From 773996617dee8acdce691b91f947a365be12c0f6 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 7 Sep 2020 00:31:26 +0200 Subject: [PATCH 001/178] Added Tags --- pom.xml | 1 + .../TagMisconfigurationException.java | 34 ++++ .../implementation/setup/PostSetup.java | 15 ++ .../slimefun4/utils/PatternUtils.java | 5 + .../slimefun4/utils/tags/SlimefunTag.java | 111 +++++++++++++ .../slimefun4/utils/tags/TagParser.java | 150 ++++++++++++++++++ .../slimefun4/utils/tags/package-info.java | 4 + .../tags/climbing_pick_surfaces.json | 19 +++ src/main/resources/tags/concrete_powders.json | 21 +++ .../tags/crop_growth_accelerator_blocks.json | 11 ++ .../tags/explosive_shovel_blocks.json | 14 ++ src/main/resources/tags/ice_variants.json | 8 + src/main/resources/tags/ores.json | 12 ++ .../tags/pickaxe_of_vein_mining_blocks.json | 9 ++ .../resources/tags/sensitive_materials.json | 10 ++ src/main/resources/tags/stone_variants.json | 8 + src/main/resources/tags/terracotta.json | 21 +++ 17 files changed, 453 insertions(+) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/TagMisconfigurationException.java create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/package-info.java create mode 100644 src/main/resources/tags/climbing_pick_surfaces.json create mode 100644 src/main/resources/tags/concrete_powders.json create mode 100644 src/main/resources/tags/crop_growth_accelerator_blocks.json create mode 100644 src/main/resources/tags/explosive_shovel_blocks.json create mode 100644 src/main/resources/tags/ice_variants.json create mode 100644 src/main/resources/tags/ores.json create mode 100644 src/main/resources/tags/pickaxe_of_vein_mining_blocks.json create mode 100644 src/main/resources/tags/sensitive_materials.json create mode 100644 src/main/resources/tags/stone_variants.json create mode 100644 src/main/resources/tags/terracotta.json diff --git a/pom.xml b/pom.xml index 5a3da9e29..97b087859 100644 --- a/pom.xml +++ b/pom.xml @@ -264,6 +264,7 @@ * + tags/* languages/* diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/TagMisconfigurationException.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/TagMisconfigurationException.java new file mode 100644 index 000000000..332031986 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/TagMisconfigurationException.java @@ -0,0 +1,34 @@ +package io.github.thebusybiscuit.slimefun4.api.exceptions; + +import javax.annotation.ParametersAreNonnullByDefault; + +import org.bukkit.NamespacedKey; + +import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; + +/** + * An {@link TagMisconfigurationException} is thrown whenever a {@link SlimefunTag} + * contains illegal, invalid or unknown values. + * + * @author TheBusyBiscuit + * + */ +public class TagMisconfigurationException extends Exception { + + private static final long serialVersionUID = 5412127960821774280L; + + /** + * This constructs a new {@link TagMisconfigurationException} for the given + * {@link SlimefunTag}'s {@link NamespacedKey} with the provided context. + * + * @param key + * The {@link NamespacedKey} of our {@link SlimefunTag} + * @param message + * The message to display + */ + @ParametersAreNonnullByDefault + public TagMisconfigurationException(NamespacedKey key, String message) { + super("Tag '" + key + "' has been misconfigured: " + message); + } + +} 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 e5cedb8c8..600e4be46 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 @@ -23,6 +23,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; +import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.AutomatedCraftingChamber; @@ -31,6 +32,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Grind import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.MakeshiftSmeltery; import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.OreCrusher; import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Smeltery; +import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItemSerializer; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItemSerializer.ItemFlag; import me.mrCookieSlime.Slimefun.Lists.RecipeType; @@ -43,6 +45,19 @@ public final class PostSetup { private PostSetup() {} + public static void loadTags() { + Slimefun.getLogger().log(Level.INFO, "Loading Tags..."); + + for (SlimefunTag tag : SlimefunTag.values()) { + try { + tag.reload(); + } + catch (TagMisconfigurationException e) { + Slimefun.getLogger().log(Level.SEVERE, "Failed to load a Tag!", e); + } + } + } + public static void setupWiki() { Slimefun.getLogger().log(Level.INFO, "Loading Wiki pages..."); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/PatternUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/PatternUtils.java index 5922adeee..d3da91f63 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/PatternUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/PatternUtils.java @@ -16,6 +16,7 @@ public final class PatternUtils { private PatternUtils() {} + public static final Pattern COLON = Pattern.compile(":"); public static final Pattern SEMICOLON = Pattern.compile(";"); public static final Pattern HASH = Pattern.compile("#"); public static final Pattern COMMA = Pattern.compile(","); @@ -27,4 +28,8 @@ public final class PatternUtils { public static final Pattern NUMERIC = Pattern.compile("[0-9]+"); public static final Pattern NUMBER_SEPARATOR = Pattern.compile("[,.]"); + + public static final Pattern MINECRAFT_MATERIAL = Pattern.compile("minecraft:[a-z_]+"); + public static final Pattern MINECRAFT_TAG = Pattern.compile("#minecraft:[a-z_]+"); + public static final Pattern SLIMEFUN_TAG = Pattern.compile("#slimefun:[a-z_]+"); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java new file mode 100644 index 000000000..a6b7a969b --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java @@ -0,0 +1,111 @@ +package io.github.thebusybiscuit.slimefun4.utils.tags; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Locale; +import java.util.Set; + +import javax.annotation.Nonnull; + +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.Tag; + +import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; + +public enum SlimefunTag implements Tag { + + SENSITIVE_MATERIALS, + + // Expanding upon Minecraft's tags: + + ORES, + TERRACOTTA, + ICE_VARIANTS, + STONE_VARIANTS, + CONCRETE_POWDERS, + + // Actual Slimefun tags: + + EXPLOSIVE_SHOVEL_BLOCKS, + PICKAXE_OF_VEIN_MINING_BLOCKS, + CROP_GROWTH_ACCELERATOR_BLOCKS, + CLIMBING_PICK_SURFACES; + + private final NamespacedKey key; + private final Set includedMaterials = new HashSet<>(); + private final Set> additionalTags = new HashSet<>(); + + SlimefunTag() { + key = new NamespacedKey(SlimefunPlugin.instance(), name().toLowerCase(Locale.ROOT)); + } + + /** + * This method reloads this {@link SlimefunTag} from our resources directory. + * + * @throws TagMisconfigurationException + * This is thrown whenever a {@link SlimefunTag} could not be parsed properly + */ + public void reload() throws TagMisconfigurationException { + new TagParser(this).parse((materials, tags) -> { + this.includedMaterials.clear(); + this.includedMaterials.addAll(materials); + + this.additionalTags.clear(); + this.additionalTags.addAll(tags); + }); + } + + @Nonnull + @Override + public NamespacedKey getKey() { + return key; + } + + @Override + public boolean isTagged(@Nonnull Material item) { + if (includedMaterials.contains(item)) { + return true; + } + else { + // Check if any of our additional Tags contain this Materials + for (Tag tag : additionalTags) { + if (tag.isTagged(item)) { + return true; + } + } + + // Now we can be sure it isn't tagged in any way + return false; + } + } + + @Nonnull + @Override + public Set getValues() { + if (additionalTags.isEmpty()) { + return Collections.unmodifiableSet(includedMaterials); + } + else { + Set values = new HashSet<>(includedMaterials); + + for (Tag tag : additionalTags) { + values.addAll(tag.getValues()); + } + + return Collections.unmodifiableSet(values); + } + } + + /** + * This method returns an Array representation for this {@link SlimefunTag}. + * + * @return A {@link Material} array for this {@link Tag} + */ + @Nonnull + public Material[] toArray() { + return getValues().toArray(new Material[0]); + } + +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java new file mode 100644 index 000000000..01f070603 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java @@ -0,0 +1,150 @@ +package io.github.thebusybiscuit.slimefun4.utils.tags; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.HashSet; +import java.util.Locale; +import java.util.Set; +import java.util.function.BiConsumer; +import java.util.stream.Collectors; + +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + +import org.bukkit.Bukkit; +import org.bukkit.Keyed; +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.Tag; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonParser; +import com.google.gson.JsonPrimitive; + +import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.utils.PatternUtils; + +class TagParser implements Keyed { + + private final NamespacedKey key; + + TagParser(@Nonnull SlimefunTag tag) { + this.key = tag.getKey(); + } + + void parse(@Nonnull BiConsumer, Set>> callback) throws TagMisconfigurationException { + Set materials = new HashSet<>(); + Set> tags = new HashSet<>(); + + JsonParser parser = new JsonParser(); + + try (BufferedReader reader = new BufferedReader(new InputStreamReader(SlimefunPlugin.class.getResourceAsStream("/tags/" + key.getKey() + ".json"), StandardCharsets.UTF_8))) { + JsonObject root = parser.parse(reader.lines().collect(Collectors.joining(""))).getAsJsonObject(); + JsonElement child = root.get("values"); + + if (child instanceof JsonArray) { + JsonArray values = child.getAsJsonArray(); + + for (JsonElement element : values) { + if (element instanceof JsonPrimitive && ((JsonPrimitive) element).isString()) { + parsePrimitiveValue(element.getAsString(), materials, tags); + } + else if (element instanceof JsonObject) { + parseComplexValue(element.getAsJsonObject(), materials, tags); + } + else { + throw new TagMisconfigurationException(key, "Unexpected value format: " + element.getClass().getSimpleName() + " - " + element.toString()); + } + } + + callback.accept(materials, tags); + } + else { + throw new TagMisconfigurationException(key, "No values array specified"); + } + } + catch (IOException | IllegalStateException | JsonParseException x) { + throw new TagMisconfigurationException(key, x.getMessage()); + } + } + + @ParametersAreNonnullByDefault + private void parsePrimitiveValue(String value, Set materials, Set> tags) throws TagMisconfigurationException { + if (PatternUtils.MINECRAFT_MATERIAL.matcher(value).matches()) { + // Match the NamespacedKey against Materials + Material material = Material.matchMaterial(value); + + if (material != null) { + materials.add(material); + } + else { + throw new TagMisconfigurationException(key, "Minecraft Material '" + value + "' seems to not exist!"); + } + } + else if (PatternUtils.MINECRAFT_TAG.matcher(value).matches()) { + String keyValue = PatternUtils.COLON.split(value)[1].toUpperCase(Locale.ROOT); + NamespacedKey namespacedKey = NamespacedKey.minecraft(keyValue); + Tag itemsTag = Bukkit.getTag(Tag.REGISTRY_ITEMS, namespacedKey, Material.class); + Tag blocksTag = Bukkit.getTag(Tag.REGISTRY_BLOCKS, namespacedKey, Material.class); + + if (itemsTag != null) { + tags.add(itemsTag); + } + else if (blocksTag != null) { + tags.add(blocksTag); + } + else { + throw new TagMisconfigurationException(key, "There is no '" + value + "' tag in Minecraft."); + } + } + else if (PatternUtils.SLIMEFUN_TAG.matcher(value).matches()) { + try { + String keyValue = PatternUtils.COLON.split(value)[1].toUpperCase(Locale.ROOT); + SlimefunTag tag = SlimefunTag.valueOf(keyValue); + tags.add(tag); + } + catch (IllegalArgumentException x) { + throw new TagMisconfigurationException(key, "There is no '" + value + "' tag in Slimefun"); + } + } + else { + throw new TagMisconfigurationException(key, "Could not recognize value '" + value + "'"); + } + } + + @ParametersAreNonnullByDefault + private void parseComplexValue(JsonObject entry, Set materials, Set> tags) throws TagMisconfigurationException { + JsonElement id = entry.get("id"); + JsonElement required = entry.get("required"); + + if (id instanceof JsonPrimitive && ((JsonPrimitive) id).isString() && required instanceof JsonPrimitive && ((JsonPrimitive) required).isBoolean()) { + if (required.getAsBoolean()) { + parsePrimitiveValue(id.getAsString(), materials, tags); + } + else { + try { + parsePrimitiveValue(id.getAsString(), materials, tags); + } + catch (TagMisconfigurationException x) { + // This is an optional entry, so we will ignore the validation here + } + } + } + else { + throw new TagMisconfigurationException(key, "Found a JSON Object value without an id!"); + } + } + + @Nonnull + @Override + public NamespacedKey getKey() { + return key; + } + +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/package-info.java new file mode 100644 index 000000000..9cd770784 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/package-info.java @@ -0,0 +1,4 @@ +/** + * This package holds utilities related to the {@link io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag} enum. + */ +package io.github.thebusybiscuit.slimefun4.utils.tags; \ No newline at end of file diff --git a/src/main/resources/tags/climbing_pick_surfaces.json b/src/main/resources/tags/climbing_pick_surfaces.json new file mode 100644 index 000000000..c72bb4368 --- /dev/null +++ b/src/main/resources/tags/climbing_pick_surfaces.json @@ -0,0 +1,19 @@ +{ + "values" : [ + "#slimefun:ice_variants", + "#slimefun:concrete_powders", + "#slimefun:terracotta", + "#slimefun:stone_variants", + "#minecraft:sand", + "minecraft:gravel", + "minecraft:netherrack", + { + "id" : "minecraft:blackstone", + "required" : false + }, + { + "id" : "minecraft:basalt", + "required" : false + } + ] +} diff --git a/src/main/resources/tags/concrete_powders.json b/src/main/resources/tags/concrete_powders.json new file mode 100644 index 000000000..a4085b8d1 --- /dev/null +++ b/src/main/resources/tags/concrete_powders.json @@ -0,0 +1,21 @@ +{ + "values" : [ + "minecraft:white_concrete_powder", + "minecraft:orange_concrete_powder", + "minecraft:magenta_concrete_powder", + "minecraft:light_blue_concrete_powder", + "minecraft:yellow_concrete_powder", + "minecraft:lime_concrete_powder", + "minecraft:pink_concrete_powder", + "minecraft:gray_concrete_powder", + "minecraft:light_gray_concrete_powder", + "minecraft:cyan_concrete_powder", + "minecraft:purple_concrete_powder", + "minecraft:blue_concrete_powder", + "minecraft:brown_concrete_powder", + "minecraft:green_concrete_powder", + "minecraft:red_concrete_powder", + "minecraft:black_concrete_powder", + "minecraft:legacy_concrete_powder" + ] +} diff --git a/src/main/resources/tags/crop_growth_accelerator_blocks.json b/src/main/resources/tags/crop_growth_accelerator_blocks.json new file mode 100644 index 000000000..7d858380a --- /dev/null +++ b/src/main/resources/tags/crop_growth_accelerator_blocks.json @@ -0,0 +1,11 @@ +{ + "values" : [ + "#minecraft:crops", + "minecraft:nether_wart", + "minecraft:cocoa", + { + "id" : "minecraft:sweet_berry_bush", + "required" : false + } + ] +} diff --git a/src/main/resources/tags/explosive_shovel_blocks.json b/src/main/resources/tags/explosive_shovel_blocks.json new file mode 100644 index 000000000..892676ece --- /dev/null +++ b/src/main/resources/tags/explosive_shovel_blocks.json @@ -0,0 +1,14 @@ +{ + "values" : [ + "#minecraft:sand", + "#minecraft:dirt_like", + "#slimefun:concrete_powders", + "minecraft:farmland", + "minecraft:grass_path", + "minecraft:snow", + "minecraft:snow_block", + "minecraft:gravel", + "minecraft:clay", + "minecraft:soul_sand" + ] +} diff --git a/src/main/resources/tags/ice_variants.json b/src/main/resources/tags/ice_variants.json new file mode 100644 index 000000000..4315fec62 --- /dev/null +++ b/src/main/resources/tags/ice_variants.json @@ -0,0 +1,8 @@ +{ + "values" : [ + "minecraft:ice", + "minecraft:packed_ice", + "minecraft:frosted_ice", + "minecraft:blue_ice" + ] +} diff --git a/src/main/resources/tags/ores.json b/src/main/resources/tags/ores.json new file mode 100644 index 000000000..c57f473ec --- /dev/null +++ b/src/main/resources/tags/ores.json @@ -0,0 +1,12 @@ +{ + "values" : [ + "#minecraft:gold_ores", + "minecraft:iron_ore", + "minecraft:coal_ore", + "minecraft:lapis_ore", + "minecraft:diamond_ore", + "minecraft:redstone_ore", + "minecraft:emerald_ore", + "minecraft:nether_quartz_ore" + ] +} diff --git a/src/main/resources/tags/pickaxe_of_vein_mining_blocks.json b/src/main/resources/tags/pickaxe_of_vein_mining_blocks.json new file mode 100644 index 000000000..7f21a6746 --- /dev/null +++ b/src/main/resources/tags/pickaxe_of_vein_mining_blocks.json @@ -0,0 +1,9 @@ +{ + "values" : [ + "#slimefun:ores", + { + "id" : "#minecraft:ancient_debris", + "required" : false + } + ] +} diff --git a/src/main/resources/tags/sensitive_materials.json b/src/main/resources/tags/sensitive_materials.json new file mode 100644 index 000000000..9306acb55 --- /dev/null +++ b/src/main/resources/tags/sensitive_materials.json @@ -0,0 +1,10 @@ +{ + "values" : [ + "#minecraft:saplings", + "#minecraft:wooden_pressure_plates", + "minecraft:stone_pressure_plate", + "minecraft:light_pressure_plate", + "minecraft:heavy_weighted_pressure_plate", + "minecraft:cake" + ] +} diff --git a/src/main/resources/tags/stone_variants.json b/src/main/resources/tags/stone_variants.json new file mode 100644 index 000000000..8a33d8958 --- /dev/null +++ b/src/main/resources/tags/stone_variants.json @@ -0,0 +1,8 @@ +{ + "values" : [ + "minecraft:stone", + "minecraft:granite", + "minecraft:andesite", + "minecraft:diorite" + ] +} diff --git a/src/main/resources/tags/terracotta.json b/src/main/resources/tags/terracotta.json new file mode 100644 index 000000000..5ce8e1e9c --- /dev/null +++ b/src/main/resources/tags/terracotta.json @@ -0,0 +1,21 @@ +{ + "values" : [ + "minecraft:terracotta", + "minecraft:white_terracotta", + "minecraft:orange_terracotta", + "minecraft:magenta_terracotta", + "minecraft:light_blue_terracotta", + "minecraft:yellow_terracotta", + "minecraft:lime_terracotta", + "minecraft:pink_terracotta", + "minecraft:gray_terracotta", + "minecraft:light_gray_terracotta", + "minecraft:cyan_terracotta", + "minecraft:purple_terracotta", + "minecraft:blue_terracotta", + "minecraft:brown_terracotta", + "minecraft:green_terracotta", + "minecraft:red_terracotta", + "minecraft:black_terracotta" + ] +} From 06498e3f639a33db27ea6a864f512f4eeb80b022 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 7 Sep 2020 01:13:25 +0200 Subject: [PATCH 002/178] Added Unit Test and loop detection --- .../implementation/SlimefunPlugin.java | 17 +++- .../implementation/setup/PostSetup.java | 16 ---- .../slimefun4/utils/tags/SlimefunTag.java | 5 ++ .../slimefun4/utils/tags/TagParser.java | 2 +- src/main/resources/tags/concrete_powders.json | 3 +- src/main/resources/tags/ores.json | 6 +- .../resources/tags/sensitive_materials.json | 2 +- .../slimefun4/testing/TestUtilities.java | 5 ++ .../testing/tests/utils/TestSlimefunTags.java | 89 +++++++++++++++++++ 9 files changed, 123 insertions(+), 22 deletions(-) create mode 100644 src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/utils/TestSlimefunTags.java 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 da8208f6f..a980d5317 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java @@ -28,6 +28,7 @@ import io.github.thebusybiscuit.cscorelib2.protection.ProtectionManager; import io.github.thebusybiscuit.cscorelib2.reflection.ReflectionUtils; import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException; import io.github.thebusybiscuit.slimefun4.api.gps.GPSNetwork; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.core.SlimefunRegistry; @@ -96,6 +97,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.setup.SlimefunItemSetup import io.github.thebusybiscuit.slimefun4.implementation.tasks.ArmorTask; import io.github.thebusybiscuit.slimefun4.implementation.tasks.SlimefunStartupTask; import io.github.thebusybiscuit.slimefun4.implementation.tasks.TickerTask; +import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import io.papermc.lib.PaperLib; import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; @@ -174,7 +176,6 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { } else if (getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) { long timestamp = System.nanoTime(); - PaperLib.suggestPaper(this); // We wanna ensure that the Server uses a compatible version of Minecraft @@ -228,6 +229,9 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { getLogger().log(Level.INFO, "Loading GEO-Resources..."); GEOResourcesSetup.setup(); + getLogger().log(Level.INFO, "Loading Tags..."); + loadTags(); + getLogger().log(Level.INFO, "Loading items..."); loadItems(); @@ -492,6 +496,17 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { new PlayerProfileListener(this); } + private void loadTags() { + for (SlimefunTag tag : SlimefunTag.values()) { + try { + tag.reload(); + } + catch (TagMisconfigurationException e) { + getLogger().log(Level.SEVERE, "Failed to load a Tag!", e); + } + } + } + private void loadItems() { try { SlimefunItemSetup.setup(this); 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 600e4be46..b38ee0987 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 @@ -23,7 +23,6 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.AutomatedCraftingChamber; @@ -32,7 +31,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Grind import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.MakeshiftSmeltery; import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.OreCrusher; import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Smeltery; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItemSerializer; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItemSerializer.ItemFlag; import me.mrCookieSlime.Slimefun.Lists.RecipeType; @@ -45,22 +43,8 @@ public final class PostSetup { private PostSetup() {} - public static void loadTags() { - Slimefun.getLogger().log(Level.INFO, "Loading Tags..."); - - for (SlimefunTag tag : SlimefunTag.values()) { - try { - tag.reload(); - } - catch (TagMisconfigurationException e) { - Slimefun.getLogger().log(Level.SEVERE, "Failed to load a Tag!", e); - } - } - } - public static void setupWiki() { Slimefun.getLogger().log(Level.INFO, "Loading Wiki pages..."); - JsonParser parser = new JsonParser(); try (BufferedReader reader = new BufferedReader(new InputStreamReader(SlimefunPlugin.class.getResourceAsStream("/wiki.json"), StandardCharsets.UTF_8))) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java index a6b7a969b..fd807270b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java @@ -98,6 +98,11 @@ public enum SlimefunTag implements Tag { } } + @Nonnull + public Set> getSubTags() { + return Collections.unmodifiableSet(additionalTags); + } + /** * This method returns an Array representation for this {@link SlimefunTag}. * diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java index 01f070603..2ea0974fc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java @@ -88,7 +88,7 @@ class TagParser implements Keyed { } } else if (PatternUtils.MINECRAFT_TAG.matcher(value).matches()) { - String keyValue = PatternUtils.COLON.split(value)[1].toUpperCase(Locale.ROOT); + String keyValue = PatternUtils.COLON.split(value)[1]; NamespacedKey namespacedKey = NamespacedKey.minecraft(keyValue); Tag itemsTag = Bukkit.getTag(Tag.REGISTRY_ITEMS, namespacedKey, Material.class); Tag blocksTag = Bukkit.getTag(Tag.REGISTRY_BLOCKS, namespacedKey, Material.class); diff --git a/src/main/resources/tags/concrete_powders.json b/src/main/resources/tags/concrete_powders.json index a4085b8d1..d4f077b0a 100644 --- a/src/main/resources/tags/concrete_powders.json +++ b/src/main/resources/tags/concrete_powders.json @@ -15,7 +15,6 @@ "minecraft:brown_concrete_powder", "minecraft:green_concrete_powder", "minecraft:red_concrete_powder", - "minecraft:black_concrete_powder", - "minecraft:legacy_concrete_powder" + "minecraft:black_concrete_powder" ] } diff --git a/src/main/resources/tags/ores.json b/src/main/resources/tags/ores.json index c57f473ec..b4c76a1a4 100644 --- a/src/main/resources/tags/ores.json +++ b/src/main/resources/tags/ores.json @@ -1,6 +1,10 @@ { "values" : [ - "#minecraft:gold_ores", + { + "id" : "#minecraft:gold_ores", + "required" : false + }, + "minecraft:gold_ore", "minecraft:iron_ore", "minecraft:coal_ore", "minecraft:lapis_ore", diff --git a/src/main/resources/tags/sensitive_materials.json b/src/main/resources/tags/sensitive_materials.json index 9306acb55..dd408500d 100644 --- a/src/main/resources/tags/sensitive_materials.json +++ b/src/main/resources/tags/sensitive_materials.json @@ -3,7 +3,7 @@ "#minecraft:saplings", "#minecraft:wooden_pressure_plates", "minecraft:stone_pressure_plate", - "minecraft:light_pressure_plate", + "minecraft:light_weighted_pressure_plate", "minecraft:heavy_weighted_pressure_plate", "minecraft:cake" ] 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..ea670bb08 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java @@ -73,7 +73,9 @@ 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("dirt_like"), Material.DIRT, Material.PODZOL, Material.MYCELIUM); 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_pressure_plates"), Material.OAK_PRESSURE_PLATE, Material.BIRCH_PRESSURE_PLATE, Material.SPRUCE_PRESSURE_PLATE, Material.JUNGLE_PRESSURE_PLATE, Material.ACACIA_PRESSURE_PLATE, Material.DARK_OAK_PRESSURE_PLATE); 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); @@ -83,6 +85,9 @@ public final class TestUtilities { 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("gold_ores"), Material.GOLD_ORE); + server.createMaterialTag(NamespacedKey.minecraft("sand"), Material.SAND, Material.RED_SAND); + server.createMaterialTag(NamespacedKey.minecraft("crops"), Material.WHEAT, Material.CARROTS, Material.POTATOES, Material.BEETROOTS); server.createMaterialTag(NamespacedKey.minecraft("ice"), Material.ICE, Material.PACKED_ICE, Material.FROSTED_ICE, Material.BLUE_ICE); } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/utils/TestSlimefunTags.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/utils/TestSlimefunTags.java new file mode 100644 index 000000000..ac7e0d495 --- /dev/null +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/utils/TestSlimefunTags.java @@ -0,0 +1,89 @@ +package io.github.thebusybiscuit.slimefun4.testing.tests.utils; + +import java.util.HashSet; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + +import org.bukkit.Material; +import org.bukkit.Tag; +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.api.exceptions.TagMisconfigurationException; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.testing.TestUtilities; +import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; + +class TestSlimefunTags { + + @BeforeAll + public static void load() { + ServerMock server = MockBukkit.mock(); + MockBukkit.load(SlimefunPlugin.class); + TestUtilities.registerDefaultTags(server); + } + + @AfterAll + public static void unload() { + MockBukkit.unmock(); + } + + @Test + @DisplayName("Test for Exceptions with Slimefun Tags") + void testTags() { + for (SlimefunTag tag : SlimefunTag.values()) { + Assertions.assertDoesNotThrow(tag::reload); + } + } + + @Test + @DisplayName("Test for infinite loops with Slimefun Tags") + void testForInfiniteLoops() throws TagMisconfigurationException { + for (SlimefunTag tag : SlimefunTag.values()) { + tag.reload(); + } + + for (SlimefunTag tag : SlimefunTag.values()) { + assertNotCyclic(tag); + } + } + + private void assertNotCyclic(@Nonnull SlimefunTag tag) { + Set visiting = new HashSet<>(); + Set visited = new HashSet<>(); + + if (isCyclic(visiting, visited, tag)) { + System.out.println("Currently visiting: " + visiting); + System.out.println("Previously visited" + visiting); + Assertions.fail("Tag '" + tag.getKey() + "' is cyclic!"); + } + } + + @ParametersAreNonnullByDefault + private boolean isCyclic(Set visiting, Set visited, SlimefunTag tag) { + visiting.add(tag); + + for (Tag sub : tag.getSubTags()) { + if (sub instanceof SlimefunTag) { + if (visiting.contains(sub)) { + return true; + } + else if (!visited.contains(sub) && isCyclic(visiting, visited, (SlimefunTag) sub)) { + return true; + } + } + } + + visiting.remove(tag); + visited.add(tag); + return false; + } + +} From b09c4af900d572ad4e4af87968537b9536ef08df Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 7 Sep 2020 03:12:31 +0200 Subject: [PATCH 003/178] Added documentation --- .../slimefun4/utils/tags/SlimefunTag.java | 73 ++++++++++++++-- .../slimefun4/utils/tags/TagParser.java | 83 ++++++++++++++++--- 2 files changed, 141 insertions(+), 15 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java index fd807270b..9f43fb983 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java @@ -13,30 +13,85 @@ import org.bukkit.Tag; import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.CropGrowthAccelerator; +import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ClimbingPick; +import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ExplosiveShovel; +import io.github.thebusybiscuit.slimefun4.implementation.items.tools.PickaxeOfTheSeeker; +/** + * This enum contains various implementations of the {@link Tag} interface. + * Most of them serve some purpose within Slimefun's implementation, some are just pure + * extensions of the default Minecraft tags. + * The actual tag files are located in the {@literal /src/main/resources/tags} directory + * and follow Minecraft's tags.json format. + * + * @author TheBusyBiscuit + * + */ public enum SlimefunTag implements Tag { + /** + * Materials which are sensitive to break. + * Things like Saplings or Pressure plates which break as well when you break + * the block beneath them. + */ SENSITIVE_MATERIALS, - // Expanding upon Minecraft's tags: - + /** + * Minecraft ores. + */ ORES, + + /** + * All terracotta variants, does not include glazed terracotta. + */ TERRACOTTA, + + /** + * All ice variants, normal, packed, blue and whatever else there is. + */ ICE_VARIANTS, + + /** + * All stone variants, normal, andesite, diorite, granite and whatever else may come. + */ STONE_VARIANTS, + + /** + * All variants of concrete powder. + * Can you believe there is no tag for this already? + */ CONCRETE_POWDERS, - // Actual Slimefun tags: - + /** + * All materials which the {@link ExplosiveShovel} can break. + */ EXPLOSIVE_SHOVEL_BLOCKS, + + /** + * All materials (ores) which the {@link PickaxeOfTheSeeker} recognizes. + */ PICKAXE_OF_VEIN_MINING_BLOCKS, + + /** + * All materials (crops) which the {@link CropGrowthAccelerator} will recognize. + */ CROP_GROWTH_ACCELERATOR_BLOCKS, + + /** + * All materials which the {@link ClimbingPick} is able to climb. + */ CLIMBING_PICK_SURFACES; private final NamespacedKey key; private final Set includedMaterials = new HashSet<>(); private final Set> additionalTags = new HashSet<>(); + /** + * This constructs a new {@link SlimefunTag}. + * The {@link NamespacedKey} will be automatically inferred using + * {@link SlimefunPlugin} and {@link #name()}. + */ SlimefunTag() { key = new NamespacedKey(SlimefunPlugin.instance(), name().toLowerCase(Locale.ROOT)); } @@ -48,7 +103,7 @@ public enum SlimefunTag implements Tag { * This is thrown whenever a {@link SlimefunTag} could not be parsed properly */ public void reload() throws TagMisconfigurationException { - new TagParser(this).parse((materials, tags) -> { + new TagParser(this).parse(this, (materials, tags) -> { this.includedMaterials.clear(); this.includedMaterials.addAll(materials); @@ -98,6 +153,14 @@ public enum SlimefunTag implements Tag { } } + /** + * This returns a {@link Set} of {@link Tag Tags} which are children of this {@link SlimefunTag}, + * these can be other {@link SlimefunTag SlimefunTags} or regular {@link Tag Tags}. + * + * The returned {@link Set} is immutable + * + * @return An immutable {@link Set} of all sub tags. + */ @Nonnull public Set> getSubTags() { return Collections.unmodifiableSet(additionalTags); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java index 2ea0974fc..120af665b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java @@ -13,6 +13,7 @@ import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.Keyed; import org.bukkit.Material; @@ -30,22 +31,69 @@ import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationExce import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.PatternUtils; -class TagParser implements Keyed { +/** + * The {@link TagParser} is responsible for parsing a JSON input into a {@link SlimefunTag}. + * + * @author TheBusyBiscuit + * + */ +public class TagParser implements Keyed { private final NamespacedKey key; - TagParser(@Nonnull SlimefunTag tag) { - this.key = tag.getKey(); + /** + * This constructs a new {@link TagParser}. + * + * @param key + * The {@link NamespacedKey} of the resulting {@link SlimefunTag} + */ + public TagParser(@Nonnull NamespacedKey key) { + this.key = key; } - void parse(@Nonnull BiConsumer, Set>> callback) throws TagMisconfigurationException { - Set materials = new HashSet<>(); - Set> tags = new HashSet<>(); + /** + * This constructs a new {@link TagParser} for the given {@link SlimefunTag} + * + * @param tag + * The {@link SlimefunTag} to parse inputs for + */ + TagParser(@Nonnull SlimefunTag tag) { + this(tag.getKey()); + } - JsonParser parser = new JsonParser(); + void parse(@Nonnull SlimefunTag tag, @Nonnull BiConsumer, Set>> callback) throws TagMisconfigurationException { + String path = "/tags/" + tag.getKey().getKey() + ".json"; - try (BufferedReader reader = new BufferedReader(new InputStreamReader(SlimefunPlugin.class.getResourceAsStream("/tags/" + key.getKey() + ".json"), StandardCharsets.UTF_8))) { - JsonObject root = parser.parse(reader.lines().collect(Collectors.joining(""))).getAsJsonObject(); + try (BufferedReader reader = new BufferedReader(new InputStreamReader(SlimefunPlugin.class.getResourceAsStream(path), StandardCharsets.UTF_8))) { + parse(reader.lines().collect(Collectors.joining("")), callback); + } + catch (IOException x) { + throw new TagMisconfigurationException(key, x.getMessage()); + } + } + + /** + * This will parse the given JSON {@link String} and run the provided callback with {@link Set Sets} of + * matched {@link Material Materials} and {@link Tag Tags}. + * + * @param json + * The JSON {@link String} to parse + * @param callback + * A callback to run after successfully parsing the input + * + * @throws TagMisconfigurationException + * This is thrown whenever the given input is malformed or no adequate + * {@link Material} or {@link Tag} could be found + */ + public void parse(@Nonnull String json, @Nonnull BiConsumer, Set>> callback) throws TagMisconfigurationException { + Validate.notNull(json, "Cannot parse a null String"); + + try { + Set materials = new HashSet<>(); + Set> tags = new HashSet<>(); + + JsonParser parser = new JsonParser(); + JsonObject root = parser.parse(json).getAsJsonObject(); JsonElement child = root.get("values"); if (child instanceof JsonArray) { @@ -53,9 +101,12 @@ class TagParser implements Keyed { for (JsonElement element : values) { if (element instanceof JsonPrimitive && ((JsonPrimitive) element).isString()) { + // Strings will be parsed directly parsePrimitiveValue(element.getAsString(), materials, tags); } else if (element instanceof JsonObject) { + // JSONObjects can have a "required" property which can make + // it optional to resolve the underlying value parseComplexValue(element.getAsJsonObject(), materials, tags); } else { @@ -63,13 +114,15 @@ class TagParser implements Keyed { } } + // Run the callback with the filled-in materials and tags callback.accept(materials, tags); } else { + // The JSON seems to be empty yet valid throw new TagMisconfigurationException(key, "No values array specified"); } } - catch (IOException | IllegalStateException | JsonParseException x) { + catch (IllegalStateException | JsonParseException x) { throw new TagMisconfigurationException(key, x.getMessage()); } } @@ -81,6 +134,7 @@ class TagParser implements Keyed { Material material = Material.matchMaterial(value); if (material != null) { + // If the Material could be matched, simply add it to our Set materials.add(material); } else { @@ -88,23 +142,28 @@ class TagParser implements Keyed { } } else if (PatternUtils.MINECRAFT_TAG.matcher(value).matches()) { + // Get the actual Key portion and match it to item and block tags. String keyValue = PatternUtils.COLON.split(value)[1]; NamespacedKey namespacedKey = NamespacedKey.minecraft(keyValue); Tag itemsTag = Bukkit.getTag(Tag.REGISTRY_ITEMS, namespacedKey, Material.class); Tag blocksTag = Bukkit.getTag(Tag.REGISTRY_BLOCKS, namespacedKey, Material.class); if (itemsTag != null) { + // We will prioritize the item tag tags.add(itemsTag); } else if (blocksTag != null) { + // If no item tag exists, fall back to the block tag tags.add(blocksTag); } else { + // If both fail, then the tag does not exist. throw new TagMisconfigurationException(key, "There is no '" + value + "' tag in Minecraft."); } } else if (PatternUtils.SLIMEFUN_TAG.matcher(value).matches()) { try { + // Get a SlimefunTag enum value for the given key String keyValue = PatternUtils.COLON.split(value)[1].toUpperCase(Locale.ROOT); SlimefunTag tag = SlimefunTag.valueOf(keyValue); tags.add(tag); @@ -114,6 +173,7 @@ class TagParser implements Keyed { } } else { + // If no RegEx pattern matched, it's malformed. throw new TagMisconfigurationException(key, "Could not recognize value '" + value + "'"); } } @@ -123,11 +183,14 @@ class TagParser implements Keyed { JsonElement id = entry.get("id"); JsonElement required = entry.get("required"); + // Check if the entry contains elements of the correct type if (id instanceof JsonPrimitive && ((JsonPrimitive) id).isString() && required instanceof JsonPrimitive && ((JsonPrimitive) required).isBoolean()) { if (required.getAsBoolean()) { + // If this entry is required, parse it like normal parsePrimitiveValue(id.getAsString(), materials, tags); } else { + // If the entry is not required, validation will be optional try { parsePrimitiveValue(id.getAsString(), materials, tags); } From 5b72faddc355bce74ac23054a0556e3cd69e5aaf Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 7 Sep 2020 11:08:39 +0200 Subject: [PATCH 004/178] Implemented tags --- .../machines/CropGrowthAccelerator.java | 22 ++----------------- .../multiblocks/miner/IndustrialMiner.java | 10 +++------ .../items/tools/ExplosiveShovel.java | 4 ++-- .../items/tools/PickaxeOfTheSeeker.java | 7 ++++-- .../items/tools/PickaxeOfVeinMining.java | 6 ++--- .../items/tools/SmeltersPickaxe.java | 4 ++-- .../listeners/BlockListener.java | 16 ++------------ .../slimefun4/utils/tags/SlimefunTag.java | 20 ++++++++++++++++- .../resources/tags/industrial_miner_ores.json | 9 ++++++++ .../tags/pickaxe_of_the_seeker_blocks.json | 9 ++++++++ .../tags/smelters_pickaxe_blocks.json | 5 +++++ 11 files changed, 61 insertions(+), 51 deletions(-) create mode 100644 src/main/resources/tags/industrial_miner_ores.json create mode 100644 src/main/resources/tags/pickaxe_of_the_seeker_blocks.json create mode 100644 src/main/resources/tags/smelters_pickaxe_blocks.json diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/CropGrowthAccelerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/CropGrowthAccelerator.java index 97a4c7887..f132a751b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/CropGrowthAccelerator.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/CropGrowthAccelerator.java @@ -1,19 +1,14 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; -import java.util.EnumSet; -import java.util.Set; - -import org.bukkit.Material; import org.bukkit.Particle; import org.bukkit.block.Block; import org.bukkit.block.data.Ageable; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; +import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -22,24 +17,11 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; public abstract class CropGrowthAccelerator extends AbstractGrowthAccelerator { - private final Set crops = EnumSet.noneOf(Material.class); - // We wanna strip the Slimefun Item id here private static final ItemStack organicFertilizer = new ItemStackWrapper(SlimefunItems.FERTILIZER); public CropGrowthAccelerator(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); - - crops.add(Material.WHEAT); - crops.add(Material.POTATOES); - crops.add(Material.CARROTS); - crops.add(Material.NETHER_WART); - crops.add(Material.BEETROOTS); - crops.add(Material.COCOA); - - if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) { - crops.add(Material.SWEET_BERRY_BUSH); - } } public abstract int getEnergyConsumption(); @@ -62,7 +44,7 @@ public abstract class CropGrowthAccelerator extends AbstractGrowthAccelerator { for (int z = -getRadius(); z <= getRadius(); z++) { Block block = b.getRelative(x, 0, z); - if (crops.contains(block.getType()) && grow(b, inv, block)) { + if (SlimefunTag.CROP_GROWTH_ACCELERATOR_BLOCKS.isTagged(block.getType()) && grow(b, inv, block)) { return; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java index 4e4a54301..be32945dd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java @@ -24,6 +24,7 @@ import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; @@ -210,16 +211,11 @@ public class IndustrialMiner extends MultiBlockMachine { * @return Whether this {@link IndustrialMiner} is capable of mining this {@link Material} */ public boolean canMine(Material type) { - if (type.name().endsWith("_ORE")) { + if (SlimefunTag.INDUSTRIAL_MINER_ORES.isTagged(type)) { return true; } else if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) { - if (type == Material.GILDED_BLACKSTONE) { - return true; - } - else if (type == Material.ANCIENT_DEBRIS) { - return canMineAncientDebris.getValue(); - } + return type == Material.ANCIENT_DEBRIS && canMineAncientDebris.getValue(); } return false; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveShovel.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveShovel.java index 0804f70aa..1d0680fb1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveShovel.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveShovel.java @@ -4,9 +4,9 @@ import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.cscorelib2.materials.MaterialTools; import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; @@ -29,7 +29,7 @@ public class ExplosiveShovel extends ExplosiveTool { @Override protected boolean canBreak(Player p, Block b) { - return MaterialTools.getBreakableByShovel().contains(b.getType()) && SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.BREAK_BLOCK); + return SlimefunTag.EXPLOSIVE_SHOVEL_BLOCKS.isTagged(b.getType()) && SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.BREAK_BLOCK); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfTheSeeker.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfTheSeeker.java index 82ae021d1..c5d57d673 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfTheSeeker.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfTheSeeker.java @@ -1,16 +1,17 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.tools; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.Event.Result; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; @@ -56,7 +57,9 @@ public class PickaxeOfTheSeeker extends SimpleSlimefunItem imple for (int x = -4; x <= 4; x++) { for (int y = -4; y <= 4; y++) { for (int z = -4; z <= 4; z++) { - if (MaterialCollections.getAllOres().contains(p.getLocation().add(x, y, z).getBlock().getType()) && (closest == null || p.getLocation().distanceSquared(closest.getLocation()) > p.getLocation().distanceSquared(p.getLocation().add(x, y, z)))) { + Material type = p.getLocation().add(x, y, z).getBlock().getType(); + + if (SlimefunTag.PICKAXE_OF_THE_SEEKER_BLOCKS.isTagged(type) && (closest == null || p.getLocation().distanceSquared(closest.getLocation()) > p.getLocation().distanceSquared(p.getLocation().add(x, y, z)))) { closest = p.getLocation().getBlock().getRelative(x, y, z); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java index 5375fcc8a..1821ad6e3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java @@ -11,12 +11,12 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.blocks.Vein; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; -import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; @@ -49,8 +49,8 @@ public class PickaxeOfVeinMining extends SimpleSlimefunItem { @Override public ToolUseHandler getItemHandler() { return (e, tool, fortune, drops) -> { - if (MaterialCollections.getAllOres().contains(e.getBlock().getType())) { - List blocks = Vein.find(e.getBlock(), maxBlocks.getValue(), MaterialCollections.getAllOres()); + if (SlimefunTag.PICKAXE_OF_VEIN_MINING_BLOCKS.isTagged(e.getBlock().getType())) { + List blocks = Vein.find(e.getBlock(), maxBlocks.getValue(), b -> SlimefunTag.PICKAXE_OF_VEIN_MINING_BLOCKS.isTagged(b.getType())); breakBlocks(e.getPlayer(), blocks, fortune); } }; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/SmeltersPickaxe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/SmeltersPickaxe.java index a4b85d96e..88934823e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/SmeltersPickaxe.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/SmeltersPickaxe.java @@ -8,11 +8,11 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -27,7 +27,7 @@ public class SmeltersPickaxe extends SimpleSlimefunItem implemen @Override public ToolUseHandler getItemHandler() { return (e, tool, fortune, drops) -> { - if (MaterialCollections.getAllOres().contains(e.getBlock().getType()) && !BlockStorage.hasBlockInfo(e.getBlock())) { + if (SlimefunTag.SMELTERS_PICKAXE_BLOCKS.isTagged(e.getBlock().getType()) && !BlockStorage.hasBlockInfo(e.getBlock())) { Collection blockDrops = e.getBlock().getDrops(getItem()); for (ItemStack drop : blockDrops) { 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..c68d81f1d 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 @@ -1,11 +1,9 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; import java.util.ArrayList; -import java.util.EnumSet; import java.util.List; import java.util.Optional; import java.util.Random; -import java.util.Set; import java.util.concurrent.ThreadLocalRandom; import javax.annotation.Nonnull; @@ -13,7 +11,6 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; -import org.bukkit.Tag; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.enchantments.Enchantment; @@ -30,6 +27,7 @@ import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason; @@ -49,18 +47,8 @@ import me.mrCookieSlime.Slimefun.api.Slimefun; */ public class BlockListener implements Listener { - // Materials that require a Block under it, e.g. Pressure Plates - private final Set sensitiveMaterials = EnumSet.noneOf(Material.class); - public BlockListener(@Nonnull SlimefunPlugin plugin) { plugin.getServer().getPluginManager().registerEvents(this, plugin); - - sensitiveMaterials.add(Material.CAKE); - sensitiveMaterials.add(Material.STONE_PRESSURE_PLATE); - sensitiveMaterials.add(Material.LIGHT_WEIGHTED_PRESSURE_PLATE); - sensitiveMaterials.add(Material.HEAVY_WEIGHTED_PRESSURE_PLATE); - sensitiveMaterials.addAll(Tag.SAPLINGS.getValues()); - sensitiveMaterials.addAll(Tag.WOODEN_PRESSURE_PLATES.getValues()); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @@ -185,7 +173,7 @@ public class BlockListener implements Listener { private void checkForSensitiveBlockAbove(Player p, Block b) { Block blockAbove = b.getRelative(BlockFace.UP); - if (sensitiveMaterials.contains(blockAbove.getType())) { + if (SlimefunTag.SENSITIVE_MATERIALS.isTagged(blockAbove.getType())) { SlimefunItem sfItem = BlockStorage.check(blockAbove); if (sfItem != null && !sfItem.useVanillaBlockBreaking()) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java index 9f43fb983..e516ca499 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java @@ -14,9 +14,12 @@ import org.bukkit.Tag; import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.CropGrowthAccelerator; +import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.miner.IndustrialMiner; import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ClimbingPick; import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ExplosiveShovel; import io.github.thebusybiscuit.slimefun4.implementation.items.tools.PickaxeOfTheSeeker; +import io.github.thebusybiscuit.slimefun4.implementation.items.tools.PickaxeOfVeinMining; +import io.github.thebusybiscuit.slimefun4.implementation.items.tools.SmeltersPickaxe; /** * This enum contains various implementations of the {@link Tag} interface. @@ -69,10 +72,25 @@ public enum SlimefunTag implements Tag { EXPLOSIVE_SHOVEL_BLOCKS, /** - * All materials (ores) which the {@link PickaxeOfTheSeeker} recognizes. + * All materials (ores) which the {@link PickaxeOfVeinMining} recognizes. */ PICKAXE_OF_VEIN_MINING_BLOCKS, + /** + * All materials (ores) which the {@link PickaxeOfTheSeeker} recognizes. + */ + PICKAXE_OF_THE_SEEKER_BLOCKS, + + /** + * All materials which the {@link SmeltersPickaxe} will try and smelt. + */ + SMELTERS_PICKAXE_BLOCKS, + + /** + * All materials (ores) which the {@link IndustrialMiner} will try to mine. + */ + INDUSTRIAL_MINER_ORES, + /** * All materials (crops) which the {@link CropGrowthAccelerator} will recognize. */ diff --git a/src/main/resources/tags/industrial_miner_ores.json b/src/main/resources/tags/industrial_miner_ores.json new file mode 100644 index 000000000..5e9d4f075 --- /dev/null +++ b/src/main/resources/tags/industrial_miner_ores.json @@ -0,0 +1,9 @@ +{ + "values" : [ + "#slimefun:ores", + { + "id" : "#minecraft:gilded_blackstone", + "required" : false + } + ] +} diff --git a/src/main/resources/tags/pickaxe_of_the_seeker_blocks.json b/src/main/resources/tags/pickaxe_of_the_seeker_blocks.json new file mode 100644 index 000000000..7f21a6746 --- /dev/null +++ b/src/main/resources/tags/pickaxe_of_the_seeker_blocks.json @@ -0,0 +1,9 @@ +{ + "values" : [ + "#slimefun:ores", + { + "id" : "#minecraft:ancient_debris", + "required" : false + } + ] +} diff --git a/src/main/resources/tags/smelters_pickaxe_blocks.json b/src/main/resources/tags/smelters_pickaxe_blocks.json new file mode 100644 index 000000000..f3eed4e22 --- /dev/null +++ b/src/main/resources/tags/smelters_pickaxe_blocks.json @@ -0,0 +1,5 @@ +{ + "values" : [ + "#slimefun:ores" + ] +} From 3220a124aa4d3570c01944b167b039a84ee518c9 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 7 Sep 2020 12:41:04 +0200 Subject: [PATCH 005/178] Added more Unit Tests --- .../slimefun4/utils/tags/SlimefunTag.java | 5 + .../resources/tags/sensitive_materials.json | 1 + src/main/resources/tags/torches.json | 10 ++ .../{utils => tags}/TestSlimefunTags.java | 58 ++++++++- .../testing/tests/tags/TestTagParser.java | 116 ++++++++++++++++++ 5 files changed, 189 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/tags/torches.json rename src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/{utils => tags}/TestSlimefunTags.java (57%) create mode 100644 src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestTagParser.java diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java index e516ca499..9b585f126 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java @@ -44,6 +44,11 @@ public enum SlimefunTag implements Tag { * Minecraft ores. */ ORES, + + /** + * All variants of torches, normal, soulfire and redstone. + */ + TORCHES, /** * All terracotta variants, does not include glazed terracotta. diff --git a/src/main/resources/tags/sensitive_materials.json b/src/main/resources/tags/sensitive_materials.json index dd408500d..bd782e1e6 100644 --- a/src/main/resources/tags/sensitive_materials.json +++ b/src/main/resources/tags/sensitive_materials.json @@ -2,6 +2,7 @@ "values" : [ "#minecraft:saplings", "#minecraft:wooden_pressure_plates", + "#slimefun:torches", "minecraft:stone_pressure_plate", "minecraft:light_weighted_pressure_plate", "minecraft:heavy_weighted_pressure_plate", diff --git a/src/main/resources/tags/torches.json b/src/main/resources/tags/torches.json new file mode 100644 index 000000000..58402d2f1 --- /dev/null +++ b/src/main/resources/tags/torches.json @@ -0,0 +1,10 @@ +{ + "values" : [ + "minecraft:torch", + "minecraft:redstone_torch", + { + "id" : "minecraft:soul_torch", + "required" : false + } + ] +} diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/utils/TestSlimefunTags.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestSlimefunTags.java similarity index 57% rename from src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/utils/TestSlimefunTags.java rename to src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestSlimefunTags.java index ac7e0d495..98120296a 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/utils/TestSlimefunTags.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestSlimefunTags.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.testing.tests.utils; +package io.github.thebusybiscuit.slimefun4.testing.tests.tags; import java.util.HashSet; import java.util.Set; @@ -55,6 +55,62 @@ class TestSlimefunTags { } } + @Test + @DisplayName("Test SlimefunTag#isTagged()") + void testIsTagged() throws TagMisconfigurationException { + for (SlimefunTag tag : SlimefunTag.values()) { + tag.reload(); + } + + // Direct inclusion + Assertions.assertTrue(SlimefunTag.SENSITIVE_MATERIALS.isTagged(Material.CAKE)); + + // Inclusion through a Minecraft Tag + Assertions.assertTrue(SlimefunTag.SENSITIVE_MATERIALS.isTagged(Material.OAK_SAPLING)); + + // Inclusion through a Slimefun Tag + Assertions.assertTrue(SlimefunTag.SENSITIVE_MATERIALS.isTagged(Material.TORCH)); + } + + @Test + @DisplayName("Test SlimefunTag#toArray()") + void testToArray() throws TagMisconfigurationException { + for (SlimefunTag tag : SlimefunTag.values()) { + tag.reload(); + } + + for (SlimefunTag tag : SlimefunTag.values()) { + Set values = tag.getValues(); + Assertions.assertArrayEquals(values.toArray(new Material[0]), tag.toArray()); + } + } + + @Test + @DisplayName("Test SlimefunTag#getValues()") + void testGetValues() throws TagMisconfigurationException { + for (SlimefunTag tag : SlimefunTag.values()) { + tag.reload(); + } + + for (SlimefunTag tag : SlimefunTag.values()) { + Set values = tag.getValues(); + + Assertions.assertFalse(values.isEmpty()); + + for (Material value : tag.getValues()) { + // All values of our tag must be tagged + Assertions.assertTrue(tag.isTagged(value)); + } + + for (Tag sub : tag.getSubTags()) { + for (Material value : sub.getValues()) { + // All values of sub tags should be tagged by our tag too + Assertions.assertTrue(tag.isTagged(value)); + } + } + } + } + private void assertNotCyclic(@Nonnull SlimefunTag tag) { Set visiting = new HashSet<>(); Set visited = new HashSet<>(); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestTagParser.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestTagParser.java new file mode 100644 index 000000000..1a4f707db --- /dev/null +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestTagParser.java @@ -0,0 +1,116 @@ +package io.github.thebusybiscuit.slimefun4.testing.tests.tags; + +import java.util.Set; + +import javax.annotation.Nonnull; + +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.Tag; +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.api.exceptions.TagMisconfigurationException; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.testing.TestUtilities; +import io.github.thebusybiscuit.slimefun4.utils.tags.TagParser; + +class TestTagParser { + + private static SlimefunPlugin plugin; + private static NamespacedKey key; + + @BeforeAll + public static void load() { + ServerMock server = MockBukkit.mock(); + plugin = MockBukkit.load(SlimefunPlugin.class); + TestUtilities.registerDefaultTags(server); + + key = new NamespacedKey(plugin, "test"); + } + + @AfterAll + public static void unload() { + MockBukkit.unmock(); + } + + @Test + @DisplayName("Test Keyed implementation") + void testkey() { + TagParser parser = new TagParser(key); + Assertions.assertEquals(key, parser.getKey()); + } + + @Test + @DisplayName("Test Nullability check") + void testNullability() { + TagParser parser = new TagParser(key); + Assertions.assertThrows(IllegalArgumentException.class, () -> parser.parse(null, this::identity)); + } + + @Test + @DisplayName("Test JSON Parsing Error handling") + void testInvalidJson() { + assertMisconfiguration(""); + assertMisconfiguration("hello world"); + } + + @Test + @DisplayName("Test no Arrays") + void testMissingArray() { + assertMisconfiguration("{}"); + assertMisconfiguration("{\"values\":\"derp\"}"); + } + + @Test + @DisplayName("Test invalid Type") + void testInvalidMaterial() { + assertMisconfiguration("{\"values\":[123456]}"); + } + + @Test + @DisplayName("Test invalid Materials") + void testInvalidMaterials() { + assertMisconfiguration("{\"values\":[\"NO\"]}"); + assertMisconfiguration("{\"values\":[\"lol:jk\"]}"); + assertMisconfiguration("{\"values\":[\"minecraft:no\"]}"); + } + + @Test + @DisplayName("Test invalid Minecraft Tags") + void testInvalidMinecraftTags() { + assertMisconfiguration("{\"values\":[\"#minecraft:never_gonna_give_you_up\"]}"); + } + + @Test + @DisplayName("Test invalid Slimefun Tags") + void testInvalidSlimefunTags() { + assertMisconfiguration("{\"values\":[\"#slimefun:never_gonna_give_you_up\"]}"); + } + + @Test + @DisplayName("Test invalid Object elements") + void testInvalidJSONObjects() { + assertMisconfiguration("{\"values\":[{}]}"); + assertMisconfiguration("{\"values\":[{\"id\":123}]}"); + assertMisconfiguration("{\"values\":[{\"id\":\"wooh\"}]}"); + assertMisconfiguration("{\"values\":[{\"required\":false}]}"); + assertMisconfiguration("{\"values\":[{\"id\":\"wooh\",\"required\":\"wooh\"}]}"); + assertMisconfiguration("{\"values\":[{\"id\":\"wooh\",\"required\":true}]}"); + } + + private void assertMisconfiguration(@Nonnull String json) { + TagParser parser = new TagParser(key); + Assertions.assertThrows(TagMisconfigurationException.class, () -> parser.parse(json, this::identity)); + } + + private void identity(Set a, Set> b) { + + } + +} From 7e7fde9a470933daca7432efda759676c44ca1fc Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 7 Sep 2020 12:59:38 +0200 Subject: [PATCH 006/178] Slight correction --- src/main/resources/tags/pickaxe_of_vein_mining_blocks.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/tags/pickaxe_of_vein_mining_blocks.json b/src/main/resources/tags/pickaxe_of_vein_mining_blocks.json index 7f21a6746..901df5bb8 100644 --- a/src/main/resources/tags/pickaxe_of_vein_mining_blocks.json +++ b/src/main/resources/tags/pickaxe_of_vein_mining_blocks.json @@ -2,7 +2,7 @@ "values" : [ "#slimefun:ores", { - "id" : "#minecraft:ancient_debris", + "id" : "minecraft:ancient_debris", "required" : false } ] From 4fe2aee565627d11410b279a7e549e1e33b3969c Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 7 Sep 2020 13:00:15 +0200 Subject: [PATCH 007/178] Another mistake --- src/main/resources/tags/industrial_miner_ores.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/tags/industrial_miner_ores.json b/src/main/resources/tags/industrial_miner_ores.json index 5e9d4f075..8e81463c4 100644 --- a/src/main/resources/tags/industrial_miner_ores.json +++ b/src/main/resources/tags/industrial_miner_ores.json @@ -2,7 +2,7 @@ "values" : [ "#slimefun:ores", { - "id" : "#minecraft:gilded_blackstone", + "id" : "minecraft:gilded_blackstone", "required" : false } ] From 7c8b8e0c59f17212bc866fa9ec9495c2e802e628 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 7 Sep 2020 13:02:59 +0200 Subject: [PATCH 008/178] Discord webhook, please work --- .../slimefun4/testing/tests/tags/TestTagParser.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestTagParser.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestTagParser.java index 1a4f707db..d8885cb23 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestTagParser.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestTagParser.java @@ -1,12 +1,8 @@ package io.github.thebusybiscuit.slimefun4.testing.tests.tags; -import java.util.Set; - import javax.annotation.Nonnull; -import org.bukkit.Material; import org.bukkit.NamespacedKey; -import org.bukkit.Tag; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; @@ -50,7 +46,7 @@ class TestTagParser { @DisplayName("Test Nullability check") void testNullability() { TagParser parser = new TagParser(key); - Assertions.assertThrows(IllegalArgumentException.class, () -> parser.parse(null, this::identity)); + Assertions.assertThrows(IllegalArgumentException.class, () -> parser.parse(null, (a, b) -> {})); } @Test @@ -106,11 +102,7 @@ class TestTagParser { private void assertMisconfiguration(@Nonnull String json) { TagParser parser = new TagParser(key); - Assertions.assertThrows(TagMisconfigurationException.class, () -> parser.parse(json, this::identity)); - } - - private void identity(Set a, Set> b) { - + Assertions.assertThrows(TagMisconfigurationException.class, () -> parser.parse(json, (a, b) -> {})); } } From 035e35a067cef1dc71d0a3482070edc64655e064 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 9 Sep 2020 15:34:58 +0200 Subject: [PATCH 009/178] Implemented tags in more occurences --- .../items/androids/FisherAndroid.java | 4 ++-- .../electric/machines/ElectrifiedCrucible.java | 4 ++-- .../implementation/items/tools/LumberAxe.java | 3 +-- .../slimefun4/utils/tags/SlimefunTag.java | 13 ++++++++++++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FisherAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FisherAndroid.java index 085895521..d2e9ce0c3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FisherAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FisherAndroid.java @@ -4,12 +4,12 @@ import java.util.concurrent.ThreadLocalRandom; 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.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.collections.RandomizedSet; -import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Lists.RecipeType; @@ -25,7 +25,7 @@ public class FisherAndroid extends ProgrammableAndroid { super(category, tier, item, recipeType, recipe); // Fish - for (Material fish : MaterialCollections.getAllFishItems()) { + for (Material fish : Tag.ITEMS_FISHES.getValues()) { fishingLoot.add(new ItemStack(fish), 25); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectrifiedCrucible.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectrifiedCrucible.java index 8bd212d00..f0d7c128d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectrifiedCrucible.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectrifiedCrucible.java @@ -4,7 +4,7 @@ import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; +import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; @@ -22,7 +22,7 @@ public abstract class ElectrifiedCrucible extends AContainer { registerRecipe(8, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.TERRACOTTA, 12) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.OBSIDIAN) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); - for (Material terracotta : MaterialCollections.getAllTerracottaColors().getAsArray()) { + for (Material terracotta : SlimefunTag.TERRACOTTA.getValues()) { registerRecipe(8, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(terracotta, 12) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/LumberAxe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/LumberAxe.java index 0e55e7ddb..084953de6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/LumberAxe.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/LumberAxe.java @@ -12,7 +12,6 @@ import org.bukkit.block.data.Orientable; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.blocks.Vein; -import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; @@ -49,7 +48,7 @@ public class LumberAxe extends SimpleSlimefunItem implements Not private ToolUseHandler onBlockBreak() { return (e, tool, fortune, drops) -> { - if (MaterialCollections.getAllLogs().contains(e.getBlock().getType())) { + if (Tag.LOGS.isTagged(e.getBlock().getType())) { List logs = Vein.find(e.getBlock(), MAX_BROKEN, b -> Tag.LOGS.isTagged(b.getType())); if (logs.contains(e.getBlock())) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java index 9b585f126..e78e3834e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java @@ -4,6 +4,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.Locale; import java.util.Set; +import java.util.stream.Stream; import javax.annotation.Nonnull; @@ -44,7 +45,7 @@ public enum SlimefunTag implements Tag { * Minecraft ores. */ ORES, - + /** * All variants of torches, normal, soulfire and redstone. */ @@ -199,4 +200,14 @@ public enum SlimefunTag implements Tag { return getValues().toArray(new Material[0]); } + /** + * This returns a {@link Stream} of {@link Material Materials} for this {@link SlimefunTag}. + * + * @return A {@link Stream} of {@link Material Materials} + */ + @Nonnull + public Stream stream() { + return getValues().stream(); + } + } From 9655761ab15b1195189c884b096ebff3fd172994 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 9 Sep 2020 15:43:44 +0200 Subject: [PATCH 010/178] Micro-optimizations Walshy would be proud of --- .../items/androids/Instruction.java | 10 +++---- .../items/androids/ProgrammableAndroid.java | 4 +-- .../slimefun4/utils/tags/SlimefunTag.java | 30 +++++++++++++++++++ .../slimefun4/utils/tags/TagParser.java | 11 +++---- 4 files changed, 43 insertions(+), 12 deletions(-) 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 e80029472..429821dc4 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 @@ -148,16 +148,16 @@ enum Instruction { private static final Map nameLookup = 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) { nameLookup.put(instruction.name(), instruction); } } + private final ItemStack item; + private final AndroidType type; + private final AndroidAction method; + @ParametersAreNonnullByDefault Instruction(AndroidType type, HeadTexture head, @Nullable AndroidAction method) { this.type = type; @@ -198,7 +198,7 @@ enum Instruction { * @return The {@link Instruction} or null if it does not exist. */ @Nullable - public static Instruction getFromCache(@Nonnull String value) { + public static Instruction getInstruction(@Nonnull String 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 096abbf8e..ddd070463 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 @@ -255,7 +255,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, }); } else { - Instruction instruction = Instruction.getFromCache(script[i]); + Instruction instruction = Instruction.getInstruction(script[i]); if (instruction == null) { SlimefunPlugin.instance().getLogger().log(Level.WARNING, "Failed to parse Android instruction: {0}, maybe your server is out of date?", script[i]); @@ -655,7 +655,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, } BlockStorage.addBlockInfo(b, "fuel", String.valueOf(fuel - 1)); - Instruction instruction = Instruction.getFromCache(script[index]); + Instruction instruction = Instruction.getInstruction(script[index]); if (instruction == null) { SlimefunPlugin.instance().getLogger().log(Level.WARNING, "Failed to parse Android instruction: {0}, maybe your server is out of date?", script[index]); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java index e78e3834e..edeb7a241 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java @@ -1,13 +1,17 @@ package io.github.thebusybiscuit.slimefun4.utils.tags; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.Locale; +import java.util.Map; import java.util.Set; import java.util.stream.Stream; import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import org.apache.commons.lang.Validate; import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.Tag; @@ -107,6 +111,15 @@ public enum SlimefunTag implements Tag { */ CLIMBING_PICK_SURFACES; + private static final Map nameLookup = new HashMap<>(); + public static final SlimefunTag[] values = values(); + + static { + for (SlimefunTag tag : values) { + nameLookup.put(tag.name(), tag); + } + } + private final NamespacedKey key; private final Set includedMaterials = new HashSet<>(); private final Set> additionalTags = new HashSet<>(); @@ -210,4 +223,21 @@ public enum SlimefunTag implements Tag { return getValues().stream(); } + /** + * 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 SlimefunTag} or null if it does not exist. + */ + @Nullable + public static SlimefunTag getTag(@Nonnull String value) { + Validate.notNull(value, "A tag cannot be null!"); + return nameLookup.get(value); + } + } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java index 120af665b..e15947a79 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java @@ -162,13 +162,14 @@ public class TagParser implements Keyed { } } else if (PatternUtils.SLIMEFUN_TAG.matcher(value).matches()) { - try { - // Get a SlimefunTag enum value for the given key - String keyValue = PatternUtils.COLON.split(value)[1].toUpperCase(Locale.ROOT); - SlimefunTag tag = SlimefunTag.valueOf(keyValue); + // Get a SlimefunTag enum value for the given key + String keyValue = PatternUtils.COLON.split(value)[1].toUpperCase(Locale.ROOT); + SlimefunTag tag = SlimefunTag.getTag(keyValue); + + if (tag != null) { tags.add(tag); } - catch (IllegalArgumentException x) { + else { throw new TagMisconfigurationException(key, "There is no '" + value + "' tag in Slimefun"); } } From 19c67a226606bc27e98fd2b0cea2dfcd14994039 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 9 Sep 2020 15:52:59 +0200 Subject: [PATCH 011/178] Unit Test should no longer fail --- .../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 ea670bb08..91eb08ac5 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java @@ -89,6 +89,7 @@ public final class TestUtilities { server.createMaterialTag(NamespacedKey.minecraft("sand"), Material.SAND, Material.RED_SAND); server.createMaterialTag(NamespacedKey.minecraft("crops"), Material.WHEAT, Material.CARROTS, Material.POTATOES, Material.BEETROOTS); server.createMaterialTag(NamespacedKey.minecraft("ice"), Material.ICE, Material.PACKED_ICE, Material.FROSTED_ICE, Material.BLUE_ICE); + server.createMaterialTag(NamespacedKey.minecraft("fishes"), Material.COD, Material.SALMON); } } From 8a3165e9ba99288bde4791e1069e3b085b1b72b8 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 10 Sep 2020 00:33:47 +0200 Subject: [PATCH 012/178] Fixed some tags and added glass --- .../slimefun4/utils/tags/SlimefunTag.java | 16 ++++++++++++++ .../tags/explosive_shovel_blocks.json | 6 +++++- src/main/resources/tags/glass.json | 6 ++++++ src/main/resources/tags/glass_blocks.json | 21 +++++++++++++++++++ src/main/resources/tags/glass_panes.json | 21 +++++++++++++++++++ .../tags/pickaxe_of_the_seeker_blocks.json | 2 +- .../tags/smelters_pickaxe_blocks.json | 7 ++++++- 7 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/tags/glass.json create mode 100644 src/main/resources/tags/glass_blocks.json create mode 100644 src/main/resources/tags/glass_panes.json diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java index edeb7a241..9079d908e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java @@ -50,6 +50,22 @@ public enum SlimefunTag implements Tag { */ ORES, + /** + * Every glass variant, includes both blocks and panes. + * Also stained glass and stained glass panes. + */ + GLASS, + + /** + * All variants of glass, normal and stained. + */ + GLASS_BLOCKS, + + /** + * All variants of glass panes, normal and stained. + */ + GLASS_PANES, + /** * All variants of torches, normal, soulfire and redstone. */ diff --git a/src/main/resources/tags/explosive_shovel_blocks.json b/src/main/resources/tags/explosive_shovel_blocks.json index 892676ece..da0f980ff 100644 --- a/src/main/resources/tags/explosive_shovel_blocks.json +++ b/src/main/resources/tags/explosive_shovel_blocks.json @@ -9,6 +9,10 @@ "minecraft:snow_block", "minecraft:gravel", "minecraft:clay", - "minecraft:soul_sand" + "minecraft:soul_sand", + { + "id" : "minecraft:soul_soil", + "required" : false + } ] } diff --git a/src/main/resources/tags/glass.json b/src/main/resources/tags/glass.json new file mode 100644 index 000000000..ef4c6c260 --- /dev/null +++ b/src/main/resources/tags/glass.json @@ -0,0 +1,6 @@ +{ + "values" : [ + "#slimefun:glass_blocks", + "#slimefun:glass_panes" + ] +} diff --git a/src/main/resources/tags/glass_blocks.json b/src/main/resources/tags/glass_blocks.json new file mode 100644 index 000000000..92346ab19 --- /dev/null +++ b/src/main/resources/tags/glass_blocks.json @@ -0,0 +1,21 @@ +{ + "values" : [ + "minecraft:glass", + "minecraft:white_stained_glass", + "minecraft:orange_stained_glass", + "minecraft:magenta_stained_glass", + "minecraft:light_blue_stained_glass", + "minecraft:yellow_stained_glass", + "minecraft:lime_stained_glass", + "minecraft:pink_stained_glass", + "minecraft:gray_stained_glass", + "minecraft:light_gray_stained_glass", + "minecraft:cyan_stained_glass", + "minecraft:purple_stained_glass", + "minecraft:blue_stained_glass", + "minecraft:brown_stained_glass", + "minecraft:green_stained_glass", + "minecraft:red_stained_glass", + "minecraft:black_stained_glass" + ] +} diff --git a/src/main/resources/tags/glass_panes.json b/src/main/resources/tags/glass_panes.json new file mode 100644 index 000000000..2defd74ca --- /dev/null +++ b/src/main/resources/tags/glass_panes.json @@ -0,0 +1,21 @@ +{ + "values" : [ + "minecraft:glass_pane", + "minecraft:white_stained_glass_pane", + "minecraft:orange_stained_glass_pane", + "minecraft:magenta_stained_glass_pane", + "minecraft:light_blue_stained_glass_pane", + "minecraft:yellow_stained_glass_pane", + "minecraft:lime_stained_glass_pane", + "minecraft:pink_stained_glass_pane", + "minecraft:gray_stained_glass_pane", + "minecraft:light_gray_stained_glass_pane", + "minecraft:cyan_stained_glass_pane", + "minecraft:purple_stained_glass_pane", + "minecraft:blue_stained_glass_pane", + "minecraft:brown_stained_glass_pane", + "minecraft:green_stained_glass_pane", + "minecraft:red_stained_glass_pane", + "minecraft:black_stained_glass_pane" + ] +} diff --git a/src/main/resources/tags/pickaxe_of_the_seeker_blocks.json b/src/main/resources/tags/pickaxe_of_the_seeker_blocks.json index 7f21a6746..901df5bb8 100644 --- a/src/main/resources/tags/pickaxe_of_the_seeker_blocks.json +++ b/src/main/resources/tags/pickaxe_of_the_seeker_blocks.json @@ -2,7 +2,7 @@ "values" : [ "#slimefun:ores", { - "id" : "#minecraft:ancient_debris", + "id" : "minecraft:ancient_debris", "required" : false } ] diff --git a/src/main/resources/tags/smelters_pickaxe_blocks.json b/src/main/resources/tags/smelters_pickaxe_blocks.json index f3eed4e22..79444a5aa 100644 --- a/src/main/resources/tags/smelters_pickaxe_blocks.json +++ b/src/main/resources/tags/smelters_pickaxe_blocks.json @@ -1,5 +1,10 @@ { "values" : [ - "#slimefun:ores" + { + "id" : "#minecraft:gold_ores", + "required" : false + }, + "minecraft:gold_ore", + "minecraft:iron_ore" ] } From 74edbe499c42c872e3cc73cb574a69e021e158f0 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 11 Sep 2020 00:07:26 +0200 Subject: [PATCH 013/178] Fixes #2238 --- CHANGELOG.md | 4 +++ .../items/backpacks/SlimefunBackpack.java | 11 ++++-- .../items/blocks/BlockPlacer.java | 18 ++++++---- .../slimefun4/utils/tags/SlimefunTag.java | 36 +++++++++++++------ .../tags/block_placer_ignored_materials.json | 16 +++++++++ src/main/resources/tags/mushrooms.json | 14 ++++++++ src/main/resources/tags/shulker_boxes.json | 21 +++++++++++ .../slimefun4/testing/TestUtilities.java | 2 ++ 8 files changed, 103 insertions(+), 19 deletions(-) create mode 100644 src/main/resources/tags/block_placer_ignored_materials.json create mode 100644 src/main/resources/tags/mushrooms.json create mode 100644 src/main/resources/tags/shulker_boxes.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f5059795..04396c8d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,12 +24,16 @@ ## Release Candidate 17 (TBD) +#### Additions +* (API) Added custom tags for developers + #### Changes * Improved Auto-Updater (Multi-Threading and more) #### Fixes * Fixed #2300 * Fixed #2296 +* Fixed #2238 ## 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/backpacks/SlimefunBackpack.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SlimefunBackpack.java index 5d7af79f1..a7c512eda 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SlimefunBackpack.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SlimefunBackpack.java @@ -1,6 +1,9 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.backpacks; -import org.bukkit.Material; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; @@ -9,6 +12,7 @@ import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; import io.github.thebusybiscuit.slimefun4.implementation.listeners.BackpackListener; +import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; @@ -28,6 +32,7 @@ public class SlimefunBackpack extends SimpleSlimefunItem { private final int size; + @ParametersAreNonnullByDefault public SlimefunBackpack(int size, Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); @@ -55,9 +60,9 @@ public class SlimefunBackpack extends SimpleSlimefunItem { * * @return Whether the given {@link ItemStack} is allowed to be put into this {@link SlimefunBackpack} */ - public boolean isItemAllowed(ItemStack item, SlimefunItem itemAsSlimefunItem) { + public boolean isItemAllowed(@Nonnull ItemStack item, @Nullable SlimefunItem itemAsSlimefunItem) { // Shulker Boxes are not allowed! - if (item.getType() == Material.SHULKER_BOX || item.getType().toString().endsWith("_SHULKER_BOX")) { + if (SlimefunTag.SHULKER_BOXES.isTagged(item.getType())) { return false; } 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..b3bffe225 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 @@ -26,6 +26,7 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockDispenseHandler; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import io.papermc.lib.PaperLib; import io.papermc.lib.features.blockstatesnapshot.BlockStateSnapshotResult; import me.mrCookieSlime.Slimefun.Lists.RecipeType; @@ -73,10 +74,13 @@ public class BlockPlacer extends SlimefunItem { private BlockDispenseHandler onBlockDispense() { return (e, dispenser, facedBlock, machine) -> { if (!hasPermission(dispenser, facedBlock)) { + e.setCancelled(true); return; } - if (isShulkerBox(e.getItem().getType())) { + Material material = e.getItem().getType(); + + if (SlimefunTag.SHULKER_BOXES.isTagged(material)) { // Since vanilla Dispensers can already place Shulker boxes, we // simply fallback to the vanilla behaviour. return; @@ -84,7 +88,13 @@ public class BlockPlacer extends SlimefunItem { e.setCancelled(true); - if (facedBlock.isEmpty() && e.getItem().getType().isBlock() && !isBlacklisted(e.getItem().getType())) { + if (!material.isBlock() || SlimefunTag.BLOCK_PLACER_IGNORED_MATERIALS.isTagged(material)) { + // Some materials cannot be reliably placed, like beds, it would look + // kinda wonky, so we just ignore these altogether + return; + } + + if (facedBlock.isEmpty() && !isBlacklisted(material)) { SlimefunItem item = SlimefunItem.getByItem(e.getItem()); if (item != null) { @@ -125,10 +135,6 @@ public class BlockPlacer extends SlimefunItem { return SlimefunPlugin.getProtectionManager().hasPermission(player, target, ProtectableAction.PLACE_BLOCK); } - private boolean isShulkerBox(Material type) { - return type == Material.SHULKER_BOX || type.name().endsWith("_SHULKER_BOX"); - } - private boolean isBlacklisted(Material type) { for (String blockType : blacklist.getValue()) { if (type.toString().equals(blockType)) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java index 9079d908e..c845478e0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java @@ -18,6 +18,7 @@ import org.bukkit.Tag; import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BlockPlacer; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.CropGrowthAccelerator; import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.miner.IndustrialMiner; import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ClimbingPick; @@ -38,18 +39,21 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.tools.SmeltersPic */ public enum SlimefunTag implements Tag { - /** - * Materials which are sensitive to break. - * Things like Saplings or Pressure plates which break as well when you break - * the block beneath them. - */ - SENSITIVE_MATERIALS, - /** * Minecraft ores. */ ORES, + /** + * All Shulker boxes, normal and colored. + */ + SHULKER_BOXES, + + /** + * Every mushroom type, red, brown and nether ones. + */ + MUSHROOMS, + /** * Every glass variant, includes both blocks and panes. * Also stained glass and stained glass panes. @@ -92,6 +96,18 @@ public enum SlimefunTag implements Tag { */ CONCRETE_POWDERS, + /** + * Materials which are sensitive to break. + * Things like Saplings or Pressure plates which break as well when you break + * the block beneath them. + */ + SENSITIVE_MATERIALS, + + /** + * Materials which cannot be reliably placed using a {@link BlockPlacer}. + */ + BLOCK_PLACER_IGNORED_MATERIALS, + /** * All materials which the {@link ExplosiveShovel} can break. */ @@ -196,13 +212,13 @@ public enum SlimefunTag implements Tag { return Collections.unmodifiableSet(includedMaterials); } else { - Set values = new HashSet<>(includedMaterials); + Set materials = new HashSet<>(includedMaterials); for (Tag tag : additionalTags) { - values.addAll(tag.getValues()); + materials.addAll(tag.getValues()); } - return Collections.unmodifiableSet(values); + return materials; } } diff --git a/src/main/resources/tags/block_placer_ignored_materials.json b/src/main/resources/tags/block_placer_ignored_materials.json new file mode 100644 index 000000000..5c3f4c887 --- /dev/null +++ b/src/main/resources/tags/block_placer_ignored_materials.json @@ -0,0 +1,16 @@ +{ + "values" : [ + "#slimefun:sensitive_materials", + "#slimefun:mushrooms", + "#minecraft:tall_flowers", + "#minecraft:beds", + "#minecraft:doors", + "minecraft:sugar_cane", + "minecraft:lily_pad", + "minecraft:dead_bush", + { + "id" : "minecraft:bamboo", + "required" : false + } + ] +} diff --git a/src/main/resources/tags/mushrooms.json b/src/main/resources/tags/mushrooms.json new file mode 100644 index 000000000..48def4144 --- /dev/null +++ b/src/main/resources/tags/mushrooms.json @@ -0,0 +1,14 @@ +{ + "values" : [ + "minecraft:red_mushroom", + "minecraft:brown_mushroom", + { + "id" : "minecraft:crimson_fungus", + "required" : false + }, + { + "id" : "minecraft:warped_fungus", + "required" : false + } + ] +} diff --git a/src/main/resources/tags/shulker_boxes.json b/src/main/resources/tags/shulker_boxes.json new file mode 100644 index 000000000..4a47012ce --- /dev/null +++ b/src/main/resources/tags/shulker_boxes.json @@ -0,0 +1,21 @@ +{ + "values" : [ + "minecraft:shulker_box", + "minecraft:white_shulker_box", + "minecraft:orange_shulker_box", + "minecraft:magenta_shulker_box", + "minecraft:light_blue_shulker_box", + "minecraft:yellow_shulker_box", + "minecraft:lime_shulker_box", + "minecraft:pink_shulker_box", + "minecraft:gray_shulker_box", + "minecraft:light_gray_shulker_box", + "minecraft:cyan_shulker_box", + "minecraft:purple_shulker_box", + "minecraft:blue_shulker_box", + "minecraft:brown_shulker_box", + "minecraft:green_shulker_box", + "minecraft:red_shulker_box", + "minecraft:black_shulker_box" + ] +} 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 91eb08ac5..eedb399ed 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java @@ -81,6 +81,7 @@ public final class TestUtilities { 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("tall_flowers"), Material.PEONY, Material.SUNFLOWER); 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); @@ -89,6 +90,7 @@ public final class TestUtilities { server.createMaterialTag(NamespacedKey.minecraft("sand"), Material.SAND, Material.RED_SAND); server.createMaterialTag(NamespacedKey.minecraft("crops"), Material.WHEAT, Material.CARROTS, Material.POTATOES, Material.BEETROOTS); server.createMaterialTag(NamespacedKey.minecraft("ice"), Material.ICE, Material.PACKED_ICE, Material.FROSTED_ICE, Material.BLUE_ICE); + server.createMaterialTag(NamespacedKey.minecraft("beds"), Material.RED_BED, Material.BLUE_BED); server.createMaterialTag(NamespacedKey.minecraft("fishes"), Material.COD, Material.SALMON); } From ff9a6f7a3ee6cb25a668b0e3382e2019ade6b39f Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 11 Sep 2020 10:44:00 +0200 Subject: [PATCH 014/178] Fixed Unit Tests --- .../implementation/SlimefunPlugin.java | 2 +- .../slimefun4/testing/TestUtilities.java | 1 + .../tests/listeners/TestBackpackListener.java | 43 +++++++++++++------ 3 files changed, 32 insertions(+), 14 deletions(-) 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 4eb84069e..1582446c4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java @@ -497,7 +497,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { } private void loadTags() { - for (SlimefunTag tag : SlimefunTag.values()) { + for (SlimefunTag tag : SlimefunTag.values) { try { tag.reload(); } 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 eedb399ed..c9fdac952 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java @@ -92,6 +92,7 @@ public final class TestUtilities { server.createMaterialTag(NamespacedKey.minecraft("ice"), Material.ICE, Material.PACKED_ICE, Material.FROSTED_ICE, Material.BLUE_ICE); server.createMaterialTag(NamespacedKey.minecraft("beds"), Material.RED_BED, Material.BLUE_BED); server.createMaterialTag(NamespacedKey.minecraft("fishes"), Material.COD, Material.SALMON); + server.createMaterialTag(NamespacedKey.minecraft("doors"), Material.OAK_DOOR, Material.IRON_DOOR); } } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestBackpackListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestBackpackListener.java index a7c6dd4f1..d798b1677 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestBackpackListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestBackpackListener.java @@ -1,5 +1,6 @@ package io.github.thebusybiscuit.slimefun4.testing.tests.listeners; +import java.util.UUID; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; @@ -21,25 +22,28 @@ 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.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; -import org.mockito.Mockito; import be.seeseemelk.mockbukkit.MockBukkit; import be.seeseemelk.mockbukkit.ServerMock; +import be.seeseemelk.mockbukkit.entity.ItemEntityMock; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; +import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException; import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; 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 io.github.thebusybiscuit.slimefun4.testing.TestUtilities; +import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; -public class TestBackpackListener { +class TestBackpackListener { private static final int BACKPACK_SIZE = 27; private static ServerMock server; @@ -47,9 +51,15 @@ public class TestBackpackListener { private static BackpackListener listener; @BeforeAll - public static void load() { + public static void load() throws TagMisconfigurationException { server = MockBukkit.mock(); + TestUtilities.registerDefaultTags(server); plugin = MockBukkit.load(SlimefunPlugin.class); + + for (SlimefunTag tag : SlimefunTag.values) { + tag.reload(); + } + listener = new BackpackListener(); listener.register(plugin); } @@ -89,7 +99,8 @@ public class TestBackpackListener { } @Test - public void testIllegalSetId() { + @DisplayName("Verify an Exception is thrown when setting a backpack id to invalid items") + void testIllegalSetId() { Player player = server.addPlayer(); Assertions.assertThrows(IllegalArgumentException.class, () -> listener.setBackpackId(null, null, 1, 1)); @@ -100,7 +111,8 @@ public class TestBackpackListener { } @Test - public void testSetId() throws InterruptedException { + @DisplayName("Test if backpack id is properly applied to the lore") + void testSetId() throws InterruptedException { Player player = server.addPlayer(); ItemStack item = new CustomItem(Material.CHEST, "&cA mocked Backpack", "", "&7Size: &e" + BACKPACK_SIZE, "&7ID: ", "", "&7&eRight Click&7 to open"); @@ -116,7 +128,8 @@ public class TestBackpackListener { } @Test - public void testOpenBackpack() throws InterruptedException { + @DisplayName("Test backpacks opening to Players") + void testOpenBackpack() throws InterruptedException { Player player = server.addPlayer(); PlayerBackpack backpack = openMockBackpack(player, "TEST_OPEN_BACKPACK", 27); InventoryView view = player.getOpenInventory(); @@ -124,7 +137,8 @@ public class TestBackpackListener { } @Test - public void testCloseBackpack() throws InterruptedException { + @DisplayName("Test backpacks being marked dirty on close") + void testCloseBackpack() throws InterruptedException { Player player = server.addPlayer(); PlayerBackpack backpack = openMockBackpack(player, "TEST_CLOSE_BACKPACK", 27); listener.onClose(new InventoryCloseEvent(player.getOpenInventory())); @@ -133,12 +147,12 @@ public class TestBackpackListener { } @Test - public void testBackpackDropNormalItem() throws InterruptedException { + @DisplayName("Test backpacks not disturbing normal item dropping") + void testBackpackDropNormalItem() throws InterruptedException { Player player = server.addPlayer(); openMockBackpack(player, "DROP_NORMAL_ITEM_BACKPACK_TEST", 27); - Item item = Mockito.mock(Item.class); - Mockito.when(item.getItemStack()).thenReturn(new ItemStack(Material.SUGAR_CANE)); + Item item = new ItemEntityMock(server, UUID.randomUUID(), new ItemStack(Material.SUGAR_CANE)); PlayerDropItemEvent event = new PlayerDropItemEvent(player, item); listener.onItemDrop(event); @@ -157,20 +171,23 @@ public class TestBackpackListener { } @ParameterizedTest + @DisplayName("Test backpacks allowing normal materials") @EnumSource(value = Material.class, names = { "AIR", "DIAMOND", "STONE" }) - public void areItemsAllowed(Material type) throws InterruptedException { + void areItemsAllowed(Material type) throws InterruptedException { Assertions.assertTrue(isAllowed("BACKPACK_ALLOWANCE_" + type.name(), new ItemStack(type))); } @ParameterizedTest + @DisplayName("Test backpacks rejecting certain materials") @EnumSource(value = Material.class, names = { "SHULKER_BOX", "RED_SHULKER_BOX", "BLUE_SHULKER_BOX", "BLACK_SHULKER_BOX" }) - public void areShulkerBoxesAllowed(Material type) throws InterruptedException { + void areShulkerBoxesAllowed(Material type) throws InterruptedException { Assertions.assertFalse(isAllowed("BACKPACK_ALLOWANCE_" + type.name(), new ItemStack(type))); } @ParameterizedTest + @DisplayName("Test backpacks hotbar key exploits") @EnumSource(value = Material.class, names = { "AIR", "SHULKER_BOX" }) - public void testHotbarKey(Material type) throws InterruptedException { + void testHotbarKey(Material type) throws InterruptedException { Player player = server.addPlayer(); openMockBackpack(player, "BACKPACK_HOTBAR_" + type.name(), 9); From b14f0b76c0a72e7e3a937542f6fd1fe8997bfb3f Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 13 Sep 2020 12:00:45 +0200 Subject: [PATCH 015/178] Added unbreakable tag --- .../implementation/items/androids/MinerAndroid.java | 6 +++--- .../implementation/items/blocks/BlockPlacer.java | 3 +-- .../implementation/items/blocks/Crucible.java | 4 ++-- .../implementation/items/tools/ExplosiveTool.java | 4 ++-- .../slimefun4/utils/tags/SlimefunTag.java | 10 ++++++++++ src/main/resources/tags/command_blocks.json | 7 +++++++ src/main/resources/tags/unbreakable_materials.json | 13 +++++++++++++ 7 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 src/main/resources/tags/command_blocks.json create mode 100644 src/main/resources/tags/unbreakable_materials.json diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java index 48b90420b..2108caa10 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java @@ -11,10 +11,10 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; import io.github.thebusybiscuit.slimefun4.api.events.AndroidMineEvent; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; @@ -40,7 +40,7 @@ public class MinerAndroid extends ProgrammableAndroid { protected void dig(Block b, BlockMenu menu, Block block) { Collection drops = block.getDrops(effectivePickaxe); - if (!MaterialCollections.getAllUnbreakableBlocks().contains(block.getType()) && !drops.isEmpty()) { + if (!SlimefunTag.UNBREAKABLE_MATERIALS.isTagged(block.getType()) && !drops.isEmpty()) { OfflinePlayer owner = Bukkit.getOfflinePlayer(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner"))); if (SlimefunPlugin.getProtectionManager().hasPermission(owner, block.getLocation(), ProtectableAction.BREAK_BLOCK)) { @@ -71,7 +71,7 @@ public class MinerAndroid extends ProgrammableAndroid { protected void moveAndDig(Block b, BlockMenu menu, BlockFace face, Block block) { Collection drops = block.getDrops(effectivePickaxe); - if (!MaterialCollections.getAllUnbreakableBlocks().contains(block.getType()) && !drops.isEmpty()) { + if (!SlimefunTag.UNBREAKABLE_MATERIALS.isTagged(block.getType()) && !drops.isEmpty()) { OfflinePlayer owner = Bukkit.getOfflinePlayer(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner"))); if (SlimefunPlugin.getProtectionManager().hasPermission(owner, block.getLocation(), ProtectableAction.BREAK_BLOCK)) { 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 b3bffe225..8d7ca6977 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 @@ -18,7 +18,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; -import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; @@ -49,7 +48,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; */ public class BlockPlacer extends SlimefunItem { - private final ItemSetting> blacklist = new ItemSetting<>("unplaceable-blocks", MaterialCollections.getAllUnbreakableBlocks().stream().map(Material::name).collect(Collectors.toList())); + private final ItemSetting> blacklist = new ItemSetting<>("unplaceable-blocks", SlimefunTag.UNBREAKABLE_MATERIALS.stream().map(Material::name).collect(Collectors.toList())); public BlockPlacer(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/blocks/Crucible.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java index b7e490b6a..c08a104e3 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 @@ -14,13 +14,13 @@ import org.bukkit.block.data.Waterlogged; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -65,7 +65,7 @@ public class Crucible extends SimpleSlimefunItem implements Rec items.add(new ItemStack(Material.WATER_BUCKET)); } - for (Material sapling : MaterialCollections.getAllTerracottaColors()) { + for (Material sapling : SlimefunTag.TERRACOTTA.getValues()) { items.add(new ItemStack(sapling, 12)); items.add(new ItemStack(Material.LAVA_BUCKET)); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java index c61c67a5f..ef089e4f5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java @@ -13,7 +13,6 @@ import org.bukkit.event.block.BlockExplodeEvent; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; -import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; @@ -21,6 +20,7 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler; @@ -113,7 +113,7 @@ class ExplosiveTool extends SimpleSlimefunItem implements NotPla if (b.isEmpty() || b.isLiquid()) { return false; } - else if (MaterialCollections.getAllUnbreakableBlocks().contains(b.getType())) { + else if (SlimefunTag.UNBREAKABLE_MATERIALS.isTagged(b.getType())) { return false; } else if (!b.getWorld().getWorldBorder().isInside(b.getLocation())) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java index c845478e0..fd5f4c333 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java @@ -49,6 +49,11 @@ public enum SlimefunTag implements Tag { */ SHULKER_BOXES, + /** + * All command block variants + */ + COMMAND_BLOCKS, + /** * Every mushroom type, red, brown and nether ones. */ @@ -103,6 +108,11 @@ public enum SlimefunTag implements Tag { */ SENSITIVE_MATERIALS, + /** + * These materials are just unbreakable, like bedrock for example. + */ + UNBREAKABLE_MATERIALS, + /** * Materials which cannot be reliably placed using a {@link BlockPlacer}. */ diff --git a/src/main/resources/tags/command_blocks.json b/src/main/resources/tags/command_blocks.json new file mode 100644 index 000000000..a2485a233 --- /dev/null +++ b/src/main/resources/tags/command_blocks.json @@ -0,0 +1,7 @@ +{ + "values" : [ + "minecraft:command_block", + "minecraft:chain_command_block", + "minecraft:repeating_command_block" + ] +} diff --git a/src/main/resources/tags/unbreakable_materials.json b/src/main/resources/tags/unbreakable_materials.json new file mode 100644 index 000000000..3617900c9 --- /dev/null +++ b/src/main/resources/tags/unbreakable_materials.json @@ -0,0 +1,13 @@ +{ + "values" : [ + "#slimefun:command_blocks", + "minecraft:bedrock", + "minecraft:barrier", + "minecraft:nether_portal", + "minecraft:end_portal", + "minecraft:end_portal_frame", + "minecraft:end_gateway", + "minecraft:structure_block", + "minecraft:structure_void" + ] +} From a98ff148e69fce66021d33f2ce8990cf33bf465d Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 13 Sep 2020 12:06:43 +0200 Subject: [PATCH 016/178] Jigsaw! --- src/main/resources/tags/unbreakable_materials.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/resources/tags/unbreakable_materials.json b/src/main/resources/tags/unbreakable_materials.json index 3617900c9..baefaf9a9 100644 --- a/src/main/resources/tags/unbreakable_materials.json +++ b/src/main/resources/tags/unbreakable_materials.json @@ -8,6 +8,10 @@ "minecraft:end_portal_frame", "minecraft:end_gateway", "minecraft:structure_block", - "minecraft:structure_void" + "minecraft:structure_void", + { + "id" : "minecraft:jigsaw", + "required" : false + } ] } From 23bf314905a6b30236de92ed3106500fb9dd6ad7 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 19 Sep 2020 11:39:35 +0200 Subject: [PATCH 017/178] Added fluid-sensitive tag --- .../implementation/listeners/BlockPhysicsListener.java | 10 +++------- .../slimefun4/utils/tags/SlimefunTag.java | 7 +++++++ src/main/resources/tags/fluid_sensitive_materials.json | 7 +++++++ 3 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 src/main/resources/tags/fluid_sensitive_materials.json 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..ff55b6065 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 @@ -4,7 +4,6 @@ import javax.annotation.Nonnull; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.Tag; import org.bukkit.block.Block; import org.bukkit.block.data.type.Piston; import org.bukkit.entity.EntityType; @@ -21,6 +20,7 @@ import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.api.BlockStorage; /** @@ -78,12 +78,8 @@ public class BlockPhysicsListener implements Listener { public void onLiquidFlow(BlockFromToEvent e) { Block block = e.getToBlock(); - if (block.getType() == Material.PLAYER_HEAD || block.getType() == Material.PLAYER_WALL_HEAD || Tag.SAPLINGS.isTagged(block.getType())) { - String item = BlockStorage.checkID(block); - - if (item != null) { - e.setCancelled(true); - } + if (SlimefunTag.FLUID_SENSITIVE_MATERIALS.isTagged(block.getType()) && BlockStorage.hasBlockInfo(block)) { + e.setCancelled(true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java index fd5f4c333..86f89cc03 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java @@ -15,6 +15,7 @@ import org.apache.commons.lang.Validate; import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.Tag; +import org.bukkit.block.data.Waterlogged; import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; @@ -108,6 +109,12 @@ public enum SlimefunTag implements Tag { */ SENSITIVE_MATERIALS, + /** + * These Materials are sensitive to fluids, they cannot be {@link Waterlogged} + * and would break in contact with water. + */ + FLUID_SENSITIVE_MATERIALS, + /** * These materials are just unbreakable, like bedrock for example. */ diff --git a/src/main/resources/tags/fluid_sensitive_materials.json b/src/main/resources/tags/fluid_sensitive_materials.json new file mode 100644 index 000000000..75524f258 --- /dev/null +++ b/src/main/resources/tags/fluid_sensitive_materials.json @@ -0,0 +1,7 @@ +{ + "values" : [ + "#minecraft:saplings", + "minecraft:player_head", + "minecraft:player_wall_head" + ] +} From 428c8b4774f0cca7690db0810b502e8a93541c52 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Tue, 22 Sep 2020 15:46:06 +0200 Subject: [PATCH 018/178] Added back tall_flowers tag --- .../github/thebusybiscuit/slimefun4/testing/TestUtilities.java | 3 ++- 1 file changed, 2 insertions(+), 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 0440b4ddd..00106be91 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java @@ -133,5 +133,6 @@ public final class TestUtilities { server.createMaterialTag(NamespacedKey.minecraft("beds"), Material.RED_BED, Material.BLUE_BED); server.createMaterialTag(NamespacedKey.minecraft("fishes"), Material.COD, Material.SALMON); server.createMaterialTag(NamespacedKey.minecraft("doors"), Material.OAK_DOOR, Material.IRON_DOOR); + server.createMaterialTag(NamespacedKey.minecraft("tall_flowers"), Material.PEONY, Material.SUNFLOWER); } -} \ No newline at end of file +} From 14b96aae5b754637714c29d62afd194c89211757 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Tue, 22 Sep 2020 15:51:08 +0200 Subject: [PATCH 019/178] Added back dirt_like tag --- .../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 00106be91..be77492cb 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java @@ -127,6 +127,7 @@ public final class TestUtilities { server.createMaterialTag(NamespacedKey.minecraft("crops"), Material.WHEAT, Material.CARROTS, Material.POTATOES, Material.BEETROOTS ); + server.createMaterialTag(NamespacedKey.minecraft("dirt_like"), Material.DIRT, Material.PODZOL, Material.MYCELIUM); server.createMaterialTag(NamespacedKey.minecraft("fire"), Material.FIRE, Material.SOUL_FIRE); server.createMaterialTag(NamespacedKey.minecraft("gold_ores"), Material.GOLD_ORE); server.createMaterialTag(NamespacedKey.minecraft("sand"), Material.SAND, Material.RED_SAND); From 4f233a631af306ea9fb76315afaceafb30684dd5 Mon Sep 17 00:00:00 2001 From: LinoxGH Date: Sat, 3 Oct 2020 21:45:32 +0300 Subject: [PATCH 020/178] Added Energy Connector. --- .../core/attributes/EnergyNetComponent.java | 2 + .../core/networks/energy/EnergyNet.java | 16 +++++ .../energy/EnergyNetComponentType.java | 8 +++ .../implementation/SlimefunItems.java | 1 + .../items/cargo/CargoConnectorNode.java | 5 ++ .../items/electric/EnergyConnector.java | 63 +++++++++++++++++++ .../implementation/setup/ResearchSetup.java | 11 +++- .../setup/SlimefunItemSetup.java | 6 ++ 8 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyConnector.java diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java index 91262da84..cae9ac31e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java @@ -66,6 +66,8 @@ public interface EnergyNetComponent extends ItemAttribute { */ default int getCharge(@Nonnull Location l) { Validate.notNull(l, "Location was null!"); + if (!isChargeable()) return 0; + String charge = BlockStorage.getLocationInfo(l, "energy-charge"); if (charge != null) { 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 12127579b..f69fa4910 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 @@ -11,6 +11,7 @@ import java.util.function.LongConsumer; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import io.github.thebusybiscuit.slimefun4.core.networks.cargo.CargoNet; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -71,6 +72,7 @@ public class EnergyNet extends Network { } else { switch (component.getEnergyComponentType()) { + case CONNECTOR: case CAPACITOR: return NetworkComponent.CONNECTOR; case CONSUMER: @@ -283,6 +285,20 @@ public class EnergyNet extends Network { return null; } + /** + * This attempts to get an {@link EnergyNet} from a given {@link Location}. + * If no suitable {@link EnergyNet} could be found, {@code null} will be returned. + * + * @param l + * The target {@link Location} + * + * @return The {@link EnergyNet} at that {@link Location}, or {@code null} + */ + @Nullable + public static EnergyNet getNetworkFromLocation(@Nonnull Location l) { + return SlimefunPlugin.getNetworkManager().getNetworkFromLocation(l, EnergyNet.class).orElse(null); + } + /** * This attempts to get an {@link EnergyNet} from a given {@link Location}. * If no suitable {@link EnergyNet} could be found, a new one will be created. diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNetComponentType.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNetComponentType.java index fe62f19ad..ef05a8466 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNetComponentType.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNetComponentType.java @@ -4,6 +4,7 @@ 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.implementation.items.electric.EnergyConnector; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; @@ -13,6 +14,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; * can have. * * @author TheBusyBiscuit + * @author Linox * * @see EnergyNetComponent * @see EnergyNet @@ -38,6 +40,12 @@ public enum EnergyNetComponentType { */ CONSUMER, + /** + * A Connector transmits energy through the network. + * Also see: {@link EnergyConnector} + */ + CONNECTOR, + /** * A fallback value to use when a {@link Block} cannot be classified as any of the * other options. 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..5f3d272bd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -749,6 +749,7 @@ public final class SlimefunItems { public static final SlimefunItemStack BLISTERING_INGOT_3 = new SlimefunItemStack("BLISTERING_INGOT_3", Material.GOLD_INGOT, "&6Blistering Ingot", "", LoreBuilder.radioactive(Radioactivity.VERY_HIGH), LoreBuilder.HAZMAT_SUIT_REQUIRED); public static final SlimefunItemStack ENERGY_REGULATOR = new SlimefunItemStack("ENERGY_REGULATOR", HeadTexture.ENERGY_REGULATOR, "&6Energy Regulator", "", "&fCore Component of an Energy Network"); + public static final SlimefunItemStack ENERGY_CONNECTOR = new SlimefunItemStack("ENERGY_CONNECTOR", HeadTexture.CARGO_CONNECTOR_NODE, "&cEnergy Connector", "", "&fCargo Connector Wire"); public static final SlimefunItemStack DEBUG_FISH = new SlimefunItemStack("DEBUG_FISH", Material.SALMON, "&3How much is the Fish?", "", "&eRight Click &fany Block to view it's BlockData", "&eLeft Click &fto break a Block", "&eShift + Left Click &fany Block to erase it's BlockData", "&eShift + Right Click &fto place a Placeholder Block"); public static final SlimefunItemStack NETHER_ICE = new SlimefunItemStack("NETHER_ICE", HeadTexture.NETHER_ICE, "&eNether Ice", "", LoreBuilder.radioactive(Radioactivity.MODERATE), LoreBuilder.HAZMAT_SUIT_REQUIRED); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java index 13f46f541..48d0e2a75 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java @@ -12,15 +12,20 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; +import javax.annotation.Nonnull; + public class CargoConnectorNode extends SimpleSlimefunItem { public CargoConnectorNode(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { super(category, item, recipeType, recipe, recipeOutput); } + @Nonnull @Override public BlockUseHandler getItemHandler() { return e -> { + if (!e.getClickedBlock().isPresent()) return; + Player p = e.getPlayer(); Block b = e.getClickedBlock().get(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyConnector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyConnector.java new file mode 100644 index 000000000..3238260f4 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyConnector.java @@ -0,0 +1,63 @@ +package io.github.thebusybiscuit.slimefun4.implementation.items.electric; + +import javax.annotation.Nonnull; + +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import io.github.thebusybiscuit.cscorelib2.chat.ChatColors; +import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; +import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; +import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet; +import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; +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.SlimefunItemStack; + +/** + * This {@link EnergyNetComponent} is a connector for the {@link EnergyNet} networks. + * They work similar to {@link Capacitor capacitors}. + * + * @author Linox + * + * @see EnergyNet + * @see EnergyNetComponent + * + */ +public class EnergyConnector extends SimpleSlimefunItem implements EnergyNetComponent { + + public EnergyConnector(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { + super(category, item, recipeType, recipe, recipeOutput); + } + + @Nonnull + @Override + public BlockUseHandler getItemHandler() { + return e -> { + if (!e.getClickedBlock().isPresent()) return; + + Player p = e.getPlayer(); + Block b = e.getClickedBlock().get(); + + if (EnergyNet.getNetworkFromLocation(b.getLocation()) != null) { + p.sendMessage(ChatColors.color("&7Connected: " + "&2\u2714")); + } + else { + p.sendMessage(ChatColors.color("&7Connected: " + "&4\u2718")); + } + }; + } + + @Nonnull + @Override + public EnergyNetComponentType getEnergyComponentType() { + return EnergyNetComponentType.CONNECTOR; + } + + @Override + public int getCapacity() { + return 0; + } +} 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..be4bcf307 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 @@ -1,5 +1,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.setup; +import javax.annotation.Nonnull; + import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.inventory.ItemStack; @@ -14,8 +16,10 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; * {@link Research} on startup. * * @author TheBusyBiscuit + * @author Every Slimefun4 Contributor (at least those who added an item...) * * @see Research + * @see SlimefunItems * */ public final class ResearchSetup { @@ -275,10 +279,13 @@ 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("energy_connectors", 267, "Wired Connections", 12, SlimefunItems.ENERGY_CONNECTOR); } - private static void register(String key, int id, String name, int defaultCost, ItemStack... items) { - Research research = new Research(new NamespacedKey(SlimefunPlugin.instance(), key), id, name, defaultCost); + private static void register(@Nonnull String key, int id, @Nonnull String name, int defaultCost, @Nonnull ItemStack... items) { + SlimefunPlugin plugin = SlimefunPlugin.instance(); + if (plugin == null) return; + Research research = new Research(new NamespacedKey(plugin, key), id, name, defaultCost); for (ItemStack item : items) { SlimefunItem sfItem = SlimefunItem.getByItem(item); 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..17a983306 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 @@ -63,6 +63,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoOutput import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.ReactorAccessPort; import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.TrashCan; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.Capacitor; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.EnergyConnector; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.EnergyRegulator; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.JetBoots; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.Jetpack; @@ -1499,6 +1500,11 @@ public final class SlimefunItemSetup { new ItemStack[] {SlimefunItems.SILVER_INGOT, SlimefunItems.DAMASCUS_STEEL_INGOT, SlimefunItems.SILVER_INGOT, SlimefunItems.DAMASCUS_STEEL_INGOT, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.DAMASCUS_STEEL_INGOT, SlimefunItems.SILVER_INGOT, SlimefunItems.DAMASCUS_STEEL_INGOT, SlimefunItems.SILVER_INGOT}) .register(plugin); + new EnergyConnector(categories.electricity, SlimefunItems.ENERGY_CONNECTOR, RecipeType.ENHANCED_CRAFTING_TABLE, + new ItemStack[] {SlimefunItems.CARBON, SlimefunItems.CARBON, SlimefunItems.CARBON, SlimefunItems.CARBON, SlimefunItems.COPPER_INGOT, SlimefunItems.CARBON, SlimefunItems.CARBON, SlimefunItems.CARBON, SlimefunItems.CARBON}, + new SlimefunItemStack(SlimefunItems.ENERGY_CONNECTOR, 8)) + .register(plugin); + new SlimefunItem(categories.misc, SlimefunItems.DUCT_TAPE, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] {SlimefunItems.ALUMINUM_DUST, SlimefunItems.ALUMINUM_DUST, SlimefunItems.ALUMINUM_DUST, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.PAPER), new ItemStack(Material.PAPER), new ItemStack(Material.PAPER)}, new SlimefunItemStack(SlimefunItems.DUCT_TAPE, 2)) From f6492e74fba04cfc326c9266c926eba881d8f726 Mon Sep 17 00:00:00 2001 From: LinoxGH Date: Sat, 3 Oct 2020 21:48:36 +0300 Subject: [PATCH 021/178] Added the research to language files. --- 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..2de333b38 100644 --- a/src/main/resources/languages/researches_en.yml +++ b/src/main/resources/languages/researches_en.yml @@ -168,6 +168,7 @@ slimefun: energized_solar_generator: Full-Time Solar Power energized_gps_transmitter: Top Tier Transmitter energy_regulator: Energy Networks 101 + energy_connectors: Wired Connections butcher_androids: Butcher Androids organic_food: Organic Food auto_breeder: Automated Feeding From d782470945b57aac85a51f84c9f5bd68d43a5bc5 Mon Sep 17 00:00:00 2001 From: LinoxGH Date: Sat, 3 Oct 2020 21:59:59 +0300 Subject: [PATCH 022/178] Fixed a couple issues. --- .../slimefun4/core/networks/energy/EnergyNet.java | 1 - .../implementation/items/cargo/CargoConnectorNode.java | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) 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 f69fa4910..e6489ff3a 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 @@ -11,7 +11,6 @@ import java.util.function.LongConsumer; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import io.github.thebusybiscuit.slimefun4.core.networks.cargo.CargoNet; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java index 48d0e2a75..5fd8dd3c6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java @@ -1,5 +1,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.cargo; +import javax.annotation.Nonnull; + import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -12,8 +14,6 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; -import javax.annotation.Nonnull; - public class CargoConnectorNode extends SimpleSlimefunItem { public CargoConnectorNode(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { From e1a8c6f52e9f1cd3755a4039f0b9b0c938e2d94a Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 3 Oct 2020 22:21:01 +0200 Subject: [PATCH 023/178] Added caveman talisman tag --- .../implementation/items/tools/ClimbingPick.java | 3 +-- .../implementation/listeners/TalismanListener.java | 3 ++- .../thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java | 7 ++++++- src/main/resources/tags/caveman_talisman_triggers.json | 9 +++++++++ 4 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 src/main/resources/tags/caveman_talisman_triggers.json 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 9a6e23676..7730f1375 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 @@ -54,7 +54,7 @@ public class ClimbingPick extends SimpleSlimefunItem implements private final ItemSetting dualWielding = new ItemSetting<>("dual-wielding", true); private final ItemSetting damageOnUse = new ItemSetting<>("damage-on-use", true); - private final Map materialSpeeds; + private final Map materialSpeeds = new EnumMap<>(Material.class); private final Set users = new HashSet<>(); @ParametersAreNonnullByDefault @@ -64,7 +64,6 @@ public class ClimbingPick extends SimpleSlimefunItem implements String cfgKey = getID() + ".launch-amounts."; Config itemCfg = SlimefunPlugin.getItemCfg(); - materialSpeeds = new EnumMap<>(Material.class); for (Material mat : MaterialCollections.getAllIceBlocks()) { materialSpeeds.put(mat, itemCfg.getOrSetDefault(cfgKey + mat.name(), 1.0)); 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 abcfcca3d..a75025e03 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 @@ -46,6 +46,7 @@ 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 io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; public class TalismanListener implements Listener { @@ -287,7 +288,7 @@ public class TalismanListener implements Listener { @EventHandler public void onBlockBreak(BlockBreakEvent e) { - if (e.getBlock().getType().name().endsWith("_ORE")) { + if (SlimefunTag.CAVEMAN_TALISMAN_TRIGGERS.isTagged(e.getBlock().getType())) { Talisman.checkFor(e, SlimefunItems.TALISMAN_CAVEMAN); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java index 86f89cc03..c83560031 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java @@ -158,7 +158,12 @@ public enum SlimefunTag implements Tag { /** * All materials which the {@link ClimbingPick} is able to climb. */ - CLIMBING_PICK_SURFACES; + CLIMBING_PICK_SURFACES, + + /** + * All materials (ores) which trigger the Talisman of the Caveman. + */ + CAVEMAN_TALISMAN_TRIGGERS; private static final Map nameLookup = new HashMap<>(); public static final SlimefunTag[] values = values(); diff --git a/src/main/resources/tags/caveman_talisman_triggers.json b/src/main/resources/tags/caveman_talisman_triggers.json new file mode 100644 index 000000000..901df5bb8 --- /dev/null +++ b/src/main/resources/tags/caveman_talisman_triggers.json @@ -0,0 +1,9 @@ +{ + "values" : [ + "#slimefun:ores", + { + "id" : "minecraft:ancient_debris", + "required" : false + } + ] +} From 8bbdc37130fc5f7454f807788da6eb651e71a9f9 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 4 Oct 2020 02:28:59 +0200 Subject: [PATCH 024/178] Refactored Climbing Picks and added Tags --- .../items/tools/ClimbableSurface.java | 51 ++++++++++++ .../items/tools/ClimbingPick.java | 80 +++++++++++-------- .../implementation/items/tools/GoldPan.java | 23 +++++- .../items/tools/NetherGoldPan.java | 2 +- .../slimefun4/utils/tags/SlimefunTag.java | 9 ++- ...son => climbing_pick_strong_surfaces.json} | 3 - .../tags/climbing_pick_weak_surfaces.json | 7 ++ 7 files changed, 134 insertions(+), 41 deletions(-) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbableSurface.java rename src/main/resources/tags/{climbing_pick_surfaces.json => climbing_pick_strong_surfaces.json} (77%) create mode 100644 src/main/resources/tags/climbing_pick_weak_surfaces.json diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbableSurface.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbableSurface.java new file mode 100644 index 000000000..cf3ed08a4 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbableSurface.java @@ -0,0 +1,51 @@ +package io.github.thebusybiscuit.slimefun4.implementation.items.tools; + +import javax.annotation.Nonnull; + +import org.bukkit.Material; + +import io.github.thebusybiscuit.slimefun4.api.events.ClimbingPickLaunchEvent; +import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; + +/** + * This is an {@link ItemSetting} + * + * @author TheBusyBiscuit + * + * @see ClimbingPick + * @see ClimbingPickLaunchEvent + * + */ +public class ClimbableSurface extends ItemSetting { + + private final Material type; + + /** + * This creates a new {@link ClimbableSurface} for the given {@link Material}. + * + * @param surface + * The {@link Material} of this surface + * @param defaultValue + * The default launch amount + */ + public ClimbableSurface(@Nonnull Material surface, double defaultValue) { + super("launch-amounts." + surface.name(), defaultValue); + this.type = surface; + } + + @Override + public boolean validateInput(Double input) { + return super.validateInput(input) && input >= 0; + } + + /** + * This returns the {@link Material} of this surface. + * + * @return The {@link Material} of this surface + */ + @Nonnull + public Material getType() { + return type; + } + +} \ No newline at end of file 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 7730f1375..90368972a 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 @@ -1,6 +1,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.tools; import java.util.ArrayList; +import java.util.Collection; import java.util.EnumMap; import java.util.HashSet; import java.util.List; @@ -24,8 +25,6 @@ import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; -import io.github.thebusybiscuit.cscorelib2.config.Config; -import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; import io.github.thebusybiscuit.slimefun4.api.events.ClimbingPickLaunchEvent; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; @@ -34,6 +33,7 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; @@ -49,52 +49,68 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; */ public class ClimbingPick extends SimpleSlimefunItem implements DamageableItem, RecipeDisplayItem { - private static final double BASE_POWER = 1; private static final double MAX_DISTANCE = 4.4; + private static final double STRONG_SURFACE_DEFAULT = 1.0; + private static final double WEAK_SURFACE_DEFAULT = 0.6; + private static final long COOLDOWN = 4; private final ItemSetting dualWielding = new ItemSetting<>("dual-wielding", true); private final ItemSetting damageOnUse = new ItemSetting<>("damage-on-use", true); - private final Map materialSpeeds = new EnumMap<>(Material.class); + private final Map surfaces = new EnumMap<>(Material.class); 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); + addDefaultSurfaces(); + } - String cfgKey = getID() + ".launch-amounts."; - Config itemCfg = SlimefunPlugin.getItemCfg(); - - for (Material mat : MaterialCollections.getAllIceBlocks()) { - materialSpeeds.put(mat, itemCfg.getOrSetDefault(cfgKey + mat.name(), 1.0)); + protected void addDefaultSurfaces() { + // These are "strong" surfaces, they will give you the biggest boost + for (Material surface : SlimefunTag.CLIMBING_PICK_STRONG_SURFACES.getValues()) { + addSurface(surface, STRONG_SURFACE_DEFAULT); } - for (Material mat : MaterialCollections.getAllConcretePowderColors()) { - materialSpeeds.put(mat, itemCfg.getOrSetDefault(cfgKey + mat.name(), 1.0)); - } - - for (Material mat : MaterialCollections.getAllTerracottaColors()) { - materialSpeeds.put(mat, itemCfg.getOrSetDefault(cfgKey + mat.name(), 1.0)); - } - - materialSpeeds.put(Material.GRAVEL, itemCfg.getOrSetDefault(cfgKey + Material.GRAVEL.name(), 0.4)); - materialSpeeds.put(Material.SAND, itemCfg.getOrSetDefault(cfgKey + Material.SAND.name(), 0.4)); - materialSpeeds.put(Material.STONE, itemCfg.getOrSetDefault(cfgKey + Material.STONE.name(), 0.6)); - materialSpeeds.put(Material.DIORITE, itemCfg.getOrSetDefault(cfgKey + Material.DIORITE.name(), 0.6)); - materialSpeeds.put(Material.GRANITE, itemCfg.getOrSetDefault(cfgKey + Material.GRANITE.name(), 0.6)); - materialSpeeds.put(Material.ANDESITE, itemCfg.getOrSetDefault(cfgKey + Material.ANDESITE.name(), 0.6)); - materialSpeeds.put(Material.NETHERRACK, itemCfg.getOrSetDefault(cfgKey + Material.NETHERRACK.name(), 0.6)); - - if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) { - materialSpeeds.put(Material.BLACKSTONE, itemCfg.getOrSetDefault(cfgKey + Material.BLACKSTONE.name(), 0.6)); - materialSpeeds.put(Material.BASALT, itemCfg.getOrSetDefault(cfgKey + Material.BASALT.name(), 0.7)); + // These are "weak" surfaces, you can still climb them but they don't have + // such a high boost as the "strong" surfaces + for (Material surface : SlimefunTag.CLIMBING_PICK_WEAK_SURFACES.getValues()) { + addSurface(surface, WEAK_SURFACE_DEFAULT); } } + protected void addSurface(@Nonnull Material type, double defaultValue) { + ClimbableSurface surface = new ClimbableSurface(type, defaultValue); + addItemSetting(surface); + surfaces.put(type, surface); + } + + /** + * This returns whether the {@link ClimbingPick} needs to be held in both + * arms to work. + * + * @return Whether dual wielding is enabled + */ public boolean isDualWieldingEnabled() { return dualWielding.getValue(); } + /** + * This method returns a {@link Collection} of every {@link ClimbableSurface} the + * {@link ClimbingPick} can climb. + * + * @return A {@link Collection} of every {@link ClimbableSurface} + */ + @Nonnull + public Collection getClimbableSurfaces() { + return surfaces.values(); + } + + private double getClimbingSpeed(@Nonnull Material type) { + ClimbableSurface surface = surfaces.get(type); + return surface != null ? surface.getValue() : 0; + } + @Override public ItemUseHandler getItemHandler() { return e -> { @@ -138,7 +154,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); + double power = getClimbingSpeed(block.getType()); if (power > 0.05) { // Prevent players from spamming this @@ -149,8 +165,8 @@ public class ClimbingPick extends SimpleSlimefunItem implements power += efficiencyLevel * 0.1; } - SlimefunPlugin.runSync(() -> users.remove(p.getUniqueId()), 4L); - Vector velocity = new Vector(0, power * BASE_POWER, 0); + SlimefunPlugin.runSync(() -> users.remove(p.getUniqueId()), COOLDOWN); + Vector velocity = new Vector(0, power, 0); ClimbingPickLaunchEvent event = new ClimbingPickLaunchEvent(p, velocity, this, item, block); Bukkit.getPluginManager().callEvent(event); @@ -219,7 +235,7 @@ public class ClimbingPick extends SimpleSlimefunItem implements public List getDisplayRecipes() { List display = new ArrayList<>(); - for (Material mat : materialSpeeds.keySet()) { + for (Material mat : surfaces.keySet()) { display.add(new ItemStack(mat)); } 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 0c7101673..aba6e1374 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 @@ -6,6 +6,9 @@ import java.util.List; import java.util.Optional; import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.block.Block; @@ -43,6 +46,7 @@ public class GoldPan extends SimpleSlimefunItem implements Recip private final RandomizedSet randomizer = new RandomizedSet<>(); private final Set drops = new HashSet<>(); + @ParametersAreNonnullByDefault public GoldPan(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); @@ -51,7 +55,13 @@ public class GoldPan extends SimpleSlimefunItem implements Recip addItemHandler(onEntityInteract()); } - protected Material getInput() { + /** + * This method returns the target {@link Material} for this {@link GoldPan}. + * + * @return The {@link Material} this {@link GoldPan} can be used on + */ + @Nonnull + protected Material getTargetMaterial() { return Material.GRAVEL; } @@ -84,6 +94,13 @@ public class GoldPan extends SimpleSlimefunItem implements Recip } } + /** + * This returns a random output {@link ItemStack} that can be obtained via + * this {@link GoldPan}. + * + * @return a random {@link ItemStack} obtained by this {@link GoldPan} + */ + @Nonnull public ItemStack getRandomOutput() { return randomizer.getRandom(); } @@ -101,7 +118,7 @@ public class GoldPan extends SimpleSlimefunItem implements Recip if (block.isPresent()) { Block b = block.get(); - if (b.getType() == getInput() && SlimefunPlugin.getProtectionManager().hasPermission(e.getPlayer(), b.getLocation(), ProtectableAction.BREAK_BLOCK)) { + if (b.getType() == getTargetMaterial() && SlimefunPlugin.getProtectionManager().hasPermission(e.getPlayer(), b.getLocation(), ProtectableAction.BREAK_BLOCK)) { ItemStack output = getRandomOutput(); b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType()); @@ -133,7 +150,7 @@ public class GoldPan extends SimpleSlimefunItem implements Recip for (GoldPanDrop drop : drops) { if (drop.getValue() > 0) { - recipes.add(new ItemStack(getInput())); + recipes.add(new ItemStack(getTargetMaterial())); recipes.add(drop.getOutput()); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/NetherGoldPan.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/NetherGoldPan.java index f7c4500b7..300b5a0cd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/NetherGoldPan.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/NetherGoldPan.java @@ -17,7 +17,7 @@ public class NetherGoldPan extends GoldPan { } @Override - protected Material getInput() { + protected Material getTargetMaterial() { return Material.SOUL_SAND; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java index c83560031..d5218059c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java @@ -156,9 +156,14 @@ public enum SlimefunTag implements Tag { CROP_GROWTH_ACCELERATOR_BLOCKS, /** - * All materials which the {@link ClimbingPick} is able to climb. + * All strong materials which the {@link ClimbingPick} is able to climb. */ - CLIMBING_PICK_SURFACES, + CLIMBING_PICK_STRONG_SURFACES, + + /** + * All weak materials which the {@link ClimbingPick} is able to climb. + */ + CLIMBING_PICK_WEAK_SURFACES, /** * All materials (ores) which trigger the Talisman of the Caveman. diff --git a/src/main/resources/tags/climbing_pick_surfaces.json b/src/main/resources/tags/climbing_pick_strong_surfaces.json similarity index 77% rename from src/main/resources/tags/climbing_pick_surfaces.json rename to src/main/resources/tags/climbing_pick_strong_surfaces.json index c72bb4368..ca798a9bd 100644 --- a/src/main/resources/tags/climbing_pick_surfaces.json +++ b/src/main/resources/tags/climbing_pick_strong_surfaces.json @@ -1,11 +1,8 @@ { "values" : [ "#slimefun:ice_variants", - "#slimefun:concrete_powders", "#slimefun:terracotta", "#slimefun:stone_variants", - "#minecraft:sand", - "minecraft:gravel", "minecraft:netherrack", { "id" : "minecraft:blackstone", diff --git a/src/main/resources/tags/climbing_pick_weak_surfaces.json b/src/main/resources/tags/climbing_pick_weak_surfaces.json new file mode 100644 index 000000000..902bfac23 --- /dev/null +++ b/src/main/resources/tags/climbing_pick_weak_surfaces.json @@ -0,0 +1,7 @@ +{ + "values" : [ + "#slimefun:concrete_powders", + "#minecraft:sand", + "minecraft:gravel" + ] +} From 50777ac546fa495dace64adb5c77e3ef6393eb96 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 4 Oct 2020 02:55:11 +0200 Subject: [PATCH 025/178] A bit of code cleanup and docs --- .../items/tools/ClimbingPick.java | 18 +++++++++++++++--- .../tools/TestClimbingPick.java | 4 ++-- 2 files changed, 17 insertions(+), 5 deletions(-) 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 90368972a..ac0aa93d7 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 @@ -52,6 +52,7 @@ public class ClimbingPick extends SimpleSlimefunItem implements private static final double MAX_DISTANCE = 4.4; private static final double STRONG_SURFACE_DEFAULT = 1.0; private static final double WEAK_SURFACE_DEFAULT = 0.6; + private static final double EFFICIENCY_MODIFIER = 0.125; private static final long COOLDOWN = 4; private final ItemSetting dualWielding = new ItemSetting<>("dual-wielding", true); @@ -66,6 +67,9 @@ public class ClimbingPick extends SimpleSlimefunItem implements addDefaultSurfaces(); } + /** + * This method adds every surface that is climbable by default. + */ protected void addDefaultSurfaces() { // These are "strong" surfaces, they will give you the biggest boost for (Material surface : SlimefunTag.CLIMBING_PICK_STRONG_SURFACES.getValues()) { @@ -106,6 +110,14 @@ public class ClimbingPick extends SimpleSlimefunItem implements return surfaces.values(); } + /** + * This returns the climbing speed for a given {@link Material}. + * + * @param type + * The {@link Material} + * + * @return The climbing speed for this {@link Material} or 0. + */ private double getClimbingSpeed(@Nonnull Material type) { ClimbableSurface surface = surfaces.get(type); return surface != null ? surface.getValue() : 0; @@ -121,7 +133,7 @@ public class ClimbingPick extends SimpleSlimefunItem implements Block block = e.getClickedBlock().get(); Player p = e.getPlayer(); - // Check if the Player is standing close to the wall + // Check if the Player is standing close enough to the wall if (p.getLocation().distanceSquared(block.getLocation().add(0.5, 0.5, 0.5)) > MAX_DISTANCE) { return; } @@ -161,8 +173,8 @@ public class ClimbingPick extends SimpleSlimefunItem implements if (users.add(p.getUniqueId())) { int efficiencyLevel = item.getEnchantmentLevel(Enchantment.DIG_SPEED); - if (efficiencyLevel != 0) { - power += efficiencyLevel * 0.1; + if (efficiencyLevel > 0) { + power += efficiencyLevel * EFFICIENCY_MODIFIER; } SlimefunPlugin.runSync(() -> users.remove(p.getUniqueId()), COOLDOWN); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java index 4acbc0474..c5bf82f09 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java @@ -68,8 +68,8 @@ class TestClimbingPick implements SlimefunItemTest { boolean shouldFireEvent = face != BlockFace.DOWN && face != BlockFace.UP; - BlockMock block1 = new BlockMock(Material.ICE, blockLocation); - simulateRightClickBlock(player, pick, block1, face); + BlockMock block = new BlockMock(Material.ICE, blockLocation); + simulateRightClickBlock(player, pick, block, face); if (shouldFireEvent) { server.getPluginManager().assertEventFired(ClimbingPickLaunchEvent.class); From 38f891ca9897b4793a7e0556eab0f22938d3b959 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sun, 4 Oct 2020 09:01:24 +0300 Subject: [PATCH 026/178] Some code improvements. (at least that's what was meant to be done) --- .../slimefun4/implementation/setup/ResearchSetup.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 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 cc7e85901..56ef82b3a 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 @@ -24,6 +24,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; */ public final class ResearchSetup { + private static SlimefunPlugin plugin = null; private static boolean alreadyRan = false; private ResearchSetup() {} @@ -32,6 +33,11 @@ public final class ResearchSetup { if (alreadyRan) { throw new UnsupportedOperationException("Researches can only be registered once!"); } + + plugin = SlimefunPlugin.instance(); + if (plugin == null) { + throw new Exception("Plugin cannot be null!"); + } alreadyRan = true; @@ -281,11 +287,11 @@ public final class ResearchSetup { register("even_higher_tier_capacitors", 266, "Tier 3 Capacitors", 40, SlimefunItems.ENERGIZED_CAPACITOR); register("caveman_talisman", 267, "Talisman of the Caveman", 20, SlimefunItems.TALISMAN_CAVEMAN); register("energy_connectors", 268, "Wired Connections", 12, SlimefunItems.ENERGY_CONNECTOR); + + plugin = null; } private static void register(@Nonnull String key, int id, @Nonnull String name, int defaultCost, @Nonnull ItemStack... items) { - SlimefunPlugin plugin = SlimefunPlugin.instance(); - if (plugin == null) return; Research research = new Research(new NamespacedKey(plugin, key), id, name, defaultCost); for (ItemStack item : items) { From 7dffd8468762bd86d09ab0734ee61b69fcc2ba72 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sun, 4 Oct 2020 09:06:21 +0300 Subject: [PATCH 027/178] Update ResearchSetup.java --- .../slimefun4/implementation/setup/ResearchSetup.java | 2 +- 1 file 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 56ef82b3a..ddc279997 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 @@ -36,7 +36,7 @@ public final class ResearchSetup { plugin = SlimefunPlugin.instance(); if (plugin == null) { - throw new Exception("Plugin cannot be null!"); + throw new UnsupportedOperationException("Plugin cannot be null!"); } alreadyRan = true; From 4df4f6d4c924ee7932a6e23aec87894cbfe065ba Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 4 Oct 2020 11:04:35 +0200 Subject: [PATCH 028/178] More Climbing Pick unit tests which may give us better context? --- .../items/tools/ClimbingPick.java | 37 ++++++--- .../tools/TestClimbingPick.java | 83 ++++++++++++++++++- 2 files changed, 108 insertions(+), 12 deletions(-) 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 ac0aa93d7..486d698d3 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 @@ -13,6 +13,7 @@ import java.util.concurrent.ThreadLocalRandom; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.GameMode; @@ -49,9 +50,9 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; */ public class ClimbingPick extends SimpleSlimefunItem implements DamageableItem, RecipeDisplayItem { - private static final double MAX_DISTANCE = 4.4; private static final double STRONG_SURFACE_DEFAULT = 1.0; private static final double WEAK_SURFACE_DEFAULT = 0.6; + private static final double MAX_DISTANCE = 4.4; private static final double EFFICIENCY_MODIFIER = 0.125; private static final long COOLDOWN = 4; @@ -118,11 +119,33 @@ public class ClimbingPick extends SimpleSlimefunItem implements * * @return The climbing speed for this {@link Material} or 0. */ - private double getClimbingSpeed(@Nonnull Material type) { + public double getClimbingSpeed(@Nonnull Material type) { + Validate.notNull(type, "The surface cannot be null"); ClimbableSurface surface = surfaces.get(type); return surface != null ? surface.getValue() : 0; } + /** + * This returns the climbing speed for a given {@link Material} and the used {@link ItemStack}. + * + * @param item + * the {@link ClimbingPick}'s {@link ItemStack} + * @param type + * The {@link Material} + * + * @return The climbing speed or 0. + */ + public double getClimbingSpeed(@Nonnull ItemStack item, @Nonnull Material type) { + double speed = getClimbingSpeed(type); + int efficiencyLevel = item.getEnchantmentLevel(Enchantment.DIG_SPEED); + + if (efficiencyLevel > 0) { + speed += efficiencyLevel * EFFICIENCY_MODIFIER; + } + + return speed; + } + @Override public ItemUseHandler getItemHandler() { return e -> { @@ -166,17 +189,11 @@ public class ClimbingPick extends SimpleSlimefunItem implements @ParametersAreNonnullByDefault private void climb(Player p, EquipmentSlot hand, ItemStack item, Block block) { - double power = getClimbingSpeed(block.getType()); + double power = getClimbingSpeed(item, block.getType()); if (power > 0.05) { - // Prevent players from spamming this + // Prevent players from spamming this item by enforcing a cooldown if (users.add(p.getUniqueId())) { - int efficiencyLevel = item.getEnchantmentLevel(Enchantment.DIG_SPEED); - - if (efficiencyLevel > 0) { - power += efficiencyLevel * EFFICIENCY_MODIFIER; - } - SlimefunPlugin.runSync(() -> users.remove(p.getUniqueId()), COOLDOWN); Vector velocity = new Vector(0, power, 0); ClimbingPickLaunchEvent event = new ClimbingPickLaunchEvent(p, velocity, this, item, block); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java index c5bf82f09..19a5ac00e 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java @@ -1,30 +1,43 @@ package io.github.thebusybiscuit.slimefun4.testing.tests.items.implementations.tools; +import java.util.stream.Stream; + +import javax.annotation.Nonnull; + import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.BlockFace; +import org.bukkit.enchantments.Enchantment; 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.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.EnumSource; +import org.junit.jupiter.params.provider.MethodSource; import be.seeseemelk.mockbukkit.MockBukkit; import be.seeseemelk.mockbukkit.ServerMock; import be.seeseemelk.mockbukkit.block.BlockMock; import be.seeseemelk.mockbukkit.entity.PlayerMock; import io.github.thebusybiscuit.slimefun4.api.events.ClimbingPickLaunchEvent; +import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ClimbingPick; import io.github.thebusybiscuit.slimefun4.testing.TestUtilities; import io.github.thebusybiscuit.slimefun4.testing.interfaces.SlimefunItemTest; +import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; class TestClimbingPick implements SlimefunItemTest { + private static final double STRONG_SURFACE_DEFAULT = 1.0; + private static final double WEAK_SURFACE_DEFAULT = 0.6; + private static ServerMock server; private static SlimefunPlugin plugin; @@ -57,9 +70,51 @@ class TestClimbingPick implements SlimefunItemTest { return pick; } + @ParameterizedTest + @DisplayName("Test Climbing Pick on strong surfaces") + @MethodSource("getStrongSurfaces") + void testStrongSurfaces(Material surface) { + Assertions.assertFalse(SlimefunTag.CLIMBING_PICK_STRONG_SURFACES.getValues().isEmpty()); + ClimbingPick pick = registerSlimefunItem(plugin, "STRONG_CLIMBING_PICK_" + surface.name()); + double speed = pick.getClimbingSpeed(surface); + + Assertions.assertEquals(STRONG_SURFACE_DEFAULT, speed); + Assertions.assertEquals(1, pick.getClimbableSurfaces().stream().filter(s -> s.getType() == surface).count()); + } + + private static Stream getStrongSurfaces() throws TagMisconfigurationException { + SlimefunTag.CLIMBING_PICK_STRONG_SURFACES.reload(); + return SlimefunTag.CLIMBING_PICK_STRONG_SURFACES.getValues().stream().map(Arguments::of); + } + + @ParameterizedTest + @DisplayName("Test Climbing Pick on weak surfaces") + @MethodSource("getWeakSurfaces") + void testWeakSurfaces(Material surface) { + Assertions.assertFalse(SlimefunTag.CLIMBING_PICK_WEAK_SURFACES.getValues().isEmpty()); + ClimbingPick pick = registerSlimefunItem(plugin, "WEAK_CLIMBING_PICK_" + surface.name()); + double speed = pick.getClimbingSpeed(surface); + + Assertions.assertEquals(WEAK_SURFACE_DEFAULT, speed); + Assertions.assertEquals(1, pick.getClimbableSurfaces().stream().filter(s -> s.getType() == surface).count()); + } + + private static Stream getWeakSurfaces() throws TagMisconfigurationException { + SlimefunTag.CLIMBING_PICK_WEAK_SURFACES.reload(); + return SlimefunTag.CLIMBING_PICK_WEAK_SURFACES.getValues().stream().map(Arguments::of); + } + + @Test + @DisplayName("Test Climbing Pick on non-climbable surface") + void testNonClimbable() { + ClimbingPick pick = registerSlimefunItem(plugin, "NOT_CLIMBING_PICK"); + double speed = pick.getClimbingSpeed(Material.DRAGON_EGG); + Assertions.assertEquals(0, speed); + } + @ParameterizedTest @DisplayName("Test Climbing Pick on various Block Faces") - @EnumSource(value = BlockFace.class) + @EnumSource(value = BlockFace.class, names = { "UP", "DOWN", "NORTH", "EAST", "SOUTH", "WEST" }) void testItemUse(BlockFace face) { server.getPluginManager().clearEvents(); PlayerMock player = server.addPlayer(); @@ -72,11 +127,35 @@ class TestClimbingPick implements SlimefunItemTest { simulateRightClickBlock(player, pick, block, face); if (shouldFireEvent) { - server.getPluginManager().assertEventFired(ClimbingPickLaunchEvent.class); + Assertions.assertTrue(pick.getClimbingSpeed(block.getType()) > 0); Assertions.assertTrue(player.getVelocity().length() > 0); + server.getPluginManager().assertEventFired(ClimbingPickLaunchEvent.class); } else { Assertions.assertEquals(0, player.getVelocity().length()); } } + + @Test + @DisplayName("Test Climbing Pick Efficiency modifier") + void testEfficiency() { + Material surface = Material.ICE; + + ClimbingPick pick = registerSlimefunItem(plugin, "TEST_CLIMBING_PICK_EFFICIENCY"); + ItemStack efficiency0 = pick.getItem().clone(); + ItemStack efficiency1 = getPickWithEfficiency(pick, 1); + ItemStack efficiency2 = getPickWithEfficiency(pick, 2); + ItemStack efficiency3 = getPickWithEfficiency(pick, 3); + + Assertions.assertEquals(pick.getClimbingSpeed(surface), pick.getClimbingSpeed(efficiency0, surface)); + Assertions.assertTrue(pick.getClimbingSpeed(efficiency1, surface) > pick.getClimbingSpeed(efficiency0, surface)); + Assertions.assertTrue(pick.getClimbingSpeed(efficiency2, surface) > pick.getClimbingSpeed(efficiency1, surface)); + Assertions.assertTrue(pick.getClimbingSpeed(efficiency3, surface) > pick.getClimbingSpeed(efficiency2, surface)); + } + + private ItemStack getPickWithEfficiency(@Nonnull ClimbingPick pick, int level) { + ItemStack item = pick.getItem().clone(); + item.addUnsafeEnchantment(Enchantment.DIG_SPEED, level); + return item; + } } From 2ff105dabe76251f226ffe7d9aa7a0a6f9ab2a05 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 4 Oct 2020 11:22:56 +0200 Subject: [PATCH 029/178] Maybe fixed the unit tests? --- .../implementation/items/tools/ClimbingPick.java | 2 +- .../items/implementations/tools/TestClimbingPick.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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 486d698d3..a337be904 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 @@ -139,7 +139,7 @@ public class ClimbingPick extends SimpleSlimefunItem implements double speed = getClimbingSpeed(type); int efficiencyLevel = item.getEnchantmentLevel(Enchantment.DIG_SPEED); - if (efficiencyLevel > 0) { + if (speed > 0 && efficiencyLevel > 0) { speed += efficiencyLevel * EFFICIENCY_MODIFIER; } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java index 19a5ac00e..ae47a7483 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java @@ -55,6 +55,14 @@ class TestClimbingPick implements SlimefunItemTest { @Override public ClimbingPick registerSlimefunItem(SlimefunPlugin plugin, String id) { + try { + SlimefunTag.CLIMBING_PICK_WEAK_SURFACES.reload(); + SlimefunTag.CLIMBING_PICK_STRONG_SURFACES.reload(); + } + catch (TagMisconfigurationException e) { + Assertions.fail(e); + } + SlimefunItemStack item = new SlimefunItemStack(id, Material.IRON_PICKAXE, "&5Test Pick"); ClimbingPick pick = new ClimbingPick(TestUtilities.getCategory(plugin, "climbing_pick"), item, RecipeType.NULL, new ItemStack[9]) { From ceadd2147f4ff300b0f46934a6d27d9e9f28b48d Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 4 Oct 2020 11:51:03 +0200 Subject: [PATCH 030/178] Added a debug line to finally fix this unit test --- .../slimefun4/api/items/ItemSetting.java | 9 ++++++++- .../implementation/items/tools/ClimbingPick.java | 15 ++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java index ce98a6a35..774265809 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java @@ -133,7 +133,14 @@ public class ItemSetting { Object configuredValue = SlimefunPlugin.getItemCfg().getValue(item.getID() + '.' + getKey()); if (defaultValue.getClass().isInstance(configuredValue)) { - this.value = (T) configuredValue; + if (validateInput((T) configuredValue)) { + this.value = (T) configuredValue; + } + else { + Slimefun.getLogger().log(Level.WARNING, "Slimefun has found an invalid config setting in your Items.yml!"); + Slimefun.getLogger().log(Level.WARNING, " at \"{0}.{1}\"", new Object[] { item.getID(), getKey() }); + Slimefun.getLogger().log(Level.WARNING, "{0} is not a valid input!", configuredValue); + } } else { this.value = defaultValue; 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 a337be904..7f3163d96 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 @@ -122,7 +122,14 @@ public class ClimbingPick extends SimpleSlimefunItem implements public double getClimbingSpeed(@Nonnull Material type) { Validate.notNull(type, "The surface cannot be null"); ClimbableSurface surface = surfaces.get(type); - return surface != null ? surface.getValue() : 0; + + if (surface != null) { + System.out.println(surface.getValue()); + return surface.getValue(); + } + else { + return 0; + } } /** @@ -168,11 +175,9 @@ public class ClimbingPick extends SimpleSlimefunItem implements } // Top and bottom faces won't be allowed - if (e.getClickedFace() == BlockFace.DOWN || e.getClickedFace() == BlockFace.UP) { - return; + if (e.getClickedFace() != BlockFace.DOWN && e.getClickedFace() != BlockFace.UP) { + climb(p, e.getHand(), e.getItem(), block); } - - climb(p, e.getHand(), e.getItem(), block); }; } From c8d2bea162dd064018a7af0745d8fc258999ae99 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 4 Oct 2020 12:16:32 +0200 Subject: [PATCH 031/178] Maybe now? :eyes: --- .../slimefun4/implementation/items/tools/ClimbingPick.java | 1 - .../tests/items/implementations/tools/TestClimbingPick.java | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) 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 7f3163d96..ab20d3032 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 @@ -124,7 +124,6 @@ public class ClimbingPick extends SimpleSlimefunItem implements ClimbableSurface surface = surfaces.get(type); if (surface != null) { - System.out.println(surface.getValue()); return surface.getValue(); } else { diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java index ae47a7483..b1fb1ec00 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java @@ -64,7 +64,6 @@ class TestClimbingPick implements SlimefunItemTest { } SlimefunItemStack item = new SlimefunItemStack(id, Material.IRON_PICKAXE, "&5Test Pick"); - ClimbingPick pick = new ClimbingPick(TestUtilities.getCategory(plugin, "climbing_pick"), item, RecipeType.NULL, new ItemStack[9]) { @Override @@ -75,6 +74,7 @@ class TestClimbingPick implements SlimefunItemTest { }; pick.register(plugin); + Assertions.assertFalse(pick.getClimbableSurfaces().isEmpty()); return pick; } @@ -124,7 +124,6 @@ class TestClimbingPick implements SlimefunItemTest { @DisplayName("Test Climbing Pick on various Block Faces") @EnumSource(value = BlockFace.class, names = { "UP", "DOWN", "NORTH", "EAST", "SOUTH", "WEST" }) void testItemUse(BlockFace face) { - server.getPluginManager().clearEvents(); PlayerMock player = server.addPlayer(); ClimbingPick pick = registerSlimefunItem(plugin, "TEST_CLIMBING_PICK_" + face.name()); Location blockLocation = new Location(player.getLocation().getWorld(), player.getLocation().getBlockX() + 1, player.getLocation().getBlockY(), player.getLocation().getBlockZ()); @@ -137,7 +136,7 @@ class TestClimbingPick implements SlimefunItemTest { if (shouldFireEvent) { Assertions.assertTrue(pick.getClimbingSpeed(block.getType()) > 0); Assertions.assertTrue(player.getVelocity().length() > 0); - server.getPluginManager().assertEventFired(ClimbingPickLaunchEvent.class); + server.getPluginManager().assertEventFired(ClimbingPickLaunchEvent.class, e -> e.getPlayer() == player && e.getPick() == pick); } else { Assertions.assertEquals(0, player.getVelocity().length()); From 5753def8e9223894339b99658d2c8fb38cb35521 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 4 Oct 2020 12:42:59 +0200 Subject: [PATCH 032/178] Hey unit tests, you work now, k pls? --- .../thebusybiscuit/slimefun4/api/items/ItemSetting.java | 6 ++++++ .../implementation/items/tools/ClimbingPick.java | 9 ++++++--- .../items/implementations/tools/TestClimbingPick.java | 5 ++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java index 774265809..578540ffc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java @@ -153,4 +153,10 @@ public class ItemSetting { } } + @Override + public String toString() { + T currentValue = this.value != null ? this.value : defaultValue; + return getClass().getSimpleName() + " {" + getKey() + " = " + currentValue + " (default: " + getDefaultValue() + ")"; + } + } 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 ab20d3032..5449d97ad 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 @@ -143,10 +143,13 @@ public class ClimbingPick extends SimpleSlimefunItem implements */ public double getClimbingSpeed(@Nonnull ItemStack item, @Nonnull Material type) { double speed = getClimbingSpeed(type); - int efficiencyLevel = item.getEnchantmentLevel(Enchantment.DIG_SPEED); - if (speed > 0 && efficiencyLevel > 0) { - speed += efficiencyLevel * EFFICIENCY_MODIFIER; + if (speed > 0) { + int efficiencyLevel = item.getEnchantmentLevel(Enchantment.DIG_SPEED); + + if (efficiencyLevel > 0) { + speed += efficiencyLevel * EFFICIENCY_MODIFIER; + } } return speed; diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java index b1fb1ec00..5bd1c4d8b 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java @@ -56,6 +56,7 @@ class TestClimbingPick implements SlimefunItemTest { @Override public ClimbingPick registerSlimefunItem(SlimefunPlugin plugin, String id) { try { + TestUtilities.registerDefaultTags(server); SlimefunTag.CLIMBING_PICK_WEAK_SURFACES.reload(); SlimefunTag.CLIMBING_PICK_STRONG_SURFACES.reload(); } @@ -63,7 +64,7 @@ class TestClimbingPick implements SlimefunItemTest { Assertions.fail(e); } - SlimefunItemStack item = new SlimefunItemStack(id, Material.IRON_PICKAXE, "&5Test Pick"); + SlimefunItemStack item = new SlimefunItemStack(id, Material.IRON_PICKAXE, "&5Test Pick", id); ClimbingPick pick = new ClimbingPick(TestUtilities.getCategory(plugin, "climbing_pick"), item, RecipeType.NULL, new ItemStack[9]) { @Override @@ -91,6 +92,7 @@ class TestClimbingPick implements SlimefunItemTest { } private static Stream getStrongSurfaces() throws TagMisconfigurationException { + TestUtilities.registerDefaultTags(server); SlimefunTag.CLIMBING_PICK_STRONG_SURFACES.reload(); return SlimefunTag.CLIMBING_PICK_STRONG_SURFACES.getValues().stream().map(Arguments::of); } @@ -108,6 +110,7 @@ class TestClimbingPick implements SlimefunItemTest { } private static Stream getWeakSurfaces() throws TagMisconfigurationException { + TestUtilities.registerDefaultTags(server); SlimefunTag.CLIMBING_PICK_WEAK_SURFACES.reload(); return SlimefunTag.CLIMBING_PICK_WEAK_SURFACES.getValues().stream().map(Arguments::of); } From 078e749679f0b031de8b119abb9e6c21bb524b11 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 4 Oct 2020 13:04:21 +0200 Subject: [PATCH 033/178] Added a new Unit test for Slimefun Tags --- .../slimefun4/testing/tests/tags/TestSlimefunTags.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestSlimefunTags.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestSlimefunTags.java index 98120296a..90e069a6b 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestSlimefunTags.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestSlimefunTags.java @@ -111,6 +111,16 @@ class TestSlimefunTags { } } + @Test + @DisplayName("Test static SlimefunTag accessors") + void testGetTag() { + Assertions.assertEquals(SlimefunTag.GLASS_BLOCKS, SlimefunTag.getTag("GLASS_BLOCKS")); + Assertions.assertEquals(SlimefunTag.ORES, SlimefunTag.getTag("ORES")); + Assertions.assertEquals(SlimefunTag.SHULKER_BOXES, SlimefunTag.getTag("SHULKER_BOXES")); + + Assertions.assertArrayEquals(SlimefunTag.values(), SlimefunTag.values); + } + private void assertNotCyclic(@Nonnull SlimefunTag tag) { Set visiting = new HashSet<>(); Set visited = new HashSet<>(); From 7cab529a2b9179739b02198af4b9b45ea177a2c8 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 4 Oct 2020 13:19:54 +0200 Subject: [PATCH 034/178] Merged master into tags --- .../slimefun4/testing/tests/tags/TestSlimefunTags.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestSlimefunTags.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestSlimefunTags.java index 90e069a6b..5dc4b454c 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestSlimefunTags.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestSlimefunTags.java @@ -117,6 +117,8 @@ class TestSlimefunTags { Assertions.assertEquals(SlimefunTag.GLASS_BLOCKS, SlimefunTag.getTag("GLASS_BLOCKS")); Assertions.assertEquals(SlimefunTag.ORES, SlimefunTag.getTag("ORES")); Assertions.assertEquals(SlimefunTag.SHULKER_BOXES, SlimefunTag.getTag("SHULKER_BOXES")); + Assertions.assertNull(SlimefunTag.getTag("hello")); + Assertions.assertThrows(IllegalArgumentException.class, () -> SlimefunTag.getTag(null)); Assertions.assertArrayEquals(SlimefunTag.values(), SlimefunTag.values); } From 655b429f0d7d4955b4c18bfc32df54d859eb8501 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 4 Oct 2020 13:31:52 +0200 Subject: [PATCH 035/178] Added a new super tag --- .../slimefun4/utils/tags/SlimefunTag.java | 6 ++++++ .../resources/tags/climbing_pick_surfaces.json | 6 ++++++ .../implementations/tools/TestClimbingPick.java | 16 ++++++++++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/tags/climbing_pick_surfaces.json diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java index d5218059c..ebbd4e110 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java @@ -164,6 +164,12 @@ public enum SlimefunTag implements Tag { * All weak materials which the {@link ClimbingPick} is able to climb. */ CLIMBING_PICK_WEAK_SURFACES, + + /** + * This {@link SlimefunTag} holds all surfaces for the {@link ClimbingPick}. + * This is an aggregation of {@code CLIMBING_PICK_STRONG_SURFACES} and {@code CLIMBING_PICK_WEAK_SURFACES} + */ + CLIMBING_PICK_SURFACES, /** * All materials (ores) which trigger the Talisman of the Caveman. diff --git a/src/main/resources/tags/climbing_pick_surfaces.json b/src/main/resources/tags/climbing_pick_surfaces.json new file mode 100644 index 000000000..6af387263 --- /dev/null +++ b/src/main/resources/tags/climbing_pick_surfaces.json @@ -0,0 +1,6 @@ +{ + "values" : [ + "#slimefun:climbing_pick_strong_surfaces", + "#slimefun:climbing_pick_weak_surfaces" + ] +} diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java index 5bd1c4d8b..6d77a6c65 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java @@ -83,10 +83,10 @@ class TestClimbingPick implements SlimefunItemTest { @DisplayName("Test Climbing Pick on strong surfaces") @MethodSource("getStrongSurfaces") void testStrongSurfaces(Material surface) { - Assertions.assertFalse(SlimefunTag.CLIMBING_PICK_STRONG_SURFACES.getValues().isEmpty()); ClimbingPick pick = registerSlimefunItem(plugin, "STRONG_CLIMBING_PICK_" + surface.name()); double speed = pick.getClimbingSpeed(surface); + Assertions.assertTrue(SlimefunTag.CLIMBING_PICK_STRONG_SURFACES.isTagged(surface)); Assertions.assertEquals(STRONG_SURFACE_DEFAULT, speed); Assertions.assertEquals(1, pick.getClimbableSurfaces().stream().filter(s -> s.getType() == surface).count()); } @@ -101,10 +101,10 @@ class TestClimbingPick implements SlimefunItemTest { @DisplayName("Test Climbing Pick on weak surfaces") @MethodSource("getWeakSurfaces") void testWeakSurfaces(Material surface) { - Assertions.assertFalse(SlimefunTag.CLIMBING_PICK_WEAK_SURFACES.getValues().isEmpty()); ClimbingPick pick = registerSlimefunItem(plugin, "WEAK_CLIMBING_PICK_" + surface.name()); double speed = pick.getClimbingSpeed(surface); + Assertions.assertTrue(SlimefunTag.CLIMBING_PICK_WEAK_SURFACES.isTagged(surface)); Assertions.assertEquals(WEAK_SURFACE_DEFAULT, speed); Assertions.assertEquals(1, pick.getClimbableSurfaces().stream().filter(s -> s.getType() == surface).count()); } @@ -115,11 +115,23 @@ class TestClimbingPick implements SlimefunItemTest { return SlimefunTag.CLIMBING_PICK_WEAK_SURFACES.getValues().stream().map(Arguments::of); } + @Test + @DisplayName("Test Climbing Pick on climbable surface") + void testClimbable() { + ClimbingPick pick = registerSlimefunItem(plugin, "WEAK_CLIMBING_PICK"); + double speed = pick.getClimbingSpeed(Material.ICE); + + Assertions.assertFalse(SlimefunTag.CLIMBING_PICK_SURFACES.isTagged(Material.ICE)); + Assertions.assertTrue(speed > 0); + } + @Test @DisplayName("Test Climbing Pick on non-climbable surface") void testNonClimbable() { ClimbingPick pick = registerSlimefunItem(plugin, "NOT_CLIMBING_PICK"); double speed = pick.getClimbingSpeed(Material.DRAGON_EGG); + + Assertions.assertFalse(SlimefunTag.CLIMBING_PICK_SURFACES.isTagged(Material.DRAGON_EGG)); Assertions.assertEquals(0, speed); } From b32dc0b72784f082bc97c9885da9e6a91db54900 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 4 Oct 2020 13:40:41 +0200 Subject: [PATCH 036/178] @poma123 for the rescue --- .../slimefun4/api/MinecraftVersion.java | 2 +- .../slimefun4/api/player/PlayerBackpack.java | 3 ++- .../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 | 6 +++--- .../items/androids/Instruction.java | 4 ++-- .../items/androids/ProgrammableAndroid.java | 2 +- .../slimefun4/utils/HeadTexture.java | 4 +++- .../slimefun4/utils/tags/SlimefunTag.java | 12 +++++++++--- .../tools/TestClimbingPick.java | 13 ++----------- .../tests/listeners/TestBackpackListener.java | 5 +---- .../testing/tests/tags/TestSlimefunTags.java | 18 ++++-------------- .../testing/tests/utils/TestHeadTextures.java | 2 +- 17 files changed, 35 insertions(+), 48 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 c4c8c0dd5..9cb5793b9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java @@ -50,7 +50,7 @@ public enum MinecraftVersion { */ UNIT_TEST("Unit Test Environment"); - public static final MinecraftVersion[] values = values(); + public static final MinecraftVersion[] valuesCache = values(); private final String name; private final String prefix; 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 e0f2086f2..336a6bfbe 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 @@ -28,13 +28,14 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.BackpackListe */ public class PlayerBackpack { + private static final String CONFIG_PREFIX = "backpacks."; + private final PlayerProfile profile; private final int id; private final Config cfg; private Inventory inventory; private int size; - private static final String CONFIG_PREFIX = "backpacks."; /** * This constructor loads an existing Backpack 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 278352c9d..562fe5981 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,6 +31,6 @@ public enum SlimefunGuideLayout { */ CHEAT_SHEET; - public static final SlimefunGuideLayout[] values = values(); + public static final SlimefunGuideLayout[] valuesCache = 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 f30704905..de7f10de4 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.valuesCache) { 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 a4e21ba01..bc14a57b3 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.valuesCache) { 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 76287f772..a6381a059 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,7 +58,7 @@ enum SupportedLanguage { MACEDONIAN("mk", false, "a0e0b0b5d87a855466980a101a757bcdb5f77d9f7287889f3efa998ee0472fc0"), TAGALOG("tl", true, "9306c0c1ce6a9c61bb42a572c49e6d0ed20e0e6b3d122cc64c339cbf78e9e937"); - public static final SupportedLanguage[] values = values(); + public static final SupportedLanguage[] valuesCache = values(); private final String id; private final boolean releaseReady; 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 b03191c6c..b1417b523 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,7 +31,7 @@ public enum PerformanceRating implements Predicate { HURTFUL(ChatColor.DARK_RED, 500), BAD(ChatColor.DARK_RED, Float.MAX_VALUE); - public static final PerformanceRating[] values = values(); + public static final PerformanceRating[] valuesCache = 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 b69118d89..ae3925596 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.valuesCache) { 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 b96b58e0f..20617921b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java @@ -318,7 +318,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.valuesCache) { if (version.matches(currentVersion)) { minecraftVersion = version; return false; @@ -345,7 +345,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.valuesCache) { if (version != MinecraftVersion.UNKNOWN) { list.add(version.getName()); } @@ -498,7 +498,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { } private void loadTags() { - for (SlimefunTag tag : SlimefunTag.values) { + for (SlimefunTag tag : SlimefunTag.valuesCache) { try { tag.reload(); } 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 429821dc4..4a2083b05 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 @@ -146,10 +146,10 @@ enum Instruction { }); private static final Map nameLookup = new HashMap<>(); - public static final Instruction[] values = values(); + public static final Instruction[] valuesCache = values(); static { - for (Instruction instruction : values) { + for (Instruction instruction : valuesCache) { nameLookup.put(instruction.name(), instruction); } } 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 ea61d38f6..b4485b525 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 @@ -502,7 +502,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, protected List getValidScriptInstructions() { List list = new ArrayList<>(); - for (Instruction part : Instruction.values) { + for (Instruction part : Instruction.valuesCache) { if (part == Instruction.START || part == Instruction.REPEAT) { continue; } 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 019979dfb..8db1b1e07 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java @@ -109,7 +109,7 @@ public enum HeadTexture { IRON_GOLEM("89091d79ea0f59ef7ef94d7bba6e5f17f2f7d4572c44f90f76c4819a714"), PIGLIN_HEAD("2882af1294a74023e6919a31d1a027310f2e142afb4667d230d155e7f21dbb41"); - public static final HeadTexture[] values = values(); + public static final HeadTexture[] valuesCache = values(); private final String texture; @@ -123,6 +123,7 @@ public enum HeadTexture { * * @return The associated texture hash */ + @Nonnull public String getTexture() { return texture; } @@ -132,6 +133,7 @@ public enum HeadTexture { * * @return A custom head {@link ItemStack} */ + @Nonnull public ItemStack getAsItemStack() { return SlimefunUtils.getCustomHead(getTexture()); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java index ebbd4e110..16a4069cb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java @@ -164,7 +164,7 @@ public enum SlimefunTag implements Tag { * All weak materials which the {@link ClimbingPick} is able to climb. */ CLIMBING_PICK_WEAK_SURFACES, - + /** * This {@link SlimefunTag} holds all surfaces for the {@link ClimbingPick}. * This is an aggregation of {@code CLIMBING_PICK_STRONG_SURFACES} and {@code CLIMBING_PICK_WEAK_SURFACES} @@ -177,10 +177,10 @@ public enum SlimefunTag implements Tag { CAVEMAN_TALISMAN_TRIGGERS; private static final Map nameLookup = new HashMap<>(); - public static final SlimefunTag[] values = values(); + public static final SlimefunTag[] valuesCache = values(); static { - for (SlimefunTag tag : values) { + for (SlimefunTag tag : valuesCache) { nameLookup.put(tag.name(), tag); } } @@ -214,6 +214,12 @@ public enum SlimefunTag implements Tag { }); } + public static void reloadAll() throws TagMisconfigurationException { + for (SlimefunTag tag : valuesCache) { + tag.reload(); + } + } + @Nonnull @Override public NamespacedKey getKey() { diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java index 6d77a6c65..4213c1649 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java @@ -55,15 +55,6 @@ class TestClimbingPick implements SlimefunItemTest { @Override public ClimbingPick registerSlimefunItem(SlimefunPlugin plugin, String id) { - try { - TestUtilities.registerDefaultTags(server); - SlimefunTag.CLIMBING_PICK_WEAK_SURFACES.reload(); - SlimefunTag.CLIMBING_PICK_STRONG_SURFACES.reload(); - } - catch (TagMisconfigurationException e) { - Assertions.fail(e); - } - SlimefunItemStack item = new SlimefunItemStack(id, Material.IRON_PICKAXE, "&5Test Pick", id); ClimbingPick pick = new ClimbingPick(TestUtilities.getCategory(plugin, "climbing_pick"), item, RecipeType.NULL, new ItemStack[9]) { @@ -93,7 +84,7 @@ class TestClimbingPick implements SlimefunItemTest { private static Stream getStrongSurfaces() throws TagMisconfigurationException { TestUtilities.registerDefaultTags(server); - SlimefunTag.CLIMBING_PICK_STRONG_SURFACES.reload(); + SlimefunTag.reloadAll(); return SlimefunTag.CLIMBING_PICK_STRONG_SURFACES.getValues().stream().map(Arguments::of); } @@ -111,7 +102,7 @@ class TestClimbingPick implements SlimefunItemTest { private static Stream getWeakSurfaces() throws TagMisconfigurationException { TestUtilities.registerDefaultTags(server); - SlimefunTag.CLIMBING_PICK_WEAK_SURFACES.reload(); + SlimefunTag.reloadAll(); return SlimefunTag.CLIMBING_PICK_WEAK_SURFACES.getValues().stream().map(Arguments::of); } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestBackpackListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestBackpackListener.java index d798b1677..ed9d3014e 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestBackpackListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestBackpackListener.java @@ -55,10 +55,7 @@ class TestBackpackListener { server = MockBukkit.mock(); TestUtilities.registerDefaultTags(server); plugin = MockBukkit.load(SlimefunPlugin.class); - - for (SlimefunTag tag : SlimefunTag.values) { - tag.reload(); - } + SlimefunTag.reloadAll(); listener = new BackpackListener(); listener.register(plugin); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestSlimefunTags.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestSlimefunTags.java index 5dc4b454c..7e4b760c9 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestSlimefunTags.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestSlimefunTags.java @@ -46,9 +46,7 @@ class TestSlimefunTags { @Test @DisplayName("Test for infinite loops with Slimefun Tags") void testForInfiniteLoops() throws TagMisconfigurationException { - for (SlimefunTag tag : SlimefunTag.values()) { - tag.reload(); - } + SlimefunTag.reloadAll(); for (SlimefunTag tag : SlimefunTag.values()) { assertNotCyclic(tag); @@ -58,9 +56,7 @@ class TestSlimefunTags { @Test @DisplayName("Test SlimefunTag#isTagged()") void testIsTagged() throws TagMisconfigurationException { - for (SlimefunTag tag : SlimefunTag.values()) { - tag.reload(); - } + SlimefunTag.reloadAll(); // Direct inclusion Assertions.assertTrue(SlimefunTag.SENSITIVE_MATERIALS.isTagged(Material.CAKE)); @@ -75,9 +71,7 @@ class TestSlimefunTags { @Test @DisplayName("Test SlimefunTag#toArray()") void testToArray() throws TagMisconfigurationException { - for (SlimefunTag tag : SlimefunTag.values()) { - tag.reload(); - } + SlimefunTag.reloadAll(); for (SlimefunTag tag : SlimefunTag.values()) { Set values = tag.getValues(); @@ -88,9 +82,7 @@ class TestSlimefunTags { @Test @DisplayName("Test SlimefunTag#getValues()") void testGetValues() throws TagMisconfigurationException { - for (SlimefunTag tag : SlimefunTag.values()) { - tag.reload(); - } + SlimefunTag.reloadAll(); for (SlimefunTag tag : SlimefunTag.values()) { Set values = tag.getValues(); @@ -119,8 +111,6 @@ class TestSlimefunTags { Assertions.assertEquals(SlimefunTag.SHULKER_BOXES, SlimefunTag.getTag("SHULKER_BOXES")); Assertions.assertNull(SlimefunTag.getTag("hello")); Assertions.assertThrows(IllegalArgumentException.class, () -> SlimefunTag.getTag(null)); - - Assertions.assertArrayEquals(SlimefunTag.values(), SlimefunTag.values); } private void assertNotCyclic(@Nonnull SlimefunTag tag) { 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 ecaaa4368..601d0d335 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.valuesCache) { String texture = head.getTexture(); Assertions.assertNotNull(texture); From 2ac5899abc9b07b3af91b9acab076392c603b42c Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 4 Oct 2020 13:44:04 +0200 Subject: [PATCH 037/178] Whoops --- .../tests/items/implementations/tools/TestClimbingPick.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java index 4213c1649..7bf645ed4 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java @@ -112,7 +112,7 @@ class TestClimbingPick implements SlimefunItemTest { ClimbingPick pick = registerSlimefunItem(plugin, "WEAK_CLIMBING_PICK"); double speed = pick.getClimbingSpeed(Material.ICE); - Assertions.assertFalse(SlimefunTag.CLIMBING_PICK_SURFACES.isTagged(Material.ICE)); + Assertions.assertTrue(SlimefunTag.CLIMBING_PICK_SURFACES.isTagged(Material.ICE)); Assertions.assertTrue(speed > 0); } From cb35cddc9f14c27215e06d217c3ffdfb34d5b6ed Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 5 Oct 2020 15:07:48 +0200 Subject: [PATCH 038/178] Merged with master --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eb55122e6..41e805a73 100644 --- a/pom.xml +++ b/pom.xml @@ -311,7 +311,7 @@ com.github.seeseemelk MockBukkit-v1.16 - 0.10.0 + 0.10.2 test From 37f0715156dd8a8f7228f532daf9e3aeec34a2a4 Mon Sep 17 00:00:00 2001 From: NCBPFluffyBear <31554056+ncbpfluffybear@users.noreply.github.com> Date: Tue, 6 Oct 2020 19:46:22 -0500 Subject: [PATCH 039/178] Added permission checks for the GEO Scanner and GPS Control Panel --- .../implementation/items/geo/GEOScanner.java | 21 ++++++++++++++++--- .../items/gps/GPSControlPanel.java | 21 ++++++++++++++++++- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java index de00637ad..1f4fe0cf8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java @@ -1,6 +1,9 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.geo; +import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; +import me.mrCookieSlime.Slimefun.api.Slimefun; import org.bukkit.block.Block; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; @@ -19,10 +22,22 @@ public class GEOScanner extends SimpleSlimefunItem { @Override public BlockUseHandler getItemHandler() { return e -> { - Block b = e.getClickedBlock().get(); - e.cancel(); - SlimefunPlugin.getGPSNetwork().getResourceManager().scan(e.getPlayer(), b, 0); + + Block b = e.getClickedBlock().get(); + Player p = e.getPlayer(); + + if (p.hasPermission("slimefun.inventory.bypass") + || (SlimefunPlugin.getProtectionManager().hasPermission( + p, b.getLocation(), ProtectableAction.ACCESS_INVENTORIES)) + && Slimefun.hasUnlocked(e.getPlayer(), item, false) + ) { + + SlimefunPlugin.getGPSNetwork().getResourceManager().scan(p, b, 0); + } else { + SlimefunPlugin.getLocalization().sendMessage(p, "inventory.no-access", true); + + } }; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java index 4d11de893..0118f3968 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java @@ -1,5 +1,8 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.gps; +import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; +import me.mrCookieSlime.Slimefun.api.Slimefun; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; @@ -17,6 +20,22 @@ public class GPSControlPanel extends SimpleSlimefunItem { @Override public BlockUseHandler getItemHandler() { - return e -> SlimefunPlugin.getGPSNetwork().openTransmitterControlPanel(e.getPlayer()); + return e -> { + e.cancel(); + + Player p = e.getPlayer(); + + if (p.hasPermission("slimefun.inventory.bypass") + || (SlimefunPlugin.getProtectionManager().hasPermission( + p, e.getClickedBlock().get().getLocation(), ProtectableAction.ACCESS_INVENTORIES)) + && Slimefun.hasUnlocked(p, item, false) + ) { + + SlimefunPlugin.getGPSNetwork().openTransmitterControlPanel(p); + } else { + SlimefunPlugin.getLocalization().sendMessage(p, "inventory.no-access", true); + + } + }; } } From bbb2a78a4ca8558002a5b5e5f25d5c942cf90964 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 7 Oct 2020 17:16:33 +0200 Subject: [PATCH 040/178] Added some code-style guidelines to CONTRIBUTING --- CONTRIBUTING.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e9d1e9120..f3b2d2472 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -94,3 +94,48 @@ 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://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**. + +## :black_nib: Code Style guidelines +The general gist when it comes to code style: **Try to be consistent!**.
+Try to stay inline with the code that surrounds you, having an entire package or even a single file that's filled with plenty of different and inconsistent code styles is just hard to read or maintain. That's why we wanna make sure everyone follows these simple principles: + +1. Imports +* Don't use wildcard (`*`) imports! +* Don't import unused classes! +* Don't use static imports! +2. Annotations +* Methods and parameters should be annotated with `@Nullable` or `@Nonnull`! +* Methods that override a method must be annotated with `@Override`! +* Interfaces with only one method should be annotated using `@FunctionalInterface`! +* If you deprecate a method, add an `@deprecated` section to the javadocs explaining why you did it. +3. Documentation +* Every class and every public method should have a Javadocs section assigned to it. +* New packages should have a `package-info.java` file with documentation about the package. +* Classes should have an `@author` tag. +4. Unit Tests +* Try to write Unit Tests where possible. +* Unit Test classes and methods should have no access modifier, not `public`, `protected` nor `private`. +* Each Test should have a plain text `@DisplayName` annotation! +5. General +* Use **Spaces**, not Tabs! +* Do not declare multiple fields/variables on the same line! (e.g. Don't do this: `int x, y, z;`) +* Comments should never go on the same line as code! Always above or below. +* Use a Logger, try to avoid `System.out.println(...)` and `Throwable#printStacktrace()`! +* Do not use `Collection#forEach(x -> ...)`, use a proper `for (...)` loop! +* Do not create new `Random` objects, use `ThreadLocalRandom.current()` instead! +* Always declare Maps or Collections using their base type! (e.g. `List list = new ArrayList<>();` +* When doing String operations like `String#toUppercase()`, always specify `Locale.ROOT` as an argument! +* When reading or writing files, always specify the encoding using `StandardCharsets.UTF_8`! +* Do not use Exceptions to validate data, empty catch blocks are a very bad practice, use other means like a regular expression to validate data. +* If a parameter is annotated with `@Nonnull`, you should enforce this behaviour by doing `Validate.notNull(variable, "...");` and give a meaningful message about what went wrong +* Any `switch/case` should always have a `default:` case at the end. +* If you are working with a resource that must be closed, use a `try/with-resource`, this will automatically close the resource at the end (e.g. `try (InputStream stream = ...) {`) +* Array designators should be placed behind the type, not the variable name (e.g. `int[] myArray`) +* Enums must be compared using `==`, not with `.equals()`! +* If you need both the key and the value from a Map, use `Map#entrySet()`! +6. Naming conventions +* Classes should be in *PascalCase* (e.g. `MyAwesomeClass`) +* Enum constants should be in *SCREAMING_SNAKE_CASE* (e.g. `MY_ENUM_CONSTANT`) +* Constants (`static final` fields) should be in *SCREAMING_SNAKE_CASE* (e.g. `MY_CONSTANT_FIELD`) +* Variables, parameters and fields should be in *camelCase* (e.g. `myVariableOrField`) +* All methods should be in *camelCase* (e.g. `myMethod`) From 816c0a4e494feab4f34da151730e487dcade56c1 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 7 Oct 2020 17:23:44 +0200 Subject: [PATCH 041/178] Updated headings --- CONTRIBUTING.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f3b2d2472..408caace2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -99,24 +99,24 @@ If you have any further questions, then please join our [Discord Support Server] The general gist when it comes to code style: **Try to be consistent!**.
Try to stay inline with the code that surrounds you, having an entire package or even a single file that's filled with plenty of different and inconsistent code styles is just hard to read or maintain. That's why we wanna make sure everyone follows these simple principles: -1. Imports +#### 1. Imports * Don't use wildcard (`*`) imports! * Don't import unused classes! * Don't use static imports! -2. Annotations +#### 2. Annotations * Methods and parameters should be annotated with `@Nullable` or `@Nonnull`! * Methods that override a method must be annotated with `@Override`! * Interfaces with only one method should be annotated using `@FunctionalInterface`! * If you deprecate a method, add an `@deprecated` section to the javadocs explaining why you did it. -3. Documentation +#### 3. Documentation * Every class and every public method should have a Javadocs section assigned to it. * New packages should have a `package-info.java` file with documentation about the package. * Classes should have an `@author` tag. -4. Unit Tests +#### 4. Unit Tests * Try to write Unit Tests where possible. * Unit Test classes and methods should have no access modifier, not `public`, `protected` nor `private`. * Each Test should have a plain text `@DisplayName` annotation! -5. General +#### 5. General best-practices * Use **Spaces**, not Tabs! * Do not declare multiple fields/variables on the same line! (e.g. Don't do this: `int x, y, z;`) * Comments should never go on the same line as code! Always above or below. @@ -133,7 +133,7 @@ Try to stay inline with the code that surrounds you, having an entire package or * Array designators should be placed behind the type, not the variable name (e.g. `int[] myArray`) * Enums must be compared using `==`, not with `.equals()`! * If you need both the key and the value from a Map, use `Map#entrySet()`! -6. Naming conventions +#### 6. Naming conventions * Classes should be in *PascalCase* (e.g. `MyAwesomeClass`) * Enum constants should be in *SCREAMING_SNAKE_CASE* (e.g. `MY_ENUM_CONSTANT`) * Constants (`static final` fields) should be in *SCREAMING_SNAKE_CASE* (e.g. `MY_CONSTANT_FIELD`) From 9436f2ec47aa98cbccce7e646e5a31b355bb73db Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 7 Oct 2020 17:32:14 +0200 Subject: [PATCH 042/178] Update CONTRIBUTING.md --- CONTRIBUTING.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 408caace2..c68c78e60 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -103,8 +103,9 @@ Try to stay inline with the code that surrounds you, having an entire package or * Don't use wildcard (`*`) imports! * Don't import unused classes! * Don't use static imports! +* Always use imports, even in javadocs, don't write out the full location of a class. #### 2. Annotations -* Methods and parameters should be annotated with `@Nullable` or `@Nonnull`! +* Methods and parameters should be annotated with `@Nullable` (`javax.annotation.Nullable`) or `@Nonnull`(`javax.annotation.Nonnull`)! * Methods that override a method must be annotated with `@Override`! * Interfaces with only one method should be annotated using `@FunctionalInterface`! * If you deprecate a method, add an `@deprecated` section to the javadocs explaining why you did it. @@ -112,6 +113,7 @@ Try to stay inline with the code that surrounds you, having an entire package or * Every class and every public method should have a Javadocs section assigned to it. * New packages should have a `package-info.java` file with documentation about the package. * Classes should have an `@author` tag. +* If there are any other relevant classes related to yours, add them using the `@see` tag. #### 4. Unit Tests * Try to write Unit Tests where possible. * Unit Test classes and methods should have no access modifier, not `public`, `protected` nor `private`. From fa2c1d9957e15402bb807c0c5ac75ea00ee38535 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 7 Oct 2020 18:25:33 +0200 Subject: [PATCH 043/178] Updated code style guidelines --- CONTRIBUTING.md | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c68c78e60..03ca08bea 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -119,15 +119,13 @@ Try to stay inline with the code that surrounds you, having an entire package or * Unit Test classes and methods should have no access modifier, not `public`, `protected` nor `private`. * Each Test should have a plain text `@DisplayName` annotation! #### 5. General best-practices -* Use **Spaces**, not Tabs! -* Do not declare multiple fields/variables on the same line! (e.g. Don't do this: `int x, y, z;`) -* Comments should never go on the same line as code! Always above or below. -* Use a Logger, try to avoid `System.out.println(...)` and `Throwable#printStacktrace()`! * Do not use `Collection#forEach(x -> ...)`, use a proper `for (...)` loop! * Do not create new `Random` objects, use `ThreadLocalRandom.current()` instead! * Always declare Maps or Collections using their base type! (e.g. `List list = new ArrayList<>();` * When doing String operations like `String#toUppercase()`, always specify `Locale.ROOT` as an argument! * When reading or writing files, always specify the encoding using `StandardCharsets.UTF_8`! +* Do not declare multiple fields/variables on the same line! (e.g. Don't do this: `int x, y, z;`) +* Use a Logger, try to avoid `System.out.println(...)` and `Throwable#printStacktrace()`, use `Logger#log` instead! * Do not use Exceptions to validate data, empty catch blocks are a very bad practice, use other means like a regular expression to validate data. * If a parameter is annotated with `@Nonnull`, you should enforce this behaviour by doing `Validate.notNull(variable, "...");` and give a meaningful message about what went wrong * Any `switch/case` should always have a `default:` case at the end. @@ -141,3 +139,25 @@ Try to stay inline with the code that surrounds you, having an entire package or * Constants (`static final` fields) should be in *SCREAMING_SNAKE_CASE* (e.g. `MY_CONSTANT_FIELD`) * Variables, parameters and fields should be in *camelCase* (e.g. `myVariableOrField`) * All methods should be in *camelCase* (e.g. `myMethod`) +* Packages must be all lowercase, consecutive words should generally be avoided. (e.g. `io.github.thebusybiscuit.slimefun4.core.something`) +#### 7. Style preferences +* Use **Spaces**, not Tabs! +* We do not enforce any particular width or column limit, but try to prevent your lines from becoming too long. +* Annotations for methods or fields should never go on the same line, place them on the line above. +* Comments should never go on the same line as code! Always above or below. +* Empty blocks like constructors should not occupy more than one line. (e.g. `private MyClass() {}`) +* Modifiers for classes and fields must follow this order:
+`(public/protected/private) (abstract) (static) (final)` +* if/else statements should always include a bracket, please avoid one-line statements (e.g. Avoid doing: `if (x == 0) return;`) +* Slimefun follows the **1TBS / OTBS** Bracket-Style standard (One true brace style): +```java +private void example(int x) { + if (x < 0) { + // x < 0 + } else if (x > 0) { + // x > 0 + } else { + // x == 0 + } +} +``` From ddf9016b0592286bfc799a5545f27bf1cdc555a9 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 7 Oct 2020 18:28:04 +0200 Subject: [PATCH 044/178] StringBuilder --- CONTRIBUTING.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 03ca08bea..6121afc21 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -129,9 +129,10 @@ Try to stay inline with the code that surrounds you, having an entire package or * Do not use Exceptions to validate data, empty catch blocks are a very bad practice, use other means like a regular expression to validate data. * If a parameter is annotated with `@Nonnull`, you should enforce this behaviour by doing `Validate.notNull(variable, "...");` and give a meaningful message about what went wrong * Any `switch/case` should always have a `default:` case at the end. -* If you are working with a resource that must be closed, use a `try/with-resource`, this will automatically close the resource at the end (e.g. `try (InputStream stream = ...) {`) -* Array designators should be placed behind the type, not the variable name (e.g. `int[] myArray`) +* If you are working with a resource that must be closed, use a `try/with-resource`, this will automatically close the resource at the end. (e.g. `try (InputStream stream = ...) {`) +* Array designators should be placed behind the type, not the variable name. (e.g. `int[] myArray`) * Enums must be compared using `==`, not with `.equals()`! +* Avoid direct string concatenation, use a `StringBuilder` instead! * If you need both the key and the value from a Map, use `Map#entrySet()`! #### 6. Naming conventions * Classes should be in *PascalCase* (e.g. `MyAwesomeClass`) From 95084eff70270c79e3f710de7dececd69e129c77 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 7 Oct 2020 18:32:36 +0200 Subject: [PATCH 045/178] Added empty lines --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6121afc21..e214eb1d8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -146,6 +146,7 @@ Try to stay inline with the code that surrounds you, having an entire package or * We do not enforce any particular width or column limit, but try to prevent your lines from becoming too long. * Annotations for methods or fields should never go on the same line, place them on the line above. * Comments should never go on the same line as code! Always above or below. +* Make sure that empty lines are truly empty, they should not contain any whitespace characters. * Empty blocks like constructors should not occupy more than one line. (e.g. `private MyClass() {}`) * Modifiers for classes and fields must follow this order:
`(public/protected/private) (abstract) (static) (final)` From 126ccf3d0112e03b0144b48ee100ffd83d7f8db0 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 7 Oct 2020 18:43:55 +0200 Subject: [PATCH 046/178] Formatting --- .../implementation/SlimefunPlugin.java | 3 +- .../items/tools/ClimbingPick.java | 3 +- .../slimefun4/utils/tags/SlimefunTag.java | 6 +-- .../slimefun4/utils/tags/TagParser.java | 45 +++++++------------ .../testing/tests/tags/TestSlimefunTags.java | 3 +- 5 files changed, 20 insertions(+), 40 deletions(-) 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 cc7f98539..c98640a32 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java @@ -497,8 +497,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { for (SlimefunTag tag : SlimefunTag.valuesCache) { try { tag.reload(); - } - catch (TagMisconfigurationException e) { + } catch (TagMisconfigurationException e) { getLogger().log(Level.SEVERE, "Failed to load a Tag!", e); } } 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 445bdbd81..283193fd6 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 @@ -125,8 +125,7 @@ public class ClimbingPick extends SimpleSlimefunItem implements if (surface != null) { return surface.getValue(); - } - else { + } else { return 0; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java index 16a4069cb..b63251da7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java @@ -230,8 +230,7 @@ public enum SlimefunTag implements Tag { public boolean isTagged(@Nonnull Material item) { if (includedMaterials.contains(item)) { return true; - } - else { + } else { // Check if any of our additional Tags contain this Materials for (Tag tag : additionalTags) { if (tag.isTagged(item)) { @@ -249,8 +248,7 @@ public enum SlimefunTag implements Tag { public Set getValues() { if (additionalTags.isEmpty()) { return Collections.unmodifiableSet(includedMaterials); - } - else { + } else { Set materials = new HashSet<>(includedMaterials); for (Tag tag : additionalTags) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java index e15947a79..aee7dcbfc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java @@ -66,8 +66,7 @@ public class TagParser implements Keyed { try (BufferedReader reader = new BufferedReader(new InputStreamReader(SlimefunPlugin.class.getResourceAsStream(path), StandardCharsets.UTF_8))) { parse(reader.lines().collect(Collectors.joining("")), callback); - } - catch (IOException x) { + } catch (IOException x) { throw new TagMisconfigurationException(key, x.getMessage()); } } @@ -103,26 +102,22 @@ public class TagParser implements Keyed { if (element instanceof JsonPrimitive && ((JsonPrimitive) element).isString()) { // Strings will be parsed directly parsePrimitiveValue(element.getAsString(), materials, tags); - } - else if (element instanceof JsonObject) { + } else if (element instanceof JsonObject) { // JSONObjects can have a "required" property which can make // it optional to resolve the underlying value parseComplexValue(element.getAsJsonObject(), materials, tags); - } - else { + } else { throw new TagMisconfigurationException(key, "Unexpected value format: " + element.getClass().getSimpleName() + " - " + element.toString()); } } // Run the callback with the filled-in materials and tags callback.accept(materials, tags); - } - else { + } else { // The JSON seems to be empty yet valid throw new TagMisconfigurationException(key, "No values array specified"); } - } - catch (IllegalStateException | JsonParseException x) { + } catch (IllegalStateException | JsonParseException x) { throw new TagMisconfigurationException(key, x.getMessage()); } } @@ -136,12 +131,10 @@ public class TagParser implements Keyed { if (material != null) { // If the Material could be matched, simply add it to our Set materials.add(material); - } - else { + } else { throw new TagMisconfigurationException(key, "Minecraft Material '" + value + "' seems to not exist!"); } - } - else if (PatternUtils.MINECRAFT_TAG.matcher(value).matches()) { + } else if (PatternUtils.MINECRAFT_TAG.matcher(value).matches()) { // Get the actual Key portion and match it to item and block tags. String keyValue = PatternUtils.COLON.split(value)[1]; NamespacedKey namespacedKey = NamespacedKey.minecraft(keyValue); @@ -151,29 +144,24 @@ public class TagParser implements Keyed { if (itemsTag != null) { // We will prioritize the item tag tags.add(itemsTag); - } - else if (blocksTag != null) { + } else if (blocksTag != null) { // If no item tag exists, fall back to the block tag tags.add(blocksTag); - } - else { + } else { // If both fail, then the tag does not exist. throw new TagMisconfigurationException(key, "There is no '" + value + "' tag in Minecraft."); } - } - else if (PatternUtils.SLIMEFUN_TAG.matcher(value).matches()) { + } else if (PatternUtils.SLIMEFUN_TAG.matcher(value).matches()) { // Get a SlimefunTag enum value for the given key String keyValue = PatternUtils.COLON.split(value)[1].toUpperCase(Locale.ROOT); SlimefunTag tag = SlimefunTag.getTag(keyValue); if (tag != null) { tags.add(tag); - } - else { + } else { throw new TagMisconfigurationException(key, "There is no '" + value + "' tag in Slimefun"); } - } - else { + } else { // If no RegEx pattern matched, it's malformed. throw new TagMisconfigurationException(key, "Could not recognize value '" + value + "'"); } @@ -189,18 +177,15 @@ public class TagParser implements Keyed { if (required.getAsBoolean()) { // If this entry is required, parse it like normal parsePrimitiveValue(id.getAsString(), materials, tags); - } - else { + } else { // If the entry is not required, validation will be optional try { parsePrimitiveValue(id.getAsString(), materials, tags); - } - catch (TagMisconfigurationException x) { + } catch (TagMisconfigurationException x) { // This is an optional entry, so we will ignore the validation here } } - } - else { + } else { throw new TagMisconfigurationException(key, "Found a JSON Object value without an id!"); } } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestSlimefunTags.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestSlimefunTags.java index 1ec81420d..7c2a6f51f 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestSlimefunTags.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/tags/TestSlimefunTags.java @@ -129,8 +129,7 @@ class TestSlimefunTags { if (sub instanceof SlimefunTag) { if (visiting.contains(sub)) { return true; - } - else if (!visited.contains(sub) && isCyclic(visiting, visited, (SlimefunTag) sub)) { + } else if (!visited.contains(sub) && isCyclic(visiting, visited, (SlimefunTag) sub)) { return true; } } From 4936c25e491edc9f9c2c593fa9f7b51f0af19445 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 7 Oct 2020 18:53:13 +0200 Subject: [PATCH 047/178] Horizontal whitespaces --- CONTRIBUTING.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e214eb1d8..1026fb78c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -143,6 +143,8 @@ Try to stay inline with the code that surrounds you, having an entire package or * Packages must be all lowercase, consecutive words should generally be avoided. (e.g. `io.github.thebusybiscuit.slimefun4.core.something`) #### 7. Style preferences * Use **Spaces**, not Tabs! +* Try to keep ternary operators to a minimum, only in return statements (e.g. avoid doing this: `int y = x == null ? 1: 2`) +* if/else statements should always include a bracket, please avoid one-line statements (e.g. Avoid doing: `if (x == 0) return;`) * We do not enforce any particular width or column limit, but try to prevent your lines from becoming too long. * Annotations for methods or fields should never go on the same line, place them on the line above. * Comments should never go on the same line as code! Always above or below. @@ -150,7 +152,12 @@ Try to stay inline with the code that surrounds you, having an entire package or * Empty blocks like constructors should not occupy more than one line. (e.g. `private MyClass() {}`) * Modifiers for classes and fields must follow this order:
`(public/protected/private) (abstract) (static) (final)` -* if/else statements should always include a bracket, please avoid one-line statements (e.g. Avoid doing: `if (x == 0) return;`) +* We recommend using horizontal whitespaces like this: + * In variable assignments: `int x = 123;` + * In a for-loop: `for (int i = 0; i < 10; i++) {` + * Before and after statement parenthesis: `if (x != null) {` + * Inbetween array initializers: `int[] array = { 1, 2, 3 }; + * After the double slash of a comment: `// This is a comment` * Slimefun follows the **1TBS / OTBS** Bracket-Style standard (One true brace style): ```java private void example(int x) { From b577c1e4a369fe954420ecb7b2fe0aa2cd1ce5d7 Mon Sep 17 00:00:00 2001 From: NCBPFluffyBear <31554056+ncbpfluffybear@users.noreply.github.com> Date: Wed, 7 Oct 2020 13:45:49 -0500 Subject: [PATCH 048/178] Did changes --- .../slimefun4/implementation/items/geo/GEOScanner.java | 3 +-- .../slimefun4/implementation/items/gps/GPSControlPanel.java | 3 +-- src/main/resources/plugin.yml | 3 +++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java index 1f4fe0cf8..76d171d5b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java @@ -27,10 +27,9 @@ public class GEOScanner extends SimpleSlimefunItem { Block b = e.getClickedBlock().get(); Player p = e.getPlayer(); - if (p.hasPermission("slimefun.inventory.bypass") + if (p.hasPermission("slimefun.gps.bypass") || (SlimefunPlugin.getProtectionManager().hasPermission( p, b.getLocation(), ProtectableAction.ACCESS_INVENTORIES)) - && Slimefun.hasUnlocked(e.getPlayer(), item, false) ) { SlimefunPlugin.getGPSNetwork().getResourceManager().scan(p, b, 0); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java index 0118f3968..b13cf36cb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java @@ -25,10 +25,9 @@ public class GPSControlPanel extends SimpleSlimefunItem { Player p = e.getPlayer(); - if (p.hasPermission("slimefun.inventory.bypass") + if (p.hasPermission("slimefun.gps.bypass") || (SlimefunPlugin.getProtectionManager().hasPermission( p, e.getClickedBlock().get().getLocation(), ProtectableAction.ACCESS_INVENTORIES)) - && Slimefun.hasUnlocked(p, item, false) ) { SlimefunPlugin.getGPSNetwork().openTransmitterControlPanel(p); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 5c84cd1a9..f0aaf77fd 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -61,6 +61,9 @@ permissions: slimefun.inventory.bypass: description: Allows you to open all Slimefun Machines default: op + slimefun.gps.bypass: + description: Allows you to open all GPS inventories + default: op slimefun.debugging: description: Allows you to use the debugging tool from Slimefun default: op From 90ccbb2261d0da148454f551b51853f8e00aae2b Mon Sep 17 00:00:00 2001 From: NCBPFluffyBear <31554056+ncbpfluffybear@users.noreply.github.com> Date: Wed, 7 Oct 2020 17:37:41 -0500 Subject: [PATCH 049/178] Organized imports --- .../slimefun4/implementation/items/geo/GEOScanner.java | 3 +-- .../slimefun4/implementation/items/gps/GPSControlPanel.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java index 76d171d5b..c5aacea66 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java @@ -1,11 +1,10 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.geo; -import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; -import me.mrCookieSlime.Slimefun.api.Slimefun; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java index b13cf36cb..6fef675a9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java @@ -1,10 +1,9 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.gps; -import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; -import me.mrCookieSlime.Slimefun.api.Slimefun; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; From f2db686abac366f17af9d9d14684ff38ce4a0a8e Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 8 Oct 2020 00:47:19 +0200 Subject: [PATCH 050/178] Added info about guard blocks --- CONTRIBUTING.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1026fb78c..061ff9e23 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -143,8 +143,17 @@ Try to stay inline with the code that surrounds you, having an entire package or * Packages must be all lowercase, consecutive words should generally be avoided. (e.g. `io.github.thebusybiscuit.slimefun4.core.something`) #### 7. Style preferences * Use **Spaces**, not Tabs! -* Try to keep ternary operators to a minimum, only in return statements (e.g. avoid doing this: `int y = x == null ? 1: 2`) -* if/else statements should always include a bracket, please avoid one-line statements (e.g. Avoid doing: `if (x == 0) return;`) +* Try to keep ternary operators to a minimum, only in return statements. (e.g. avoid doing this: `int y = x == null ? 1: 2`) +* Try to keep so-called "guard blocks" to a minimum. One guard block is fine but having multiple guard blocks before getting to the actual code... Well, you might wanna refactor your code there. Example: +```java +// guard block +if (something) { + return; +} + +// Actual code... +``` +* if/else statements should always include a bracket, please avoid one-line statements. (e.g. Avoid doing: `if (x == 0) return;`) * We do not enforce any particular width or column limit, but try to prevent your lines from becoming too long. * Annotations for methods or fields should never go on the same line, place them on the line above. * Comments should never go on the same line as code! Always above or below. @@ -156,7 +165,7 @@ Try to stay inline with the code that surrounds you, having an entire package or * In variable assignments: `int x = 123;` * In a for-loop: `for (int i = 0; i < 10; i++) {` * Before and after statement parenthesis: `if (x != null) {` - * Inbetween array initializers: `int[] array = { 1, 2, 3 }; + * Inbetween array initializers: `int[] array = { 1, 2, 3 };` * After the double slash of a comment: `// This is a comment` * Slimefun follows the **1TBS / OTBS** Bracket-Style standard (One true brace style): ```java From fb8ff555048413f54963663660b3baa0908eaa86 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 8 Oct 2020 10:43:14 +0200 Subject: [PATCH 051/178] Added missing bracket --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 061ff9e23..46dfef77a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -121,7 +121,7 @@ Try to stay inline with the code that surrounds you, having an entire package or #### 5. General best-practices * Do not use `Collection#forEach(x -> ...)`, use a proper `for (...)` loop! * Do not create new `Random` objects, use `ThreadLocalRandom.current()` instead! -* Always declare Maps or Collections using their base type! (e.g. `List list = new ArrayList<>();` +* Always declare Maps or Collections using their base type! (e.g. `List list = new ArrayList<>();`) * When doing String operations like `String#toUppercase()`, always specify `Locale.ROOT` as an argument! * When reading or writing files, always specify the encoding using `StandardCharsets.UTF_8`! * Do not declare multiple fields/variables on the same line! (e.g. Don't do this: `int x, y, z;`) From 033bd3b469ad1da87b9755f6c0e1db1dd07bb521 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 8 Oct 2020 11:18:22 +0200 Subject: [PATCH 052/178] Update CONTRIBUTING.md --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 46dfef77a..ba7b3a7ec 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -143,6 +143,7 @@ Try to stay inline with the code that surrounds you, having an entire package or * Packages must be all lowercase, consecutive words should generally be avoided. (e.g. `io.github.thebusybiscuit.slimefun4.core.something`) #### 7. Style preferences * Use **Spaces**, not Tabs! +* One class per file! Please don't put multiple classes into one file, this also applies to enums, make a seperate file for new classes or enums. * Try to keep ternary operators to a minimum, only in return statements. (e.g. avoid doing this: `int y = x == null ? 1: 2`) * Try to keep so-called "guard blocks" to a minimum. One guard block is fine but having multiple guard blocks before getting to the actual code... Well, you might wanna refactor your code there. Example: ```java From f3e15022033ff8607517d132a6bbcd42e509243d Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 8 Oct 2020 11:39:51 +0200 Subject: [PATCH 053/178] Added a disclaimer --- CONTRIBUTING.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ba7b3a7ec..03fd38e80 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -97,7 +97,11 @@ If you have any further questions, then please join our [Discord Support Server] ## :black_nib: Code Style guidelines The general gist when it comes to code style: **Try to be consistent!**.
-Try to stay inline with the code that surrounds you, having an entire package or even a single file that's filled with plenty of different and inconsistent code styles is just hard to read or maintain. That's why we wanna make sure everyone follows these simple principles: +Try to stay inline with the code that surrounds you, having an entire package or even a single file that's filled with plenty of different and inconsistent code styles is just hard to read or maintain. That's why we wanna make sure everyone follows these principles. + +*Note that these are just guidelines, we may request changes on your pull request if we think there are changes necessary. +But we won't reject your Pull Request completely due to a few styling inconsistencies, we can always refactor code later. +But do try to follow our code style as best as you can.* #### 1. Imports * Don't use wildcard (`*`) imports! From 359cba3c133cc5e6da2b8748dfaac4925bbca3de Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 8 Oct 2020 14:36:58 +0200 Subject: [PATCH 054/178] [CI skip] Updated changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d06dc74d9..a5f708932 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,11 +36,13 @@ * (API) Added "NotConfigurable" attribute to disable configurability * Added Elytra Cap * Added Planks to Sticks recipe to the Table Saw +* Added "slimefun.gps.bypass" permission to open GPS devices anywhere #### Changes * Improved Auto-Updater (Multi-Threading and more) * General performance improvements * /sf cheat now shows seasonal categories all year through +* GPS devices now require chest-access in that area to be used #### Fixes * Fixed #2300 From 26066f2e6c05103fb12e315177d42bc8763dab97 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 8 Oct 2020 14:45:21 +0200 Subject: [PATCH 055/178] Refactoring --- .../implementation/items/geo/GEOScanner.java | 27 +++++++++++------ .../items/gps/GPSControlPanel.java | 29 ++++++++++++------- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java index c5aacea66..63e61042b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java @@ -1,5 +1,10 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.geo; +import java.util.Optional; + +import javax.annotation.ParametersAreNonnullByDefault; + +import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -23,19 +28,23 @@ public class GEOScanner extends SimpleSlimefunItem { return e -> { e.cancel(); - Block b = e.getClickedBlock().get(); Player p = e.getPlayer(); + Optional block = e.getClickedBlock(); - if (p.hasPermission("slimefun.gps.bypass") - || (SlimefunPlugin.getProtectionManager().hasPermission( - p, b.getLocation(), ProtectableAction.ACCESS_INVENTORIES)) - ) { - - SlimefunPlugin.getGPSNetwork().getResourceManager().scan(p, b, 0); - } else { - SlimefunPlugin.getLocalization().sendMessage(p, "inventory.no-access", true); + if (block.isPresent()) { + Block b = block.get(); + if (hasAccess(p, b.getLocation())) { + SlimefunPlugin.getGPSNetwork().getResourceManager().scan(p, b, 0); + } else { + SlimefunPlugin.getLocalization().sendMessage(p, "inventory.no-access", true); + } } }; } + + @ParametersAreNonnullByDefault + private boolean hasAccess(Player p, Location l) { + return p.hasPermission("slimefun.gps.bypass") || (SlimefunPlugin.getProtectionManager().hasPermission(p, l, ProtectableAction.ACCESS_INVENTORIES)); + } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java index 6fef675a9..27d771eba 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java @@ -1,5 +1,11 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.gps; +import java.util.Optional; + +import javax.annotation.ParametersAreNonnullByDefault; + +import org.bukkit.Location; +import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -19,21 +25,24 @@ public class GPSControlPanel extends SimpleSlimefunItem { @Override public BlockUseHandler getItemHandler() { - return e -> { + return e -> { e.cancel(); Player p = e.getPlayer(); + Optional block = e.getClickedBlock(); - if (p.hasPermission("slimefun.gps.bypass") - || (SlimefunPlugin.getProtectionManager().hasPermission( - p, e.getClickedBlock().get().getLocation(), ProtectableAction.ACCESS_INVENTORIES)) - ) { - - SlimefunPlugin.getGPSNetwork().openTransmitterControlPanel(p); - } else { - SlimefunPlugin.getLocalization().sendMessage(p, "inventory.no-access", true); - + if (block.isPresent()) { + if (hasAccess(p, block.get().getLocation())) { + SlimefunPlugin.getGPSNetwork().openTransmitterControlPanel(p); + } else { + SlimefunPlugin.getLocalization().sendMessage(p, "inventory.no-access", true); + } } }; } + + @ParametersAreNonnullByDefault + private boolean hasAccess(Player p, Location l) { + return p.hasPermission("slimefun.gps.bypass") || (SlimefunPlugin.getProtectionManager().hasPermission(p, l, ProtectableAction.ACCESS_INVENTORIES)); + } } From b5c917f719cdd600950e0303b2a62c036d6545b8 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Thu, 8 Oct 2020 16:00:26 +0300 Subject: [PATCH 056/178] Fixed the lore. --- .../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 f8b33cc4d..4cd441d08 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -750,7 +750,7 @@ public final class SlimefunItems { public static final SlimefunItemStack BLISTERING_INGOT_3 = new SlimefunItemStack("BLISTERING_INGOT_3", Material.GOLD_INGOT, "&6Blistering Ingot", "", LoreBuilder.radioactive(Radioactivity.VERY_HIGH), LoreBuilder.HAZMAT_SUIT_REQUIRED); public static final SlimefunItemStack ENERGY_REGULATOR = new SlimefunItemStack("ENERGY_REGULATOR", HeadTexture.ENERGY_REGULATOR, "&6Energy Regulator", "", "&fCore Component of an Energy Network"); - public static final SlimefunItemStack ENERGY_CONNECTOR = new SlimefunItemStack("ENERGY_CONNECTOR", HeadTexture.CARGO_CONNECTOR_NODE, "&cEnergy Connector", "", "&fCargo Connector Wire"); + public static final SlimefunItemStack ENERGY_CONNECTOR = new SlimefunItemStack("ENERGY_CONNECTOR", HeadTexture.CARGO_CONNECTOR_NODE, "&cEnergy Connector", "", "&fEnergy Connector Wire"); public static final SlimefunItemStack DEBUG_FISH = new SlimefunItemStack("DEBUG_FISH", Material.SALMON, "&3How much is the Fish?", "", "&eRight Click &fany Block to view it's BlockData", "&eLeft Click &fto break a Block", "&eShift + Left Click &fany Block to erase it's BlockData", "&eShift + Right Click &fto place a Placeholder Block"); public static final SlimefunItemStack NETHER_ICE = new SlimefunItemStack("NETHER_ICE", HeadTexture.NETHER_ICE, "&eNether Ice", "", LoreBuilder.radioactive(Radioactivity.MODERATE), LoreBuilder.HAZMAT_SUIT_REQUIRED); From 40caa2d5746c519bddf39f110deb625e9359aeed Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Thu, 8 Oct 2020 16:02:53 +0300 Subject: [PATCH 057/178] Update ResearchSetup.java --- .../slimefun4/implementation/setup/ResearchSetup.java | 1 - 1 file changed, 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 fb3a8dc55..8d733f144 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 @@ -16,7 +16,6 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; * {@link Research} on startup. * * @author TheBusyBiscuit - * @author Every Slimefun4 Contributor (at least those who added an item...) * * @see Research * @see SlimefunItems From 09a40d036e9bba3cb417a772c72327b8666d8340 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Thu, 8 Oct 2020 16:04:01 +0300 Subject: [PATCH 058/178] Update src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java Co-authored-by: TheBusyBiscuit --- .../slimefun4/core/attributes/EnergyNetComponent.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java index f16fd8b53..6d2e1504d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java @@ -66,7 +66,11 @@ public interface EnergyNetComponent extends ItemAttribute { */ default int getCharge(@Nonnull Location l) { Validate.notNull(l, "Location was null!"); - if (!isChargeable()) return 0; + + // Emergency fallback, this cannot hold a charge, so we'll just return zero + if (!isChargeable()) { + return 0; + } String charge = BlockStorage.getLocationInfo(l, "energy-charge"); From 20405a775bfe896f09d8c4793451ae75d254255a Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 8 Oct 2020 18:11:16 +0200 Subject: [PATCH 059/178] [CI skip] Added Imports cleanup action --- .github/workflows/imports-fix.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/imports-fix.yml diff --git a/.github/workflows/imports-fix.yml b/.github/workflows/imports-fix.yml new file mode 100644 index 000000000..152437949 --- /dev/null +++ b/.github/workflows/imports-fix.yml @@ -0,0 +1,30 @@ +name: Clean up Imports + +on: + pull_request: + branches: + - master + paths: + - 'src/main/java/**' + +jobs: + build: + + name: Clean up Imports + runs-on: ubuntu-latest + if: $ {{ secrets.ACCESS_TOKEN }} != null + + steps: + - name: Checkout repository + uses: actions/checkout@v2.3.3 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1.4.3 + with: + java-version: 11 + - name: Clean up Imports + uses: axel-op/googlejavaformat-action@v3.3.2 + with: + files: '**/*.java' + skipCommit: false + args: "--fix-imports-only --replace" + githubToken: $ {{ secrets.ACCESS_TOKEN }} From 6f4802f7b608253408be64dc91a5828623304f71 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 8 Oct 2020 18:33:01 +0200 Subject: [PATCH 060/178] [CI skip] Fixed imports workflow --- .github/workflows/imports-fix.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/imports-fix.yml b/.github/workflows/imports-fix.yml index 152437949..6b19edbd4 100644 --- a/.github/workflows/imports-fix.yml +++ b/.github/workflows/imports-fix.yml @@ -12,7 +12,7 @@ jobs: name: Clean up Imports runs-on: ubuntu-latest - if: $ {{ secrets.ACCESS_TOKEN }} != null + if: github.event.pull_request.base.repo.full_name == 'Slimefun/Slimefun4' steps: - name: Checkout repository @@ -21,10 +21,10 @@ jobs: uses: actions/setup-java@v1.4.3 with: java-version: 11 - - name: Clean up Imports + - name: Google Java Format uses: axel-op/googlejavaformat-action@v3.3.2 with: files: '**/*.java' skipCommit: false args: "--fix-imports-only --replace" - githubToken: $ {{ secrets.ACCESS_TOKEN }} + githubToken: ${{ secrets.ACCESS_TOKEN }} From d891d182b5b10f79b5c8a602a357cf7b5c072f51 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 8 Oct 2020 18:53:19 +0200 Subject: [PATCH 061/178] Intentionally messed up imports --- .../Slimefun/Objects/SlimefunBlockHandler.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunBlockHandler.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunBlockHandler.java index 2fcce02eb..4465a1037 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunBlockHandler.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunBlockHandler.java @@ -1,11 +1,14 @@ package me.mrCookieSlime.Slimefun.Objects; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; import org.bukkit.event.Event; - +import java.lang.annotation.*; +import javax.annotation.Nullable; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; +import org.bukkit.block.*; +import org.bukkit.entity.Player; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason; +import java.lang.Runnable; +import org.bukkit.advancement.Advancement; /** * A {@link SlimefunBlockHandler} handles breaking and placing of blocks. From 5aa6a8b7b1d169af6c6f6cedf77be01b71e58adf Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 8 Oct 2020 19:01:28 +0200 Subject: [PATCH 062/178] Removed github token from imports workflow --- .github/workflows/imports-fix.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/imports-fix.yml b/.github/workflows/imports-fix.yml index 6b19edbd4..d5933c866 100644 --- a/.github/workflows/imports-fix.yml +++ b/.github/workflows/imports-fix.yml @@ -27,4 +27,3 @@ jobs: files: '**/*.java' skipCommit: false args: "--fix-imports-only --replace" - githubToken: ${{ secrets.ACCESS_TOKEN }} From b05977c39b13a6c01b691e43217c69bf426046e4 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 8 Oct 2020 19:04:23 +0200 Subject: [PATCH 063/178] [CI skip] Removed imports workflow --- .github/workflows/imports-fix.yml | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 .github/workflows/imports-fix.yml diff --git a/.github/workflows/imports-fix.yml b/.github/workflows/imports-fix.yml deleted file mode 100644 index 6b19edbd4..000000000 --- a/.github/workflows/imports-fix.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Clean up Imports - -on: - pull_request: - branches: - - master - paths: - - 'src/main/java/**' - -jobs: - build: - - name: Clean up Imports - runs-on: ubuntu-latest - if: github.event.pull_request.base.repo.full_name == 'Slimefun/Slimefun4' - - steps: - - name: Checkout repository - uses: actions/checkout@v2.3.3 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1.4.3 - with: - java-version: 11 - - name: Google Java Format - uses: axel-op/googlejavaformat-action@v3.3.2 - with: - files: '**/*.java' - skipCommit: false - args: "--fix-imports-only --replace" - githubToken: ${{ secrets.ACCESS_TOKEN }} From 8c80ad4040bdbfe7cf8dbd4f6ba1f5df7b4a054a Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 8 Oct 2020 19:05:23 +0200 Subject: [PATCH 064/178] Cleanup --- .github/workflows/imports-fix.yml | 29 ------------------- .../Objects/SlimefunBlockHandler.java | 11 +++---- 2 files changed, 4 insertions(+), 36 deletions(-) delete mode 100644 .github/workflows/imports-fix.yml diff --git a/.github/workflows/imports-fix.yml b/.github/workflows/imports-fix.yml deleted file mode 100644 index d5933c866..000000000 --- a/.github/workflows/imports-fix.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Clean up Imports - -on: - pull_request: - branches: - - master - paths: - - 'src/main/java/**' - -jobs: - build: - - name: Clean up Imports - runs-on: ubuntu-latest - if: github.event.pull_request.base.repo.full_name == 'Slimefun/Slimefun4' - - steps: - - name: Checkout repository - uses: actions/checkout@v2.3.3 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1.4.3 - with: - java-version: 11 - - name: Google Java Format - uses: axel-op/googlejavaformat-action@v3.3.2 - with: - files: '**/*.java' - skipCommit: false - args: "--fix-imports-only --replace" diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunBlockHandler.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunBlockHandler.java index 4465a1037..2fcce02eb 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunBlockHandler.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunBlockHandler.java @@ -1,14 +1,11 @@ package me.mrCookieSlime.Slimefun.Objects; -import org.bukkit.event.Event; -import java.lang.annotation.*; -import javax.annotation.Nullable; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; -import org.bukkit.block.*; +import org.bukkit.block.Block; import org.bukkit.entity.Player; +import org.bukkit.event.Event; + +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason; -import java.lang.Runnable; -import org.bukkit.advancement.Advancement; /** * A {@link SlimefunBlockHandler} handles breaking and placing of blocks. From b2833dc5c0787d978536e7c246b5d85d400502fe Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Thu, 8 Oct 2020 21:42:57 +0300 Subject: [PATCH 065/178] Update MagicalZombiePills.java --- .../implementation/items/magical/MagicalZombiePills.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 b3e96e4d3..5a67191c2 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 @@ -53,10 +53,10 @@ public class MagicalZombiePills extends SimpleSlimefunItem Date: Thu, 8 Oct 2020 21:20:38 +0200 Subject: [PATCH 066/178] [CI skip] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5f708932..0cf0888f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,7 @@ * Fixed #2391 * Fixed #2403 * Fixed #2405 +* Fixed #2412 ## Release Candidate 16 (07 Sep 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 From c440fd0778f4e6d5a9ec5aed0d3d2b32544ff33d Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 9 Oct 2020 12:13:17 +0000 Subject: [PATCH 067/178] Translate messages_ja.yml via GitLocalize --- src/main/resources/languages/messages_ja.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/resources/languages/messages_ja.yml b/src/main/resources/languages/messages_ja.yml index 6c06002da..ec99efcc2 100644 --- a/src/main/resources/languages/messages_ja.yml +++ b/src/main/resources/languages/messages_ja.yml @@ -20,6 +20,10 @@ commands: player-never-joined: "&4その名前のプレイヤーが見つかりません!" backpack-does-not-exist: "&4指定したバックパックは存在しません!" restored-backpack-given: "&aバックパックが返還されました!" + charge: + description: 手に持っているアイテムを充電 + charge-success: アイテムは充電されました! + not-rechargeable: このアイテムは充電できません! guide: search: message: "&b検索ワードをチャットで入力してください" @@ -127,6 +131,7 @@ messages: knight: "&a&oタリスマンが再生効果を付与した" whirlwind: "&a&oタリスマンが飛び道具から身を護った" wizard: "&a&oタリスマンが高レベルの幸運を付与したが、他のエンチャントレベルは下がってしまった" + caveman: "&a&oタリスマンが採掘速度を上昇させた" soulbound-rune: fail: "&c一度に複数アイテムとのバインディングはできません" success: "&aアイテムとのバインディングが確立した!リスポーン時に当該アイテムは手繰り寄せられます" @@ -307,6 +312,7 @@ languages: el: ギリシャ語 he: ヘブライ語 pt: ポルトガル語(ポルトガル) + pt-BR: ポルトガル語(ブラジル) ar: アラビア語 af: アフリカーンス語 da: デンマーク語 @@ -318,7 +324,6 @@ languages: fa: ペルシア語 th: タイ語 ro: ルーマニア語 - pt-BR: ポルトガル語(ブラジル) bg: ブルガリア語 ko: 韓国語 tr: トルコ語 @@ -331,5 +336,7 @@ brewing_stand: not-working: "&4Slimefunアイテムは醸造台で使えません!" villagers: no-trading: "&4Slimefunアイテムは村人との取引に使用できません!" +cartography_table: + not-working: "&4Slimefunアイテムは製図台を使用できません!" miner: no-ores: "&e周辺には鉱石が見つかりませんでした!" From f95a4cfd1c41004af036600705d92f5a46f2ddd6 Mon Sep 17 00:00:00 2001 From: bito-blosh Date: Fri, 9 Oct 2020 12:13:18 +0000 Subject: [PATCH 068/178] Translate messages_ja.yml via GitLocalize From 3e20911c4814e05ee1fd803944702a8b6a5cb0cd Mon Sep 17 00:00:00 2001 From: bito-blosh Date: Fri, 9 Oct 2020 12:13:19 +0000 Subject: [PATCH 069/178] Translate researches_ja.yml via GitLocalize --- src/main/resources/languages/researches_ja.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/resources/languages/researches_ja.yml b/src/main/resources/languages/researches_ja.yml index a926847a3..7b2c59fda 100644 --- a/src/main/resources/languages/researches_ja.yml +++ b/src/main/resources/languages/researches_ja.yml @@ -243,3 +243,6 @@ slimefun: climbing_pick: ブロッククライミング shulker_shell: 合成シュルカー villager_rune: 村人の初期化 + caveman_talisman: 洞窟暮らしのタリスマン + even_higher_tier_capacitors: キャパシタⅢ + elytra_cap: 衝撃緩和装備 From 06272780bfe56620bf652c01aaa9aae6c047a2d6 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 9 Oct 2020 12:16:10 +0000 Subject: [PATCH 070/178] Update dependency com.konghq:unirest-java to v3.11.01 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eba85470d..24209e82e 100644 --- a/pom.xml +++ b/pom.xml @@ -344,7 +344,7 @@ com.konghq unirest-java - 3.11.00 + 3.11.01 compile From bd0f15bc95b2fc53619d562f6eb3d68dcbc3da61 Mon Sep 17 00:00:00 2001 From: poma123 Date: Fri, 9 Oct 2020 14:30:38 +0000 Subject: [PATCH 071/178] Translate messages_hu.yml via GitLocalize --- src/main/resources/languages/messages_hu.yml | 298 ++++++++++--------- 1 file changed, 165 insertions(+), 133 deletions(-) diff --git a/src/main/resources/languages/messages_hu.yml b/src/main/resources/languages/messages_hu.yml index 17adc36d7..7e8d86fa6 100644 --- a/src/main/resources/languages/messages_hu.yml +++ b/src/main/resources/languages/messages_hu.yml @@ -1,28 +1,32 @@ --- commands: help: Megjeleníti ezt a súgóképernyőt - cheat: Lehetővé teszi a Tárgyak csalását - give: Adj valakinek Slimefun Tárgyakat - guide: Adj magadnak egy Slimefun Útmutatót - timings: Lag-Információ a Szerverről - teleporter: Nézd meg a többi Játékos Útpontjait - versions: Az összes telepített Kiegészítőt listázza + cheat: Ezzel lekérhetsz tárgyakat + give: Slimefun tárgyak lekérése egy játékosnak + guide: Slimefun Útmutató lekérése + timings: Lag-információ a szerverről + teleporter: Játékosok útpontjainak megtekintése + versions: A kiegészítők listázása search: Keresés egy kifejezésre az Útmutatóban open_guide: A könyv használata nélkül megnyitja a Slimefun útmutatóját - stats: Néhány statisztikát mutat a Játékosról + stats: Néhány statisztikát mutat egy játékosról research: - description: A játékosok kutatásainak Feloldása/Visszaállítása - reset: "&cVisszaállítottad %player% Ismereteit" + description: A játékosok kutatásainak feloldása/visszaállítása + reset: "&cVisszaállítottad %player% ismereteit" reset-target: "&cAz ismereteidet visszaállították" backpack: description: Lekéri egy meglévő hátizsák másolatát invalid-id: "&4Az azonosító nem lehet negatív szám!" player-never-joined: "&4Nincs ilyen nevű játékos!" backpack-does-not-exist: "&4A megadott hátizsák nem létezik!" - restored-backpack-given: "&aA hátizsákod visszaállítva és hozzáadva a leltáradhoz!" + restored-backpack-given: "&aA hátizsákod visszaállítva és hozzáadva az eszköztáradhoz!" + charge: + description: Feltölti a kezedben lévő tárgyat + charge-success: Tárgy feltöltve! + not-rechargeable: Ez a tárgy nem tölthető fel! guide: search: - message: "&bMit szeretnél keresni?" + message: "&bMire szeretnél keresni?" name: "&7Keresés..." tooltip: "&bKlikk egy tárgy kereséséhez" inventory: 'Keresés erre: %item%' @@ -30,33 +34,46 @@ guide: - "&bMit szeretnél keresni?" - "&7Gépeld be a keresett kifejezést a chatbe" cheat: - no-multiblocks: "&4A Multiblokkban nem tudsz csalni, meg kell építened!" + no-multiblocks: "&4Multiblockot nem tudsz lekérni, meg kell építened!" languages: updated: "&aA nyelvet sikeresen átállítottad erre: &b%lang%" translations: name: "&aHiányzik valami?" - lore: Kattints a saját fordítás hozzáadásához + lore: Kattints saját fordítás hozzáadásához select: Kattints a nyelv kiválasztásához select-default: Kattints az alapértelmezett nyelv kiválasztásához selected-language: 'Jelenleg kiválasztva:' + change: Kattints a nyelv kiválasztásához + description: + - "&7Már lehetőséged van kiválasztani," + - "&7hogy a Slimefun milyen nyelven" + - "&7jelenjen meg számodra. A tárgyakat" + - "&7jelenleg nem lehet lefordítani." title: main: Slimefun Útmutató settings: Beállítások és Információk languages: Válaszd ki a kívánt nyelvet - credits: Slimefun4 Közreműködők + credits: Slimefun4 közreműködők wiki: Slimefun4 Wiki addons: A Slimefun4 kiegészítői bugs: Hibajelentések source: Forráskód + versions: Telepített verziók credits: - commit: Commit - commits: Commits + commit: commit + commits: commits roles: developer: "&6Fejlesztő" - wiki: "&3Wiki Szerkesztő" - resourcepack: "&cForráscsomag Művész" + wiki: "&3Wiki szerkesztő" + resourcepack: "&cForráscsomag művész" translator: "&9Fordító" profile-link: Kattints ide, hogy meglátogasd a profilját a GitHub-on + open: Kattints a közreműködők megtekintéséhez + description: + - "&7A Slimefun egy nyílt forráskódú projekt," + - "&7amit egy hatalmas közösség tart fenn." + - "&7Több mint &e%contributors% &7közreműködő" + - "&7dolgozott rajta az évek során." pages: previous: Előző oldal next: Következő oldal @@ -65,56 +82,57 @@ guide: versions-notice: Ezek nagyon fontosak a hibák jelentésekor! wiki: Tekintsd meg ezt a tárgyat a hivatalos Slimefun Wikin recipes: - machine: Ebben a Gépben készített receptek - miner: Erőforrások, amelyeket ezzel a Bányásszal szerezhetsz be + machine: Ebben a gépben készíthető receptek + miner: Erőforrások, amelyeket ezzel a bányásszal szerezhetsz be generator: Rendelkezésre álló üzemanyagtípusok - gold-pan: Megszerezhető források + gold-pan: Megszerezhető erőforrások + climbing-pick: Megmászható felületek back: title: Vissza - guide: Menj vissza a Slimefun Útmutatóba - settings: Menj vissza a Beállítások Panelre + guide: Visszalépés a Slimefun Útmutatóba + settings: Visszalépés a Beállítások panelre locked: LEZÁRVA locked-category: - Ennek a kategóriának a feloldásához - - fel kell oldanod az összes tárgyat a - - következő kategóriákból + - fel kell oldanod az összes tárgyat + - a következő kategóriákból + work-in-progress: Ez a funkció még nem készült el teljesen! messages: - not-researched: "&4Nincs elég ismereted ennek a megértéséhez" + not-researched: "&4Nincs elég ismereted, hogy megértsd ezt" not-enough-xp: "&4Nincs elég XP-d ennek a feloldásához" unlocked: '&7"%research%" &bfeloldva' - only-players: "&4Ez a parancs csak a Játékosok számára szól" - unknown-player: "&4Ismeretlen Játékos: &c%player%" - no-permission: "&4Nem rendelkezel a szükséges engedélyekkel ehhez" + only-players: "&4Ezt a parancsot csak játékosok használhatják" + unknown-player: "&4Ismeretlen játékos: &c%player%" + no-permission: "&4Ehhez nincs jogod" usage: "&4Használat: &c%usage%" - not-online: "&4%player% &cnincs online!" + not-online: "&4%player% &cjelenleg nem elérhető!" not-valid-item: "&4%item% &cnem megfelelő Tárgy!" - not-valid-amount: "&4%amount% &cnem megfelelő mennyiség : 0-nál nagyobbnak kell - lennie!" - given-item: '&bKaptál &a%amount% &7"%item%&7"&b-t' + not-valid-amount: "&4%amount% &cnem megfelelő mennyiség: 0-nál nagyobbnak kell lennie!" + given-item: '&bKaptál &a%amount% darab &7"%item%&7"&b-t' give-item: '&bAdtál %player%-nek/nak &a%amount% &7"%item%&7"&b-t' not-valid-research: "&4%research% &cnem érvényes Kutatás!" - give-research: '&bAdtál %player%-nek/nak &7"%research%&7" &bKutatást' + give-research: '&bMegadtad %player% játékosnak a(z) &7"%research%&7" &bkutatást' hungry: "&cTúl éhes vagy ehhez!" - mode-change: "&b%device% mód állítva erre: &9%mode%" - disabled-in-world: "&4&lEz a Tárgy tiltva van ebben a világban" - disabled-item: "&4&lEz a Tárgy le van tiltva! Egyáltalán hogyan szerezted?" - no-tome-yourself: "&cNem tudod használni a &4Tome of Knowledge &c-t magadon..." - multimeter: "&bTárolt Energia: &3%stored% &b/ &3%capacity%" + disabled-in-world: "&4&lEz a tárgy tiltva van ebben a világban" + disabled-item: "&4&lEz a tárgy le van tiltva! Egyáltalán hogyan szerezted?" + no-tome-yourself: "&cNem használhatod a &4Tome of Knowledge&c-t magadon..." + multimeter: "&bTárolt energia: &3%stored% &b/ &3%capacity%" talisman: - anvil: "&a&oA Talizmánod megmentette az eszközöd a töréstől" - miner: "&a&oA Talizmánod megduplázta a dobott tárgyakat" - hunter: "&a&oA Talizmánod megduplázta a dobott tárgyakat" - lava: "&a&oA Talizmánod megmentett a halálos égéstől" - water: "&a&oA Talizmánod megmentett a fulladástól" - angel: "&a&oA Talizmánod megmentett a zuhanási sérüléstől" - fire: "&a&oA Talizmánod megmentett a halálra elégéstől" - magician: "&a&oA Talizmánod adott további Fejlesztéseket is" - traveller: "&a&oA Talizmánod Gyors sebességet adott neked" - warrior: "&a&oA Talizmánodtól növelte az Erőd egy kis időre" - knight: "&a&oA Talizmánod adott 5 Másodpercre élet Regenerációt" - whirlwind: "&a&oA Talizmánod visszavert egy Távolsági lövést" - wizard: "&a&oA Talizmánod erősítette a Szerencse Szinjét, de néhány egyéb Fejlesztés - Szint kicsit gyengül" + anvil: "&a&oA talizmánod megmentette az eszközöd az eltöréstől" + miner: "&a&oA talizmánod megduplázta a dobott tárgyakat" + hunter: "&a&oA talizmánod megduplázta a dobott tárgyakat" + lava: "&a&oA talizmánod megmentett a halálos égéstől" + water: "&a&oA talizmánod megmentett a fulladástól" + angel: "&a&oA talizmánod megmentett a zuhanási sérüléstől" + fire: "&a&oA talizmánod megmentett a halálra elégéstől" + magician: "&a&oA talizmánod adott további Fejlesztéseket is" + traveller: "&a&oA talizmánod gyors sebességet adott neked" + warrior: "&a&oA talizmánodtól növelte az erőd egy kis időre" + knight: "&a&oA talizmánod adott 5 másodpercre Regenerációt" + whirlwind: "&a&oA talizmánod visszavert egy lövedéket" + wizard: "&a&oA talizmánod erősítette a Szerencse enchantot, de néhány egyéb enchantot + gyengített" + caveman: "&a&oA talizmánod adott Sietség effektet" soulbound-rune: fail: "&cEgyszerre csak egy tárgyat köthetsz a lelkedhez." success: "&aSikeresen hozzákötötted ezt a tárgyat a lelkedhez! Megmarad, amikor @@ -129,65 +147,73 @@ messages: vagy viselj Hazmat Suit-ot!" opening-guide: "&bÚtmutató megnyitása, ez eltarthat pár másodpercig..." opening-backpack: "&bHátizsák megnyitása, ez eltarthat pár másodpercig..." - no-iron-golem-heal: "&cEz nem egy Vasrúd. Ezt nem használhatod a Vasgólem gyógyítására!" + no-iron-golem-heal: "&cEz nem egy vasrúd. Ezt nem használhatod a vasgólem gyógyítására!" link-prompt: "&eKattints ide:" diet-cookie: "&eNagyon könnyednek érzed magad..." fortune-cookie: - - "&7Segítség, csapdába estem egy Szerencsesüti Gyárban!" + - "&7Segítség, csapdába estem egy szerencsesüti gyárban!" - "&7Holnap meghalsz... egy Creeper által" - "&7Valamikor az életedben valami rossz fog történni!!!" - "&7A következő héten észreveszed, hogy ez nem az igazi világ, hanem egy számítógépes játékban vagy" - - "&7Ez a süti néhány másodperc alatt jó ízű lesz" - - '&7Az utolsó szó, amelyet hallani fogsz, "KIÍRTANI!!!"' + - "&7Ez a süti néhány másodperc múlva jó ízű lesz" + - '&7Az utolsó szó, amelyet hallani fogsz: "KIÍRTANI!!!"' - "&7Bármit is teszel, ne ölelj meg egy Creepert... Kipróbáltam. Jó érzés, de nem éri meg." - "&742. A válasz 42." - "&7Walshy egy nap távol tartja a bajokat." - "&7Soha ne áss egyenesen!" - - "&7Ez csak egy friss sebesülés!" + - "&7Ez csak egy kis karcolás!" - "&7Mindig nézd az élet jó oldalát!" - - "&7Ez valójában Keksz volt, és nem Süti" + - "&7Ez valójában keksz volt, és nem süti" - "&7A neon táblák VILÁGÍTANAK!" - piglin-barter: "&4Slimefun tárgyakat nem cserélhetsz el a Piglinekkel." + piglin-barter: "&4Slimefun tárgyakat nem cserélhetsz el piglinekkel." enchantment-rune: - fail: "&cNem varázsolhatod el ezt a tárgyat." - no-enchantment: "&cNem található megfelelő varázslat ehhez az tárgyhoz." - success: "&aSikeresen alkalmaztál egy véletlenszerű varázslatot erre a tárgyra." + fail: "&cNem enchantolhatod ezt a tárgyat." + no-enchantment: "&cNem található megfelelő enchant ehhez az tárgyhoz." + success: "&aSikeresen alkalmaztál egy véletlenszerű enchantot erre a tárgyra." tape-measure: - no-anchor: "&cBe kell állítanod egy rögzítést, mielőtt megkezdenéd a mérést!" - wrong-world: "&cA rögzítés úgy tűnik egy másik világban van!" + no-anchor: "&cBe kell állítanod egy kezdőpontot, mielőtt megkezdenéd a mérést!" + wrong-world: "&cA kezdőpont úgy tűnik, hogy egy másik világban van!" distance: "&7A mérés megtörtént. &eA távolság: %distance%" - anchor-set: "&aA rögzítés sikeresen beállítva:&e %anchor%" + anchor-set: "&aA kezdőpont sikeresen beállítva:&e %anchor%" + multi-tool: + mode-change: "&b%device% mód átállítva: &9%mode%" + not-shears: "&cA Multi Tool nem használható óllóként!" + climbing-pick: + dual-wielding: "&4Mindkét kezedben Climbing Pick-et kell tartanod, hogy használhasd + őket!" + wrong-material: "&cEzt a felületet nem mászhatod meg. Nyisd meg a Slimefun Útmutatót + további információért!" + mode-change: "&b%device% mód állítva erre: &9%mode%" machines: - pattern-not-found: "&eSajnálom, nem ismerem fel ezt a Receptet. Kérlek, helyezd - a Tárgyakat a megfelelő mintában az Adagolóba." - unknown-material: "&eSajnálom, Nem tudtam felismerni a Tárgyat az adagolóban. Kérlek + pattern-not-found: "&eSajnálom, nem ismerem fel ezt a receptet. Kérlek, helyezd + a tárgyakat a megfelelő mintában az adagolóba." + unknown-material: "&eSajnálom, nem tudtam felismerni a tárgyat az adagolóban. Kérlek tegyél bele valamit, amit ismerek." - wrong-item: "&eSajnálom, nem ismerem fel azt a Tárgyat, amire kattintottál velem. - Ellenőrizd a Recepteket, és nézd meg, mely Tárgyakat használhatod." - full-inventory: "&eSajnálom, tele a tárolóm!" - in-use: "&cEnnek a Blokknak a tárolóját éppen megnyitotta egy másik Játékos." - ignition-chamber-no-flint: "&cA Gyújtókamrából hiányzik a Kovakő és Acél." + wrong-item: "&eSajnálom, nem ismerem fel azt a tárgyat, amire velem kattintottál. + Ellenőrizd a recepteket, és nézd meg, mely tárgyakat használhatod." + full-inventory: "&eSajnálom, tele az eszköztáram!" + in-use: "&cEnnek a blokknak az eszköztárát éppen megnyitotta egy másik játékos." + ignition-chamber-no-flint: "&cAz Ignition Chamber-ből hiányzik a kovakő és acél." ANCIENT_ALTAR: - not-enough-pedestals: "&4Az Oltár körül nincs elég Talapzat, ami szükséges a működéséhez + not-enough-pedestals: "&4Az Altar körül nincs elég Pedestal, ami szükséges a működéséhez &c(%pedestals% / 8)" - unknown-catalyst: "&4Ismeretlen Katalizátor! &cEhelyett használd a helyes Receptet!" - unknown-recipe: "&4Ismeretlen Recept! &cEhelyett használd a helyes Receptet!" + unknown-catalyst: "&4Ismeretlen katalizátor! &cEhelyett használd a helyes receptet!" + unknown-recipe: "&4Ismeretlen recept! &cEhelyett használd a helyes receptet!" ANCIENT_PEDESTAL: - obstructed: "&4A Talapzat el van torlaszolva! &cTávolíts el mindent, ami a talapzat + obstructed: "&4A Pedestal el van torlaszolva! &cTávolíts el mindent, ami a Pedestal felett van!" HOLOGRAM_PROJECTOR: - enter-text: "&7Kérlek, írd be a kívánt Hologram Szöveget a Chatbe. &r(A színkódok + enter-text: "&7Kérlek, írd be a kívánt hologram szöveget a chatre. &r(Színkódok is használhatóak!)" - inventory-title: Hologram Szerkesztő + inventory-title: Hologram szerkesztő ELEVATOR: no-destinations: "&4Nem található úticél" pick-a-floor: "&3- Válassz emeletet -" - current-floor: "&eEz az emelet, amelyen jelenleg tartózkodik:" - click-to-teleport: "&eKattints &7erre az emeletre való teleportáláshoz:" - enter-name: "&7Kérlek írd be a kívánt emelet nevet a Chatbe. &r(A Színkódok is - támogatottak!)" + current-floor: "&eEzen az emeleten tartózkodsz:" + click-to-teleport: "&eKattints&7, hogy erre az emeletre teleportálj:" + enter-name: "&7Kérlek írd be a kívánt emelet nevét a chatre. &r(Színkódok is használhatóak!)" named: "&2Sikeresen elnevezted ezt az emeletet: &r%floor%" TELEPORTER: teleporting: "&3Teleportálás..." @@ -196,79 +222,81 @@ machines: invulnerability: "&b&l30 másodperc Sérthetetlenséget kaptál!" gui: title: Az útpontjaid - tooltip: Klikk a teleportáláshoz + tooltip: Kattints a teleportáláshoz time: Becsült idő CARGO_NODES: must-be-placed: "&4Ládára vagy gépre kell helyezni!" GPS_CONTROL_PANEL: title: GPS - Vezérlőpult - transmitters: Transzmitter Áttekintése - waypoints: Útpont Áttekintése + transmitters: Transzmitter áttekintése + waypoints: Útpont áttekintése INDUSTRIAL_MINER: - no-fuel: "&cAz Ipari Bányászodnak elfogyott az üzemanyaga! Tedd az üzemanyagot - a fenti ládába." - piston-facing: "&cAz Ipari Bányászodhoz szükségesek dugattyúk, amik felfelé néznek!" + no-fuel: "&cAz Industrial Miner-ednek elfogyott az üzemanyaga! Tedd az üzemanyagot + a felette lévő ládába." + piston-facing: "&cAz Industrial Miner-edhez szükségesek dugattyúk, amik felfelé + néznek!" piston-space: "&cA két dugattyú felett egy üres blokknak kell lennie!" - destroyed: "&cÚgy tűnik, hogy az Ipari Bányászod megsemmisült." - already-running: "&cEz az Ipari Bányász már fut!" - full-chest: "&cAz Ipari Bányász ládája tele van!" - no-permission: "&4Úgy tűnik, hogy nincs engedélyed az Ipari Bányász üzemeltetésére + destroyed: "&cÚgy tűnik, hogy az Industrial Miner-ed megsemmisült." + already-running: "&cEz az Industrial Miner már fut!" + full-chest: "&cAz Industrial Miner ládája tele van!" + no-permission: "&4Úgy tűnik, hogy nincs engedélyed Industrial Miner üzemeltetésére itt!" - finished: Az Ipari Bányászod kész! Összesen %ores% ércet szerzett! + finished: Az Industrial Miner-ed kész! Összesen %ores% ércet szerzett! anvil: - not-working: "&4Nem használhatsz Slimefun tárgyakat az Üllőben!" + not-working: "&4Nem használhatsz Slimefun tárgyakat az üllőben!" backpack: - already-open: "&cSajnáljuk, ez a Hátizsák valahol máshol már nyitva van!" - no-stack: "&cNem lehet halmozni a Táskákat" + already-open: "&cSajnáljuk, ez a hátizsák valahol máshol már nyitva van!" + no-stack: "&cNem halmozhatsz hátizsákokat" workbench: - not-enhanced: "&4Nem használhatsz Slimefun Tárgyakat normális barkácsasztalban" + not-enhanced: "&4Nem használhatsz Slimefun tárgyakat barkácsasztalban" gps: - deathpoint: "&4Halálpont &7%date%" + deathpoint: "&4Halálpont: &7%date%" waypoint: - new: "&eKérlek, add meg az új útpontot chatben. &7(A Színkódok használhatóak!)" - added: "&aSikeresen megadtad az útpontot" + new: "&eKérlek írd be az új útpont nevét chatre. &7(Színkódok használhatóak!)" + added: "&aSikeresen létrehoztál egy útpontot" max: "&4Elérted a maximális útpontok számát" + duplicate: "&4Már létrehoztál egy ilyen nevű útpontot: &f%waypoint%" insufficient-complexity: - - "&4Nem megfelelő a GPS Hálózat Komplexitása: &c%complexity%" - - "&4a) Még nem telepítetted a GPS Hálózatot" - - "&4b) A GPS Hálózatod nem eléggé összetett" + - "&4Nem megfelelő a GPS-hálózat komplexitása: &c%complexity%" + - "&4a) Még nem telepítetted a GPS-hálózatot" + - "&4b) A GPS-hálózatod nem eléggé összetett" geo: - scan-required: "&4GEO-Vizsgálat szükséges! &cElőbb vizsgáld meg ezt a chunkot - a GEO-Szkennerrel!" + scan-required: "&4GEO-vizsgálat szükséges! &cElőbb vizsgáld meg ezt a chunkot + a GEO-Scannerrel!" inventory: no-access: "&4Nincs hozzáférésed ehhez a blokkhoz" android: - started: "&7Az Androidod folytatja a szkript futtatását" - stopped: "&7Az Androidod szünetelteti a szkript futtatását" + started: "&7Az androidod folytatja a szkript futtatását" + stopped: "&7Az androidod szünetelteti a szkript futtatását" scripts: already-uploaded: "&4Ezt a szkriptet már feltöltötték." instructions: START: "&2Szkript indítása" REPEAT: "&9Szkript ismétlése" - WAIT: "&eVárjon 0.5s" + WAIT: "&eVárj 5 másodpercet" GO_FORWARD: "&7Menj előre" GO_UP: "&7Menj felfelé" GO_DOWN: "&7Menj lefelé" TURN_LEFT: "&7Fordulj balra" TURN_RIGHT: "&7Fordulj jobbra" - DIG_UP: "&bÁss" + DIG_UP: "&bÁss felfelé" DIG_FORWARD: "&bÁss előre" - DIG_DOWN: "&bÁss le" - MOVE_AND_DIG_UP: "&bMenj és Áss felfelé" - MOVE_AND_DIG_FORWARD: "&bMenj és Áss előre" - MOVE_AND_DIG_DOWN: "&bMenj és Áss lefelé" - ATTACK_MOBS_ANIMALS: "&4Támadj &c(Ellenséges Élőlények és Állatok)" - ATTACK_MOBS: "&4Támadj &c(Ellenséges Élőlények)" - ATTACK_ANIMALS: "&4Támadj &c(Állatok)" - ATTACK_ANIMALS_ADULT: "&4Támadj &c(Állatok &7[Felnőtt]&c)" - CHOP_TREE: "&cVágj és Ültess" - CATCH_FISH: "&bFogj Halat" - FARM_FORWARD: "&bSzüretelj és Ültess" - FARM_DOWN: "&bSzüretelj és Ültess &7(Blokk alatt)" - FARM_EXOTIC_FORWARD: "&bFejlett Szüretelés és Ültetés" - FARM_EXOTIC_DOWN: "&bFejlett Szüretelés és Ültetés &7(Blokk alatt)" - INTERFACE_ITEMS: "&9Tegye az Eszköztár Tartalmát a csatlakozási Felületbe" - INTERFACE_FUEL: "&cVegyen ki az Üzemanyagot a csatlakozási Felületről" + DIG_DOWN: "&bÁss lefelé" + MOVE_AND_DIG_UP: "&bMenj és áss felfelé" + MOVE_AND_DIG_FORWARD: "&bMenj és áss előre" + MOVE_AND_DIG_DOWN: "&bMenj és áss lefelé" + ATTACK_MOBS_ANIMALS: "&4Támadj &c(ellenséges élőlényeket és állatokat)" + ATTACK_MOBS: "&4Támadj &c(ellenséges élőlényeket)" + ATTACK_ANIMALS: "&4Támadj &c(állatokat)" + ATTACK_ANIMALS_ADULT: "&4Támadj &c(&7felnőtt &cállatokat)" + CHOP_TREE: "&cVágj fát és ültess" + CATCH_FISH: "&bFogj halat" + FARM_FORWARD: "&bSzüretelj és ültess" + FARM_DOWN: "&bSzüreteljen és ültessen &7(saját maga alatt)" + FARM_EXOTIC_FORWARD: "&bFejlett szüretelés és ültetés" + FARM_EXOTIC_DOWN: "&bFejlett szüretelés és ültetés &7(saját maga alatt)" + INTERFACE_ITEMS: "&9Tegye az eszköztár tartalmát a csatlakozási felületbe" + INTERFACE_FUEL: "&cVegyen ki az üzemanyagot a csatlakozási felületről" enter-name: - - "&eKérlek, írd be a szkript nevét" @@ -280,7 +308,7 @@ android: already: "&4Ezt a szkriptet már értékelted!" editor: Szkript Szerkesztő languages: - default: Szerver-Alapértelmezett + default: Szerver-alapértelmezett en: Angol de: Német fr: Francia @@ -300,8 +328,9 @@ languages: zh-CN: Kínai (Kína) el: Görög he: Héber + pt-BR: Portugál (Brazília) ar: Arab - af: Afrikánsz + af: Afrikaans da: Dán fi: Finn uk: Ukrán @@ -312,16 +341,19 @@ languages: th: Thai ro: Román pt: Portugál (Portugália) - pt-BR: Portugál (Brazília) bg: Bolgár ko: Koreai tr: Török hr: Horvát - mk: Macedóniai + mk: Macedón sr: Szerb - be: Belorusz + be: Belarusz tl: Tagalog brewing_stand: - not-working: "&4Nem használhatsz Slimefun tárgyakat a Főzőállványban!" + not-working: "&4Nem használhatsz Slimefun tárgyakat főzőállványban!" +villagers: + no-trading: "&4Nem cserélhetsz Slimefun tárgyakat falusiakkal!" +cartography_table: + not-working: "&4Nem használhatsz Slimefun tárgyakat térképasztalban." miner: no-ores: "&eSajnálom, nem találtam semmilyen Ércet a közelben!" From ad36fb857f135627b76928442a506262e23a5f34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Marczink=C3=B3?= Date: Fri, 9 Oct 2020 14:30:39 +0000 Subject: [PATCH 072/178] Translate messages_hu.yml via GitLocalize From 00a7bb447450cfd04b53502bd324eadd92df9657 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 9 Oct 2020 14:30:40 +0000 Subject: [PATCH 073/178] Translate messages_hu.yml via GitLocalize From f3fafaff26e90059b4ae2bb808f2114383c4d6b3 Mon Sep 17 00:00:00 2001 From: poma123 Date: Fri, 9 Oct 2020 14:30:42 +0000 Subject: [PATCH 074/178] Translate categories_hu.yml via GitLocalize --- .../resources/languages/categories_hu.yml | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/resources/languages/categories_hu.yml b/src/main/resources/languages/categories_hu.yml index 812f254a8..1b2345797 100644 --- a/src/main/resources/languages/categories_hu.yml +++ b/src/main/resources/languages/categories_hu.yml @@ -2,25 +2,25 @@ slimefun: weapons: Fegyverek tools: Eszközök - items: Hasznos Tárgyak + items: Hasznos tárgyak food: Étel - basic_machines: Alapvető Gépek - electricity: Energia és Elektromosság - gps: GPS-alapú Gépek + basic_machines: Alapvető gépek + electricity: Energia és elektromosság + gps: GPS-alapú gépek armor: Páncél - magical_items: Varázslatos Tárgyak - magical_gadgets: Varázslatos Kütyük - misc: Egyéb Tárgyak - technical_gadgets: Technikai Kütyük + magical_items: Varázslatos tárgyak + magical_gadgets: Varázslatos kütyük + misc: Egyéb tárgyak + technical_gadgets: Technikai kütyük resources: Erőforrások - cargo: Szállítmány Kezelés - tech_misc: Műszaki Alkatrészek - magical_armor: Varázslatos Páncél - talismans: Talizmánok (I. Szint) - ender_talismans: Ender Talizmánok (II. Szint) + cargo: Szállítmánykezelés + tech_misc: Műszaki alkatrészek + magical_armor: Varázslatos páncél + talismans: Talizmánok (I. szint) + ender_talismans: Ender talizmánok (II. szint) christmas: Karácsony (December) - valentines_day: Valentin Nap (Február 14.) + valentines_day: Valentin nap (Február 14.) easter: Húsvét (Április) birthday: TheBusyBiscuit születésnapja (Október 26.) halloween: Halloween (Október 31.) - androids: Programozható Androidok + androids: Programozható androidok From 5ac0792cb04828494f2e6474e40c6438141cccd8 Mon Sep 17 00:00:00 2001 From: poma123 Date: Fri, 9 Oct 2020 14:30:43 +0000 Subject: [PATCH 075/178] Translate recipes_hu.yml via GitLocalize --- src/main/resources/languages/recipes_hu.yml | 112 ++++++++++---------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/src/main/resources/languages/recipes_hu.yml b/src/main/resources/languages/recipes_hu.yml index 899b0e21f..7fff814b8 100644 --- a/src/main/resources/languages/recipes_hu.yml +++ b/src/main/resources/languages/recipes_hu.yml @@ -8,33 +8,33 @@ slimefun: enhanced_crafting_table: name: Enhanced Crafting Table lore: - - Készítsd el ezt a Tárgyat az ábra alapján + - Készítsd el ezt a tárgyat az ábra alapján - egy Enhanced Crafting Table-ben. - - A normális Barkácsasztal nem lesz elegendő! + - A sima barkácsasztal nem lesz elegendő! armor_forge: name: Armor Forge lore: - - Készítsd el ezt a Tárgyat az ábra alapján + - Készítsd el ezt a tárgyat az ábra alapján - egy Armor Forge segítségével grind_stone: name: Grind Stone lore: - - Készítsd el ezt a Tárgyat az ábra alapján + - Készítsd el ezt a tárgyat az ábra alapján - egy Grind Stone segítségével smeltery: name: Smeltery lore: - - Készítsd el ezt a Tárgyat az ábra alapján + - Készítsd el ezt a tárgyat az ábra alapján - egy Smeltery segítségével ore_crusher: name: Ore Crusher lore: - - Készítsd el ezt a Tárgyat az ábra alapján + - Készítsd el ezt a tárgyat az ábra alapján - egy Ore Crusher segítségével mob_drop: - name: Élőlény Dobja + name: Élőlény dobja lore: - - Öld meg ezt az Élőlényt, + - Öld meg ezt az élőlényt, - hogy megszerezd ezt a tárgyat gold_pan: name: Gold Pan @@ -44,125 +44,125 @@ slimefun: compressor: name: Compressor lore: - - Készítsd el ezt a Tárgyat az ábra alapján + - Készítsd el ezt a tárgyat az ábra alapján - egy Compressor segítségével pressure_chamber: name: Pressure Chamber lore: - - Készítsd el ezt a Tárgyat az ábra alapján + - Készítsd el ezt a tárgyat az ábra alapján - egy Pressure Chamber segítségével ore_washer: name: Ore Washer lore: - - Készítsd el ezt a Tárgyat az ábra alapján + - Készítsd el ezt a tárgyat az ábra alapján - egy Ore Washer segítségével juicer: name: Juicer lore: - - Készítsd el ezt a Gyümölcslevet az ábra alapján + - Készítsd el ezt a gyümölcslevet az ábra alapján - egy Juicer segítségével magic_workbench: name: Magic Workbench lore: - - Készítsd el ezt a Tárgyat az ábra alapján + - Készítsd el ezt a tárgyat az ábra alapján - egy Magic Workbench segítségével ancient_altar: name: Ancient Altar lore: - - Készítsd el ezt a Tárgyat az ábra alapján + - Készítsd el ezt a tárgyat az ábra alapján - egy Ancient Altar segítségével. - Keress utána az Ancient Altar-nak a további információkért heated_pressure_chamber: name: Heated Pressure Chamber lore: - - Készítsd el ezt a Tárgyat az ábra alapján + - Készítsd el ezt a tárgyat az ábra alapján - egy Heated Pressure Chamber segítségével food_fabricator: name: Food Fabricator lore: - - Készítsd el ezt a Tárgyat az ábra alapján + - Készítsd el ezt a tárgyat az ábra alapján - egy Food Fabricator segítségével food_composter: name: Food Composter lore: - - Készítsd el ezt a Tárgyat az ábra alapján - - egy Food Composter segítségével + - Készítsd el ezt a tárgyat az ábra alapján + - egy Food Composter segítségével. freezer: name: Freezer lore: - - Készítsd el ezt a Tárgyat az ábra alapján - - egy Freezer segítségével + - Készítsd el ezt a tárgyat az ábra alapján + - egy Freezer segítségével. geo_miner: name: GEO Miner lore: - Ez a tárgy összegyűjthető - - egy GEO Miner segítségével + - egy GEO Miner segítségével. nuclear_reactor: name: Nuclear Reactor lore: - Ez a tárgy mellékterméke - - a Nuclear Reactor működésének + - a Nuclear Reactor működésének. oil_pump: name: Oil Pump lore: - Ez a tárgy összegyűjthető - - egy Oil Pump segítségével + - egy Oil Pump segítségével. pickaxe_of_containment: name: Pickaxe of Containment lore: - - Ez a blokk megszerezhető - - úgy, hogy egy Spawner-t kibányászol - - a Pickaxe of Containment-tel + - Ez a blokk megszerezhető úgy, + - hogy egy spawnert kibányászol + - a Pickaxe of Containment-tel. refinery: name: Refinery lore: - - Készítsd el ezt a Tárgyat az ábra alapján - - egy Refinery segítségével + - Készítsd el ezt a tárgyat az ábra alapján + - egy Refinery segítségével. barter_drop: - name: Piglinek Dobják Cserélésnél + name: Piglinek dobják cserélésnél lore: - - Cseréld el a Piglenekkel Aranyrudakat, - - hogy megszerezd ezt a tárgyat + - Cserélj el piglenekkel aranyrudakat, + - hogy megszerezd ezt a tárgyat. minecraft: shaped: - name: Barkácsrecept Forma + name: Barkácsrecept forma lore: - - Készítsd el ezt a Tárgyat az ábra alapján - - egy Normális Barkácsasztal segítségével. + - Készítsd el ezt a tárgyat az ábra alapján + - egy sima barkácsasztal segítségével. - A forma fontos. shapeless: - name: Forma Nélküli Barkácsrecept + name: Forma nélküli barkácsrecept lore: - - Készítsd el ezt a Tárgyat az ábra alapján - - egy Normális Barkácsasztal segítségével. - - Ez a Recept forma nélküli. + - Készítsd el ezt a tárgyat az ábra alapján + - egy sima barkácsasztal segítségével. + - Ez a recept forma nélküli. furnace: - name: Kemence Recept + name: Kemence recept lore: - - Olvaszd meg ezt a tárgyat egy Kemencében, - - hogy elkészítsd a kívánt tárgyat + - Olvaszd meg ezt a tárgyat egy kemencében, + - hogy elkészítsd a kívánt tárgyat. blasting: - name: Kohó Recept + name: Kohó recept lore: - - Olvaszd meg ezt a tárgyat egy Kohóban, - - hogy elkészítsd a kívánt tárgyat + - Olvaszd meg ezt a tárgyat egy kohóban, + - hogy elkészítsd a kívánt tárgyat. smoking: - name: Füstölő Recept + name: Füstölő recept lore: - - Olvaszd meg ezt a tárgyat egy Füstölőben, - - hogy elkészítsd a kívánt tárgyat + - Olvaszd meg ezt a tárgyat egy füstölőben, + - hogy elkészítsd a kívánt tárgyat. campfire: - name: Tábortűz Recept + name: Tábortűz recept lore: - - Olvaszd meg ezt a tárgyat egy Tábortűzön, - - hogy elkészítsd a kívánt tárgyat + - Olvaszd meg ezt a tárgyat tábortűzön, + - hogy elkészítsd a kívánt tárgyat. stonecutting: - name: Kővágó Recept + name: Kővágó recept lore: - - Készítsd el ezt a Tárgyat az ábra alapján - - egy Kővágó segítségével + - Készítsd el ezt a tárgyat az ábra alapján + - egy kővágó segítségével. smithing: - name: Kovácsasztal Recept + name: Kovácsasztal recept lore: - - Készítsd el ezt a Tárgyat az ábra alapján - - egy Kovácsasztal segítségével + - Készítsd el ezt a tárgyat az ábra alapján + - egy kovácsasztal segítségével. From e10c3024881e212cdd37468c0c012d9435e63996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Marczink=C3=B3?= Date: Fri, 9 Oct 2020 14:30:44 +0000 Subject: [PATCH 076/178] Translate recipes_hu.yml via GitLocalize From 076f1b51a46f28d30ab530a4aa69730de1475576 Mon Sep 17 00:00:00 2001 From: poma123 Date: Fri, 9 Oct 2020 14:30:45 +0000 Subject: [PATCH 077/178] Translate resources_hu.yml via GitLocalize --- src/main/resources/languages/resources_hu.yml | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/resources/languages/resources_hu.yml b/src/main/resources/languages/resources_hu.yml index 6e46c219d..b90e6cfa6 100644 --- a/src/main/resources/languages/resources_hu.yml +++ b/src/main/resources/languages/resources_hu.yml @@ -1,24 +1,24 @@ --- tooltips: - results: GEO-Vizsgálat Eredmények - chunk: Vizsgált Chunk + results: GEO-vizsgálat eredmények + chunk: Vizsgált chunk world: Világ - unit: Egység - units: Egységek + unit: egység + units: egység resources: slimefun: oil: Olaj - nether_ice: Nether Jég + nether_ice: Nether jég salt: Só uranium: Uránium slimefunorechunks: - iron_ore_chunk: Vasérc Chunk - gold_ore_chunk: Aranyérc Chunk - copper_ore_chunk: Rézérc Chunk - tin_ore_chunk: Ónérc Chunk - silver_ore_chunk: Ezüstérc Chunk - aluminum_ore_chunk: Alumínium Érc Chunk - lead_ore_chunk: Ólomérc Chunk - zinc_ore_chunk: Cinkérc Chunk - nickel_ore_chunk: Nikkelérc Chunk - cobalt_ore_chunk: Kobalt Érc Chunk + iron_ore_chunk: Vasérc chunk + gold_ore_chunk: Aranyérc chunk + copper_ore_chunk: Rézérc chunk + tin_ore_chunk: Ónérc chunk + silver_ore_chunk: Ezüstérc chunk + aluminum_ore_chunk: Alumíniumérc chunk + lead_ore_chunk: Ólomérc chunk + zinc_ore_chunk: Cinkérc chunk + nickel_ore_chunk: Nikkelérc chunk + cobalt_ore_chunk: Kobaltérc Chunk From b7b7fa8a34cc6b4f3b249b5a3328a4a120a96064 Mon Sep 17 00:00:00 2001 From: poma123 Date: Fri, 9 Oct 2020 14:30:47 +0000 Subject: [PATCH 078/178] Translate researches_hu.yml via GitLocalize --- .../resources/languages/researches_hu.yml | 390 +++++++++--------- 1 file changed, 198 insertions(+), 192 deletions(-) diff --git a/src/main/resources/languages/researches_hu.yml b/src/main/resources/languages/researches_hu.yml index 5cfd07494..2715e2184 100644 --- a/src/main/resources/languages/researches_hu.yml +++ b/src/main/resources/languages/researches_hu.yml @@ -1,242 +1,248 @@ --- slimefun: walking_sticks: Sétapálcák - portable_crafter: Hordozható Barkácsoló + portable_crafter: Hordozható barkácsoló fortune_cookie: Szerencsesüti - portable_dustbin: Hordozható Kuka - meat_jerky: Pácolt Hús - armor_forge: Páncél Barkácsolás - glowstone_armor: Izzókő Páncél - lumps: Rögök és Varázslat - ender_backpack: Ender Hátizsák - ender_armor: Ender Páncél - magic_eye_of_ender: Varázslatos Ender Szeme + portable_dustbin: Hordozható szemetes + meat_jerky: Pácolt hús + armor_forge: Páncél barkácsolás + glowstone_armor: Izzókő páncél + lumps: Rögök és varázslat + ender_backpack: Ender hátizsák + ender_armor: Ender páncél + magic_eye_of_ender: Varázslatos Ender szeme magic_sugar: Varázscukor - monster_jerky: Pácolt Szörnyhús - slime_armor: Nyálka Páncél - sword_of_beheading: Lefejezés Kardja - basic_circuit_board: Alapvető Áramköri Lap - advanced_circuit_board: Fejlett Áramköri Lap + monster_jerky: Pácolt szörnyhús + slime_armor: Nyálkás páncél + sword_of_beheading: Lefejezés kardja + basic_circuit_board: Alapvető áramköri lap + advanced_circuit_board: Fejlett áramköri lap smeltery: Kohó steel: Acélkor misc_power_items: Fontos energiával kapcsolatos tárgyak - battery: Az első Akkumulátorod + battery: Az első akkumulátorod steel_plate: Acéllemez steel_thruster: Acélhajtómű parachute: Ejtőernyő grappling_hook: Vasmacska jetpacks: Jetpackek - multitools: Többfunkciós Eszközök + multitools: Többfunkciós eszközök solar_panel_and_helmet: Napenergia - elemental_staff: Elemi Pálcák + elemental_staff: Elemi pálcák grind_stone: Köszörűkő - cactus_armor: Kaktusz Ruha + cactus_armor: Kaktusz ruha gold_pan: Aranymosó - magical_book_cover: Varázslatos Könyvkötés - slimefun_metals: Új Fémek - ore_crusher: Érc Duplázás + magical_book_cover: Varázslatos könyvkötés + slimefun_metals: Új fémek + ore_crusher: Érc duplázás bronze: Bronzkészítés - alloys: Speciális Ötvözetek + alloys: Speciális ötvözetek compressor_and_carbon: Szénkészítés - gilded_iron_armor: Aranyozott Vaspáncél - synthetic_diamond: Szintetikus Gyémántok + gilded_iron_armor: Aranyozott vaspáncél + synthetic_diamond: Szintetikus gyémántok pressure_chamber: Nyomáskamra - synthetic_sapphire: Szintetikus Zafírok - damascus_steel: Damaszkuszi Acél - damascus_steel_armor: Damaszkuszi Acél Páncél - reinforced_alloy: Megerősített Ötvözet - carbonado: Fekete Gyémántok - magic_workbench: Varázslatos Barkácsasztal - wind_staff: Szél Pálca - reinforced_armor: Megerősített Páncél + synthetic_sapphire: Szintetikus zafírok + damascus_steel: Damaszkuszi acél + damascus_steel_armor: Damaszkuszi acélpáncél + reinforced_alloy: Megerősített ötvözet + carbonado: Fekete gyémántok + magic_workbench: Varázslatos barkácsasztal + wind_staff: Szélpálca + reinforced_armor: Megerősített páncél ore_washer: Ércmosó - gold_carats: Tiszta Arany + gold_carats: Színarany silicon: Szilícium-völgy - fire_staff: Tűz Pálca - smelters_pickaxe: Olvasztó Csákány - common_talisman: Gyakori Talizmán - anvil_talisman: Az Üllő Talizmánja - miner_talisman: A Bányász Talizmánja - hunter_talisman: A Vadász Talizmánja - lava_talisman: A Láva Járó Talizmánja - water_talisman: A Vízlélegzés Talizmánja - angel_talisman: Az Angyal Talizmánja - fire_talisman: A Tűzoltó Talizmánja - lava_crystal: Tüzes Helyzet - magician_talisman: A Bűvész Talizmánja - traveller_talisman: Az Utazó Talizmánja - warrior_talisman: A Harcos Talizmánja - knight_talisman: A Lovag Talizmánja - gilded_iron: Fényes Vas - synthetic_emerald: Hamis Drágakő - chainmail_armor: Lánc Páncél - whirlwind_talisman: A Forgószél Talizmánja - wizard_talisman: A Varázsló Talizmánja - lumber_axe: Fadöntő Fejsze - hazmat_suit: Vegyvédelmi Ruha + fire_staff: Tűzpálca + smelters_pickaxe: Olvasztó csákány + common_talisman: Gyakori talizmán + anvil_talisman: Az Üllő talizmánja + miner_talisman: A Bányász talizmánja + hunter_talisman: A Vadász talizmánja + lava_talisman: A Lávajáró talizmánja + water_talisman: A Vízlélegzés talizmánja + angel_talisman: Az Angyal talizmánja + fire_talisman: A Tűzoltó talizmánja + lava_crystal: Tüzes helyzet + magician_talisman: A Bűvész talizmánja + traveller_talisman: Az Utazó talizmánja + warrior_talisman: A Harcos talizmánja + knight_talisman: A Lovag talizmánja + gilded_iron: Fényes vas + synthetic_emerald: Hamis drágakő + chainmail_armor: Láncpáncél + whirlwind_talisman: A Forgószél talizmánja + wizard_talisman: A Varázsló talizmánja + lumber_axe: Fadöntő fejsze + hazmat_suit: Vegyvédelmi ruha uranium: Radioaktív - crushed_ore: Ércek Tisztítása - redstone_alloy: Redstone Ötvözet - carbonado_tools: Felső Szintű Gépek + crushed_ore: Ércek tisztítása + redstone_alloy: Redstone ötvözet + carbonado_tools: Magasszintű gépek first_aid: Elsősegély - gold_armor: Fényes Páncél - night_vision_googles: Éjjellátó Szemüvegek - pickaxe_of_containment: Csomagtartó Csákány - hercules_pickaxe: Herkules Csákány - table_saw: Asztali Fűrész - slime_steel_armor: Nyálkás Acél Páncél - blade_of_vampires: Vámpírok Pengéje - water_staff: Víz Pálca + gold_armor: Fényes páncél + night_vision_googles: Éjjellátó szemüvegek + pickaxe_of_containment: Csomagtartó csákány + hercules_pickaxe: Herkules csákány + table_saw: Asztali fűrész + slime_steel_armor: Nyálkás acélpáncél + blade_of_vampires: Vámpírok pengéje + water_staff: Vízpálca 24k_gold_block: Aranyváros - composter: Föld Komposztáló - farmer_shoes: Farmer Cipők + composter: Föld komposztáló + farmer_shoes: Farmer cipők explosive_tools: Robbanóeszközök - automated_panning_machine: Automatizált Aranymosó - boots_of_the_stomper: A Taposás Cipője - pickaxe_of_the_seeker: A Kutatók Csákánya + automated_panning_machine: Automatizált aranymosó + boots_of_the_stomper: A Taposás cipője + pickaxe_of_the_seeker: A Kutatók csákánya backpacks: Hátizsákok - woven_backpack: Szőtt Hátizsák + woven_backpack: Szőtt hátizsák crucible: Olvasztótégely - gilded_backpack: Aranyozott Hátizsák - armored_jetpack: Páncélozott Jetpack - ender_talismans: Ender Talizmánok - nickel_and_cobalt: Még több Érc - magnet: Mágneses Fémek - infused_magnet: Infúziós Mágnesek - cobalt_pickaxe: Gyors Csákány + gilded_backpack: Aranyozott hátizsák + armored_jetpack: Páncélozott jetpack + ender_talismans: Ender talizmánok + nickel_and_cobalt: Még több érc + magnet: Mágneses fémek + infused_magnet: Infúziós mágnesek + cobalt_pickaxe: Gyors csákány essence_of_afterlife: Szellemidézés - bound_backpack: Lélekhez Kötött Tárolás - jetboots: Sugárhajtású Csizma - armored_jetboots: Páncélozott Sugárhajtású Csizmák - seismic_axe: Szeizmikus Fejsze - pickaxe_of_vein_mining: 'Ér Bányász Csákány ' - bound_weapons: Lélekhez Kötött Fegyverek - bound_tools: Lélélekhez Kötött Eszközök - bound_armor: Lélekhez Kötött Páncél - juicer: Ízletes Italok - repaired_spawner: Spawnerek Javítása - enhanced_furnace: Továbbfejlesztett Kemence - more_enhanced_furnaces: Jobb Kemencék - high_tier_enhanced_furnaces: Magas Szintű Kemence - reinforced_furnace: Megerősített Kemence - carbonado_furnace: Karbonádó Szélű Kemence + bound_backpack: Lélekhez kötött tárolás + jetboots: Sugárhajtású csizma + armored_jetboots: Páncélozott sugárhajtású csizmák + seismic_axe: Szeizmikus fejsze + pickaxe_of_vein_mining: 'Ércbányász csákány ' + bound_weapons: Lélekhez kötött fegyverek + bound_tools: Lélekhez kötött eszközök + bound_armor: Lélekhez kötött páncél + juicer: Ízletes italok + repaired_spawner: Spawnerek javítása + enhanced_furnace: Továbbfejlesztett kemence + more_enhanced_furnaces: Jobb kemencék + high_tier_enhanced_furnaces: Magasszintű kemence + reinforced_furnace: Megerősített kemence + carbonado_furnace: Karbonádó élű kemence electric_motor: Felmelegítés - block_placer: Blokk Lehelyező - scroll_of_dimensional_teleposition: Megfordítva a dolgokat + block_placer: Blokk lehelyező + scroll_of_dimensional_teleposition: Megfordítja a dolgokat special_bows: Robin Hood - tome_of_knowledge_sharing: Megosztás a barátokkal - flask_of_knowledge: XP Tároló - hardened_glass: Robbanások Ellen - golden_apple_juice: Arany Főzet - cooler: Hordozható Italok - ancient_altar: Ősi Oltár - wither_proof_obsidian: Wither-Védett Obszidián - ancient_runes: Elemi Rúnák - special_runes: Lila Rúnák - infernal_bonemeal: Pokoli Csontliszt - rainbow_blocks: Szivárvány Blokkok - infused_hopper: Pokoli Tölcsér - wither_proof_glass: Wither-Védett Üveg - duct_tape: Szövetbetétes Ragasztószalag + tome_of_knowledge_sharing: Megosztás barátokkal + flask_of_knowledge: XP-tároló + hardened_glass: Robbanások ellen + golden_apple_juice: Aranyfőzet + cooler: Hordozható italok + ancient_altar: Ősi oltár + wither_proof_obsidian: Wither-biztos obszidián + ancient_runes: Elemi rúnák + special_runes: Lila rúnák + infernal_bonemeal: Pokoli csontliszt + rainbow_blocks: Szivárvány blokkok + infused_hopper: Infúziós tölcsér + wither_proof_glass: Wither-biztos üveg + duct_tape: Ragasztószalag plastic_sheet: Műanyag android_memory_core: Memóriamag oil: Olaj fuel: Üzemanyag hologram_projector: Hologramok - capacitors: 1. Szintű Kondenzátorok - high_tier_capacitors: 2. Szintű Kondenzátorok - solar_generators: Napenergia Erőmű - electric_furnaces: Erős Kemence - electric_ore_grinding: Zúzás és Őrlés - heated_pressure_chamber: Fűtött Nyomáskamra + capacitors: 1. szintű kondenzátorok + high_tier_capacitors: 2. szintű kondenzátorok + solar_generators: Napenergia-erőmű + electric_furnaces: Elektromos kemence + electric_ore_grinding: Zúzás és őrlés + heated_pressure_chamber: Fűtött nyomáskamra coal_generator: Széngenerátor bio_reactor: Bioreaktor - auto_enchanting: Automatikus Fejlesztés és Fejlesztés Törlés - auto_anvil: Automatikus Üllő + auto_enchanting: Automatikus enchantolás és enchant levétel + auto_anvil: Automatikus üllő multimeter: Teljesítménymérés - gps_setup: Alapvető GPS Beállítás - gps_emergency_transmitter: GPS Vészhelyzeti Útpont - programmable_androids: Programozható Androidok - android_interfaces: Android Csatlakozási Felületek - geo_scanner: GEO-Vizsgálatok + gps_setup: Alapvető GPS-beállítás + gps_emergency_transmitter: Vészhelyzeti GPS-útpont + programmable_androids: Programozható androidok + android_interfaces: Android csatlakozási felületek + geo_scanner: GEO-vizsgálatok combustion_reactor: Égésreaktor - teleporter: Teleportáló Alapelemek - teleporter_activation_plates: Teleportáló Aktiválás - better_solar_generators: Továbbfejlesztett Napelemes Generátorok - better_gps_transmitters: Továbbfejlesztett Transzmitterek + teleporter: Teleportálás alapösszetevői + teleporter_activation_plates: Teleportálás aktiválása + better_solar_generators: Továbbfejlesztett napelemes generátorok + better_gps_transmitters: Továbbfejlesztett transzmitterek elevator: Liftek - energized_solar_generator: Teljes-Munkaidős Napenergia - energized_gps_transmitter: Legfelső Szintű Transzmitter + energized_solar_generator: Folyamatos napenergia + energized_gps_transmitter: Magasszintű transzmitter energy_regulator: Energiahálózatok 101 - butcher_androids: Hentes Androidok + butcher_androids: Hentes androidok organic_food: Bioélelmiszerek - auto_breeder: Automatizált Etetés - advanced_android: Speciális Androidok - advanced_butcher_android: Fejlett Androidok - Hentes - advanced_fisherman_android: Fejlett Androidok - Halász - animal_growth_accelerator: Az állatok Növekedésének Manipulálása - xp_collector: XP Gyűjtő - organic_fertilizer: Organikus Trágya - crop_growth_accelerator: Növény Növekedés Gyorsító - better_crop_growth_accelerator: Továbbfejlesztett Növény Növekedés Gyorsító - reactor_essentials: Reaktor Alapjai + auto_breeder: Automatizált etetés + advanced_android: Fejlett androidok + advanced_butcher_android: Fejlett androidok - Hentes + advanced_fisherman_android: Fejlett androidok - Halász + animal_growth_accelerator: Az állatok növekedésének manipulálása + xp_collector: XP-gyűjtő + organic_fertilizer: Organikus trágya + crop_growth_accelerator: Növény növekedés gyorsító + better_crop_growth_accelerator: Továbbfejlesztett növény növekedés gyorsító + reactor_essentials: Reaktor alapjai nuclear_reactor: Atomerőmű freezer: Fagyasztó Úr - cargo_basics: Szállítmány Alapjai - cargo_nodes: Szállítmány Beállítása - electric_ingot_machines: Elektromos Öntvénygyártás - high_tier_electric_ingot_machines: Szupergyors Öntvénygyártás - automated_crafting_chamber: Automatizált Barkácsolás - better_food_fabricator: Továbbfejlesztett Élelmiszergyártás - reactor_access_port: Reaktor Kölcsönhatás - fluid_pump: Folyadék Szivattyú - better_freezer: Továbbfejlesztett Fagyasztó - boosted_uranium: Soha Véget Nem Érő Kör + cargo_basics: Szállítmánykezelés alapjai + cargo_nodes: Szállítmánykezelés beállítása + electric_ingot_machines: Elektromos öntvénygyártás + high_tier_electric_ingot_machines: Szupergyors öntvénygyártás + automated_crafting_chamber: Automatizált barkácsolás + better_food_fabricator: Továbbfejlesztett élelmiszergyártás + reactor_access_port: Reaktor hozzáférés + fluid_pump: Folyadék szivattyú + better_freezer: Továbbfejlesztett fagyasztó + boosted_uranium: Soha véget nem érő kör trash_can: Szemetes - advanced_output_node: Speciális Kimeneti Csomópont + advanced_output_node: Speciális kimeneti csomópont carbon_press: Szénprés - electric_smeltery: Elektromos Olvasztó - better_electric_furnace: Továbbfejlesztett Elektromos Kemence - better_carbon_press: Továbbfejlesztett Szénprés - empowered_android: Felhatalmazott Androidok - empowered_butcher_android: Felhatalmazott Androidok - Hentes - empowered_fisherman_android: Felhatalmazott Androidok - Halász - high_tier_carbon_press: Végleges Szénprés - wither_assembler: Automatizált Wither Ölő - better_heated_pressure_chamber: Továbbfejlesztett Fűtött Nyomású Kamra + electric_smeltery: Elektromos olvasztó + better_electric_furnace: Továbbfejlesztett elektromos kemence + better_carbon_press: Továbbfejlesztett szénprés + empowered_android: Fejlesztett androidok + empowered_butcher_android: Fejlesztett androidok - Hentes + empowered_fisherman_android: Fejlesztett androidok - Halász + high_tier_carbon_press: Legmagasabb szintű szénprés + wither_assembler: Automatizált wither ölő + better_heated_pressure_chamber: Továbbfejlesztett fűtött nyomáskamra elytra: Kitinszárnyak - special_elytras: Speciális Kitinszárnyak - electric_crucible: Elektromos Olvasztótégely - better_electric_crucibles: Forró Olvasztótégelyek - advanced_electric_smeltery: Fejlett Elektromos Olvasztómű - advanced_farmer_android: Fejlett Androidok - Farmer + special_elytras: Speciális kitinszárnyak + electric_crucible: Elektromos olvasztótégely + better_electric_crucibles: Forró olvasztótégelyek + advanced_electric_smeltery: Fejlett elektromos olvasztómű + advanced_farmer_android: Fejlesztett androidok - Farmer lava_generator: Lávagenerátor - nether_ice: Nether Jéghűtő - nether_star_reactor: Nethercsillag Reaktor - blistering_ingots: Hólyagos Radioaktivitás - automatic_ignition_chamber: Automatikus Gyújtókamra - output_chest: Alapvető Gépek Kimeneti Láda - copper_wire: Hígított Vezetőképesség - radiant_backpack: Sugárzó Hátizsák - auto_drier: Egy Száraz Nap - diet_cookie: Diétás Süti - storm_staff: Vihar Pálca - soulbound_rune: Lélekhez Kötött Rúna - geo_miner: GEO-Bányász - lightning_rune: Villám Rúna - totem_of_undying: Életmentés Toteme + nether_ice: Netherjég hűtő + nether_star_reactor: Nethercsillag reaktor + blistering_ingots: Hólyagos radioaktivitás + automatic_ignition_chamber: Automatikus gyújtókamra + output_chest: Alapvető gépek kimeneti láda + copper_wire: Hígított vezetőképesség + radiant_backpack: Sugárzó hátizsák + auto_drier: Egy száraz nap + diet_cookie: Diétás süti + storm_staff: Viharpálca + soulbound_rune: Lélekhez kötött rúna + geo_miner: GEO-bányász + lightning_rune: Villám rúna + totem_of_undying: Életmentés toteme charging_bench: Töltőpad - nether_gold_pan: Nether Aranymosó - electric_press: Elektromos Prés - magnesium_generator: Energia Magnéziumból - kelp_cookie: Ízletes Moszat - makeshift_smeltery: Improvizált Olvasztó - tree_growth_accelerator: Gyorsabb Fák - industrial_miner: Ipari Bányászat - advanced_industrial_miner: Jobb Bányászat - magical_zombie_pills: Zombi Átváltoztató - auto_brewer: Ipari Sörgyár - enchantment_rune: Ősi Varázslat - lead_clothing: Ólom Ruházat + nether_gold_pan: Nether aranymosó + electric_press: Elektromos prés + magnesium_generator: Energia magnéziumból + kelp_cookie: Ízletes hínár + makeshift_smeltery: Improvizált olvasztó + tree_growth_accelerator: Gyorsabb fák + industrial_miner: Ipari bányászat + advanced_industrial_miner: Jobb bányászat + magical_zombie_pills: Zombi átváltoztató + auto_brewer: Ipari sörgyár + enchantment_rune: Ősi enchantolás + lead_clothing: Ólom ruházat tape_measure: Mérőszalag - iron_golem_assembler: Automatizált Vasgólemek + iron_golem_assembler: Automatizált vasgólemek + climbing_pick: Block Raider + shulker_shell: Szintetikus shulkerek + villager_rune: Falusiak alaphelyzetbe állítása + caveman_talisman: Az Ősember talizmánja + even_higher_tier_capacitors: 3. szintű kondenzátorok + elytra_cap: Ütközésvédelem From 72f7441a188e6b027d5ecaeee3fe388a709326e8 Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Fri, 9 Oct 2020 16:36:25 +0200 Subject: [PATCH 079/178] Small fixes --- src/main/resources/languages/messages_hu.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/languages/messages_hu.yml b/src/main/resources/languages/messages_hu.yml index 7e8d86fa6..8320c757b 100644 --- a/src/main/resources/languages/messages_hu.yml +++ b/src/main/resources/languages/messages_hu.yml @@ -106,7 +106,7 @@ messages: no-permission: "&4Ehhez nincs jogod" usage: "&4Használat: &c%usage%" not-online: "&4%player% &cjelenleg nem elérhető!" - not-valid-item: "&4%item% &cnem megfelelő Tárgy!" + not-valid-item: "&4%item% &cnem megfelelő tárgy!" not-valid-amount: "&4%amount% &cnem megfelelő mennyiség: 0-nál nagyobbnak kell lennie!" given-item: '&bKaptál &a%amount% darab &7"%item%&7"&b-t' give-item: '&bAdtál %player%-nek/nak &a%amount% &7"%item%&7"&b-t' @@ -125,7 +125,7 @@ messages: water: "&a&oA talizmánod megmentett a fulladástól" angel: "&a&oA talizmánod megmentett a zuhanási sérüléstől" fire: "&a&oA talizmánod megmentett a halálra elégéstől" - magician: "&a&oA talizmánod adott további Fejlesztéseket is" + magician: "&a&oA talizmánod adott további fejlesztéseket is" traveller: "&a&oA talizmánod gyors sebességet adott neked" warrior: "&a&oA talizmánodtól növelte az erőd egy kis időre" knight: "&a&oA talizmánod adott 5 másodpercre Regenerációt" @@ -356,4 +356,4 @@ villagers: cartography_table: not-working: "&4Nem használhatsz Slimefun tárgyakat térképasztalban." miner: - no-ores: "&eSajnálom, nem találtam semmilyen Ércet a közelben!" + no-ores: "&eSajnálom, nem találtam semmilyen ércet a közelben!" From 7e3866a25bfb7e877cd38a9d775470f8b3deec36 Mon Sep 17 00:00:00 2001 From: LinoxGH Date: Fri, 9 Oct 2020 14:48:12 +0000 Subject: [PATCH 080/178] Translate messages_tr.yml via GitLocalize --- src/main/resources/languages/messages_tr.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/resources/languages/messages_tr.yml b/src/main/resources/languages/messages_tr.yml index 6a7326245..b919a99d0 100644 --- a/src/main/resources/languages/messages_tr.yml +++ b/src/main/resources/languages/messages_tr.yml @@ -22,6 +22,10 @@ commands: player-never-joined: "&4Bu adda bir oyuncu bulunamadı!" backpack-does-not-exist: "&4Böyle bir sırt çantası yok." restored-backpack-given: "&aSırt çantanız bulundu ve envanterinize teslim edildi!" + charge: + description: Elinizdeki eşyayı şarj eder + charge-success: Eşyanız şarz edildi! + not-rechargeable: Bu eşya şarz edilemez! guide: search: message: "&bNe aramak istersiniz?" @@ -130,6 +134,7 @@ messages: whirlwind: "&a&oTılsımın Mermiyi yansıttı" wizard: "&a&oTılsımın sana daha yüksek seviye Servet verdi ama başka bir Büyünün seviyesini düşürmüş olabilir." + caveman: "&a&oTılsımın sana acele efekti verdi" soulbound-rune: fail: "&cBir seferde sadece bir eşyayı ruhuna bağlayabilirsin." success: "&aBu eşyayı ruhuna başarıyla bağladın! Öldüğünde saklayacaksın." @@ -346,5 +351,7 @@ brewing_stand: not-working: "&4Slimefun eşyalarını simya standında kullanamazsın!" villagers: no-trading: "&4Köylülerle Slimefun eşyalarını kullanarak ticaret yapamazsın!" +cartography_table: + not-working: "&4Slimefun eşyalarını bir haritacılık masasında kullanamazsın!" miner: no-ores: "&eÜzgünüm, yakınlarda herhangi bir cevher bulamadım!" From 26d46c2dc93db37e473f146503f7bc3ec1d1acd7 Mon Sep 17 00:00:00 2001 From: LinoxGH Date: Fri, 9 Oct 2020 14:48:14 +0000 Subject: [PATCH 081/178] Translate researches_tr.yml via GitLocalize --- src/main/resources/languages/researches_tr.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/resources/languages/researches_tr.yml b/src/main/resources/languages/researches_tr.yml index 7a2febfc9..cb141f0e2 100644 --- a/src/main/resources/languages/researches_tr.yml +++ b/src/main/resources/languages/researches_tr.yml @@ -243,3 +243,6 @@ slimefun: climbing_pick: Blok Raider shulker_shell: Sentetik Shulkerlar villager_rune: Sıfır Köylü Ticareti + caveman_talisman: Mağara Adamı Tılsımı + even_higher_tier_capacitors: Seviye 3 Kapasitörler + elytra_cap: İniş Takımı From 3767839310e9903c15ed75e8e40031d5c6ea5beb Mon Sep 17 00:00:00 2001 From: LinoxGH Date: Fri, 9 Oct 2020 14:48:15 +0000 Subject: [PATCH 082/178] Translate recipes_tr.yml via GitLocalize From 83e8010e2968a0fdec521ec02b60689214e42f65 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 9 Oct 2020 17:39:21 +0200 Subject: [PATCH 083/178] Lots of refactoring --- CHANGELOG.md | 1 + .../api/items/settings/IntRangeSetting.java | 52 +++++++++++++ .../items/settings/MaterialTagSetting.java | 76 +++++++++++++++++++ .../api/items/settings/package-info.java | 4 + .../items/blocks/BlockPlacer.java | 7 +- .../implementation/items/food/MeatJerky.java | 3 +- .../items/magical/TelepositionScroll.java | 3 +- .../magical/talismans/MagicianTalisman.java | 1 + .../items/misc/BasicCircuitBoard.java | 3 +- .../items/misc/StrangeNetherGoo.java | 3 +- .../items/multiblocks/Smeltery.java | 3 +- .../items/tools/ClimbingPick.java | 1 + .../items/tools/GrapplingHook.java | 3 +- .../items/tools/PickaxeOfTheSeeker.java | 46 ++++++++--- .../items/tools/PickaxeOfVeinMining.java | 11 +-- .../items/tools/SmeltersPickaxe.java | 18 ++++- .../items/weapons/ExplosiveBow.java | 14 +--- .../items/weapons/SwordOfBeheading.java | 11 +-- .../items/weapons/VampireBlade.java | 3 +- .../listeners/TalismanListener.java | 2 +- .../tools => settings}/ClimbableSurface.java | 5 +- .../TalismanEnchantment.java | 8 +- .../implementation/settings/package-info.java | 6 ++ .../slimefun4/utils/tags/SlimefunTag.java | 13 ++++ .../slimefun4/utils/tags/TagParser.java | 2 + 25 files changed, 248 insertions(+), 51 deletions(-) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/MaterialTagSetting.java create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/package-info.java rename src/main/java/io/github/thebusybiscuit/slimefun4/implementation/{items/tools => settings}/ClimbableSurface.java (88%) rename src/main/java/io/github/thebusybiscuit/slimefun4/implementation/{items/magical/talismans => settings}/TalismanEnchantment.java (79%) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/package-info.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 4202a6342..a34f86b17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ * Added Planks to Sticks recipe to the Table Saw * Added "slimefun.gps.bypass" permission to open GPS devices anywhere * (API) Added custom tags for developers +* The range of the Seeker Pickaxe is now configurable #### Changes * Improved Auto-Updater (Multi-Threading and more) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java new file mode 100644 index 000000000..3f62e355c --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java @@ -0,0 +1,52 @@ +package io.github.thebusybiscuit.slimefun4.api.items.settings; + +import javax.annotation.ParametersAreNonnullByDefault; + +import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; + +/** + * This variation of {@link ItemSetting} allows you to define an {@link Integer} range + * and enforces this range using the {@link #validateInput(Integer)} method. + * + * @author TheBusyBiscuit + * + * @see ItemSetting + * + */ +public class IntRangeSetting extends ItemSetting { + + private final int min; + private final int max; + + @ParametersAreNonnullByDefault + public IntRangeSetting(String key, int min, int defaultValue, int max) { + super(key, defaultValue); + + this.min = min; + this.max = max; + } + + @Override + public boolean validateInput(Integer input) { + return super.validateInput(input) && input >= min && input <= max; + } + + /** + * This returns the minimum value of this {@link IntRangeSetting}. + * + * @return The minimum value + */ + public int getMinimum() { + return min; + } + + /** + * This returns the maximum value of this {@link IntRangeSetting}. + * + * @return The maximum value + */ + public int getMaximum() { + return max; + } + +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/MaterialTagSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/MaterialTagSetting.java new file mode 100644 index 000000000..b229fa9b4 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/MaterialTagSetting.java @@ -0,0 +1,76 @@ +package io.github.thebusybiscuit.slimefun4.api.items.settings; + +import java.util.List; +import java.util.stream.Collectors; + +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + +import org.bukkit.Material; +import org.bukkit.Tag; + +import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; + +/** + * This variation of {@link ItemSetting} allows you to define a default {@link Tag}. + * The {@link Tag} will be translated into a {@link String} {@link List} which the user + * can then configure as they wish. + * + * It also validates all inputs to be a valid {@link Material}. + * + * @author TheBusyBiscuit + * + * @see ItemSetting + * + */ +public class MaterialTagSetting extends ItemSetting> { + + private final Tag defaultTag; + + @ParametersAreNonnullByDefault + public MaterialTagSetting(String key, Tag defaultTag) { + super(key, getAsStringList(defaultTag)); + + this.defaultTag = defaultTag; + } + + /** + * This {@link Tag} holds the default values for this {@link MaterialTagSetting}. + * + * @return The default {@link Tag} + */ + @Nonnull + public Tag getDefaultTag() { + return defaultTag; + } + + @Override + public boolean validateInput(List input) { + if (input != null) { + for (String value : input) { + Material material = Material.matchMaterial(value); + + // This value is not a valid material, the setting is not valid. + if (material == null) { + return false; + } + } + + return true; + } else { + return false; + } + } + + /** + * Internal method to turn a {@link Tag} into a {@link List} of {@link String Strings}. + * + * @param tag + * Our {@link Tag} + * @return The {@link String} {@link List} + */ + private static List getAsStringList(Tag tag) { + return tag.getValues().stream().map(Material::name).collect(Collectors.toList()); + } + +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/package-info.java new file mode 100644 index 000000000..2f6bea34c --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/package-info.java @@ -0,0 +1,4 @@ +/** + * This package contains various sub classes of {@link io.github.thebusybiscuit.slimefun4.api.items.ItemSetting}. + */ +package io.github.thebusybiscuit.slimefun4.api.items.settings; \ No newline at end of file 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 effaf7aa9..2bf0fbbea 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 @@ -2,7 +2,6 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.blocks; import java.util.List; import java.util.UUID; -import java.util.stream.Collectors; import org.bukkit.Bukkit; import org.bukkit.Effect; @@ -21,6 +20,7 @@ import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.api.items.settings.MaterialTagSetting; import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockDispenseHandler; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; @@ -47,7 +47,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; */ public class BlockPlacer extends SlimefunItem { - private final ItemSetting> blacklist = new ItemSetting<>("unplaceable-blocks", SlimefunTag.UNBREAKABLE_MATERIALS.stream().map(Material::name).collect(Collectors.toList())); + private final ItemSetting> blacklist = new MaterialTagSetting("unplaceable-blocks", SlimefunTag.UNBREAKABLE_MATERIALS); public BlockPlacer(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); @@ -88,7 +88,8 @@ public class BlockPlacer extends SlimefunItem { if (!material.isBlock() || SlimefunTag.BLOCK_PLACER_IGNORED_MATERIALS.isTagged(material)) { // Some materials cannot be reliably placed, like beds, it would look - // kinda wonky, so we just ignore these altogether + // kinda wonky, so we just ignore these altogether. + // The event has already been cancelled too, so they won't drop. return; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MeatJerky.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MeatJerky.java index a0e935e5d..9cd6a1ba2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MeatJerky.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MeatJerky.java @@ -3,6 +3,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.food; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; import me.mrCookieSlime.Slimefun.Lists.RecipeType; @@ -20,7 +21,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; */ public class MeatJerky extends SimpleSlimefunItem { - private final ItemSetting saturation = new ItemSetting<>("saturation-level", 6); + private final ItemSetting saturation = new IntRangeSetting("saturation-level", 0, 6, Integer.MAX_VALUE); public MeatJerky(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/magical/TelepositionScroll.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/TelepositionScroll.java index be4d3ed4f..38b97d90b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/TelepositionScroll.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/TelepositionScroll.java @@ -7,6 +7,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; import me.mrCookieSlime.Slimefun.Lists.RecipeType; @@ -24,7 +25,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; */ public class TelepositionScroll extends SimpleSlimefunItem { - private final ItemSetting radius = new ItemSetting<>("radius", 10); + private final ItemSetting radius = new IntRangeSetting("radius", 1, 10, Integer.MAX_VALUE); public TelepositionScroll(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/magical/talismans/MagicianTalisman.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/MagicianTalisman.java index 9e17b1619..29a819f04 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/MagicianTalisman.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/MagicianTalisman.java @@ -12,6 +12,7 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.implementation.settings.TalismanEnchantment; import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/BasicCircuitBoard.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/BasicCircuitBoard.java index ee6d4420a..0adf206d2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/BasicCircuitBoard.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/BasicCircuitBoard.java @@ -4,6 +4,7 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; import io.github.thebusybiscuit.slimefun4.core.attributes.RandomMobDrop; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; @@ -15,7 +16,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class BasicCircuitBoard extends SimpleSlimefunItem implements NotPlaceable, RandomMobDrop { private final ItemSetting dropSetting = new ItemSetting<>("drop-from-golems", true); - private final ItemSetting chance = new ItemSetting<>("golem-drop-chance", 75); + private final ItemSetting chance = new IntRangeSetting("golem-drop-chance", 0, 75, 100); public BasicCircuitBoard(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/misc/StrangeNetherGoo.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java index eb6aa7716..2782308cb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Piglin; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; import io.github.thebusybiscuit.slimefun4.core.attributes.PiglinBarterDrop; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.VillagerRune; import me.mrCookieSlime.Slimefun.Lists.RecipeType; @@ -23,7 +24,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; */ public class StrangeNetherGoo extends SlimefunItem implements PiglinBarterDrop { - private final ItemSetting chance = new ItemSetting<>("barter-chance", 7); + private final ItemSetting chance = new IntRangeSetting("barter-chance", 0, 7, 100); public StrangeNetherGoo(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/multiblocks/Smeltery.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java index e5a0c8d01..0d447e193 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java @@ -23,6 +23,7 @@ import org.bukkit.inventory.meta.ItemMeta; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.papermc.lib.PaperLib; @@ -33,7 +34,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class Smeltery extends AbstractSmeltery { private final BlockFace[] faces = { BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST }; - private final ItemSetting fireBreakingChance = new ItemSetting<>("fire-breaking-chance", 34); + private final ItemSetting fireBreakingChance = new IntRangeSetting("fire-breaking-chance", 0, 34, 100); public Smeltery(Category category, SlimefunItemStack item) { super(category, item, new ItemStack[] { null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.NETHER_BRICKS), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.NETHER_BRICKS), null, new ItemStack(Material.FLINT_AND_STEEL), null }, BlockFace.DOWN); 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 283193fd6..9ea82ab86 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 @@ -34,6 +34,7 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun4.implementation.settings.ClimbableSurface; import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; 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 8b521ecdd..a29be2471 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 @@ -16,6 +16,7 @@ import org.bukkit.util.Vector; import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; @@ -38,7 +39,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class GrapplingHook extends SimpleSlimefunItem { private final ItemSetting consumeOnUse = new ItemSetting<>("consume-on-use", true); - private final ItemSetting despawnTicks = new ItemSetting<>("despawn-seconds", 60); + private final ItemSetting despawnTicks = new IntRangeSetting("despawn-seconds", 0, 60, Integer.MAX_VALUE); @ParametersAreNonnullByDefault public GrapplingHook(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfTheSeeker.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfTheSeeker.java index d3d1d33a1..7f88a3f5a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfTheSeeker.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfTheSeeker.java @@ -1,12 +1,17 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.tools; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.Event.Result; import org.bukkit.inventory.ItemStack; +import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; @@ -16,10 +21,21 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; +/** + * The {@link PickaxeOfTheSeeker} will make you face the nearest ore upon right clicking. + * + * @author TheBusyBiscuit + * + */ public class PickaxeOfTheSeeker extends SimpleSlimefunItem implements DamageableItem { + private final ItemSetting maxRange = new IntRangeSetting("max-range", 1, 5, Integer.MAX_VALUE); + + @ParametersAreNonnullByDefault public PickaxeOfTheSeeker(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); + + addItemSetting(maxRange); } @Override @@ -43,23 +59,35 @@ public class PickaxeOfTheSeeker extends SimpleSlimefunItem imple float yaw = alpha2 > 90 ? (180 - alpha1) : alpha1; float pitch = (float) ((-Math.atan((closest.getY() - 0.5 - p.getLocation().getY()) / Math.sqrt(l * l + w * w))) * 180 / Math.PI); - p.teleport(new Location(p.getWorld(), p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ(), yaw, pitch)); + // We could teleport them asynchronously here... + // But we're only changing the pitch and yaw anyway. + Location loc = new Location(p.getWorld(), p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ(), yaw, pitch); + p.teleport(loc); } damageItem(p, e.getItem()); }; } - private Block findClosestOre(Player p) { + @Nullable + private Block findClosestOre(@Nonnull Player p) { + Block start = p.getLocation().getBlock(); Block closest = null; + double lastDistance = Double.MAX_VALUE; + int range = maxRange.getValue(); - for (int x = -4; x <= 4; x++) { - for (int y = -4; y <= 4; y++) { - for (int z = -4; z <= 4; z++) { - Material type = p.getLocation().add(x, y, z).getBlock().getType(); + for (int x = -range; x <= range; x++) { + for (int y = -range; y <= range; y++) { + for (int z = -range; z <= range; z++) { + Block block = start.getRelative(x, y, z); - if (SlimefunTag.PICKAXE_OF_THE_SEEKER_BLOCKS.isTagged(type) && (closest == null || p.getLocation().distanceSquared(closest.getLocation()) > p.getLocation().distanceSquared(p.getLocation().add(x, y, z)))) { - closest = p.getLocation().getBlock().getRelative(x, y, z); + if (SlimefunTag.PICKAXE_OF_THE_SEEKER_BLOCKS.isTagged(block.getType())) { + double distance = block.getLocation().distanceSquared(start.getLocation()); + + if (closest == null || distance < lastDistance) { + closest = block; + lastDistance = distance; + } } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java index 2543d6589..bad2ca71a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java @@ -15,6 +15,7 @@ import io.github.thebusybiscuit.cscorelib2.blocks.Vein; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; @@ -33,15 +34,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; */ public class PickaxeOfVeinMining extends SimpleSlimefunItem { - private final ItemSetting maxBlocks = new ItemSetting("max-blocks", 16) { - - @Override - public boolean validateInput(Integer input) { - // We do not wanna allow any negative values here - return super.validateInput(input) && input.intValue() > 0; - } - - }; + private final ItemSetting maxBlocks = new IntRangeSetting("max-blocks", 1, 16, Integer.MAX_VALUE); @ParametersAreNonnullByDefault public PickaxeOfVeinMining(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/SmeltersPickaxe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/SmeltersPickaxe.java index 88934823e..cd3ea1999 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/SmeltersPickaxe.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/SmeltersPickaxe.java @@ -3,6 +3,8 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.tools; import java.util.Collection; import java.util.Optional; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.block.Block; @@ -18,8 +20,15 @@ import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; +/** + * The {@link SmeltersPickaxe} automatically smelts any ore you mine. + * + * @author TheBusyBiscuit + * + */ public class SmeltersPickaxe extends SimpleSlimefunItem implements DamageableItem { + @ParametersAreNonnullByDefault public SmeltersPickaxe(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); } @@ -27,12 +36,14 @@ public class SmeltersPickaxe extends SimpleSlimefunItem implemen @Override public ToolUseHandler getItemHandler() { return (e, tool, fortune, drops) -> { - if (SlimefunTag.SMELTERS_PICKAXE_BLOCKS.isTagged(e.getBlock().getType()) && !BlockStorage.hasBlockInfo(e.getBlock())) { - Collection blockDrops = e.getBlock().getDrops(getItem()); + Block b = e.getBlock(); + + if (SlimefunTag.SMELTERS_PICKAXE_BLOCKS.isTagged(b.getType()) && !BlockStorage.hasBlockInfo(b)) { + Collection blockDrops = b.getDrops(getItem()); for (ItemStack drop : blockDrops) { if (drop != null && drop.getType() != Material.AIR) { - smelt(e.getBlock(), drop, fortune); + smelt(b, drop, fortune); drops.add(drop); } } @@ -42,6 +53,7 @@ public class SmeltersPickaxe extends SimpleSlimefunItem implemen }; } + @ParametersAreNonnullByDefault private void smelt(Block b, ItemStack drop, int fortune) { Optional furnaceOutput = SlimefunPlugin.getMinecraftRecipeService().getFurnaceOutput(drop); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/ExplosiveBow.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/ExplosiveBow.java index ac1b31420..e73b78ea3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/ExplosiveBow.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/ExplosiveBow.java @@ -1,5 +1,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.weapons; +import java.util.Collection; + import org.bukkit.Bukkit; import org.bukkit.Particle; import org.bukkit.Sound; @@ -11,12 +13,11 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; import io.github.thebusybiscuit.slimefun4.core.handlers.BowShootHandler; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; -import java.util.Collection; - /** * The {@link ExplosiveBow} is a {@link SlimefunBow} which creates a fake explosion when it hits * a {@link LivingEntity}. Any nearby {@link LivingEntity LivingEntities} get pushed away and @@ -30,14 +31,7 @@ import java.util.Collection; */ public class ExplosiveBow extends SlimefunBow { - private final ItemSetting range = new ItemSetting("explosion-range", 3) { - - @Override - public boolean validateInput(Integer input) { - return super.validateInput(input) && input > 0; - } - - }; + private final ItemSetting range = new IntRangeSetting("explosion-range", 1, 3, Integer.MAX_VALUE); public ExplosiveBow(Category category, SlimefunItemStack item, ItemStack[] recipe) { super(category, item, recipe); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java index 905e0ce24..9f2d14170 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java @@ -14,6 +14,7 @@ import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.SkullMeta; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; import io.github.thebusybiscuit.slimefun4.core.handlers.EntityKillHandler; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; import me.mrCookieSlime.Slimefun.Lists.RecipeType; @@ -22,11 +23,11 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class SwordOfBeheading extends SimpleSlimefunItem { - private final ItemSetting chanceZombie = new ItemSetting<>("chance.ZOMBIE", 40); - private final ItemSetting chanceSkeleton = new ItemSetting<>("chance.SKELETON", 40); - private final ItemSetting chanceWitherSkeleton = new ItemSetting<>("chance.WITHER_SKELETON", 25); - private final ItemSetting chanceCreeper = new ItemSetting<>("chance.CREEPER", 40); - private final ItemSetting chancePlayer = new ItemSetting<>("chance.PLAYER", 70); + private final ItemSetting chanceZombie = new IntRangeSetting("chance.ZOMBIE", 0, 40, 100); + private final ItemSetting chanceSkeleton = new IntRangeSetting("chance.SKELETON", 0, 40, 100); + private final ItemSetting chanceWitherSkeleton = new IntRangeSetting("chance.WITHER_SKELETON", 0, 25, 100); + private final ItemSetting chanceCreeper = new IntRangeSetting("chance.CREEPER", 0, 40, 100); + private final ItemSetting chancePlayer = new IntRangeSetting("chance.PLAYER", 0, 70, 100); public SwordOfBeheading(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/weapons/VampireBlade.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/VampireBlade.java index 72d101fa6..f31bd37bd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/VampireBlade.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/VampireBlade.java @@ -7,6 +7,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; import io.github.thebusybiscuit.slimefun4.implementation.listeners.VampireBladeListener; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; @@ -25,7 +26,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class VampireBlade extends SlimefunItem { private static final double HEALING_AMOUNT = 4.0; - private final ItemSetting chance = new ItemSetting<>("chance", 45); + private final ItemSetting chance = new IntRangeSetting("chance", 0, 45, 100); public VampireBlade(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); 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 ef2ba35a5..531bf9206 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,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; 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 io.github.thebusybiscuit.slimefun4.implementation.settings.TalismanEnchantment; import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; public class TalismanListener implements Listener { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbableSurface.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/ClimbableSurface.java similarity index 88% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbableSurface.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/ClimbableSurface.java index cf3ed08a4..a430001e3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbableSurface.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/ClimbableSurface.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.tools; +package io.github.thebusybiscuit.slimefun4.implementation.settings; import javax.annotation.Nonnull; @@ -6,6 +6,7 @@ import org.bukkit.Material; import io.github.thebusybiscuit.slimefun4.api.events.ClimbingPickLaunchEvent; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ClimbingPick; /** * This is an {@link ItemSetting} @@ -48,4 +49,4 @@ public class ClimbableSurface extends ItemSetting { return type; } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/TalismanEnchantment.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/TalismanEnchantment.java similarity index 79% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/TalismanEnchantment.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/TalismanEnchantment.java index 4e3041790..74681d9c6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/TalismanEnchantment.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/TalismanEnchantment.java @@ -1,8 +1,11 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans; +package io.github.thebusybiscuit.slimefun4.implementation.settings; + +import javax.annotation.Nonnull; import org.bukkit.enchantments.Enchantment; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans.MagicianTalisman; import io.github.thebusybiscuit.slimefun4.implementation.listeners.TalismanListener; /** @@ -17,7 +20,7 @@ public class TalismanEnchantment extends ItemSetting { private final Enchantment enchantment; private final int level; - public TalismanEnchantment(Enchantment enchantment, int level) { + public TalismanEnchantment(@Nonnull Enchantment enchantment, int level) { super("allow-enchantments." + enchantment.getKey().getKey() + ".level." + level, true); this.enchantment = enchantment; @@ -29,6 +32,7 @@ public class TalismanEnchantment extends ItemSetting { * * @return The associated {@link Enchantment} */ + @Nonnull public Enchantment getEnchantment() { return enchantment; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/package-info.java new file mode 100644 index 000000000..1b0af3d46 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/package-info.java @@ -0,0 +1,6 @@ +/** + * This package holds implementations of {@link io.github.thebusybiscuit.slimefun4.api.items.ItemSetting} that are for + * very specific {@link me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem SlimefunItems} and generally not + * very useful out of their context. + */ +package io.github.thebusybiscuit.slimefun4.implementation.settings; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java index b63251da7..c5bf0556e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java @@ -36,6 +36,8 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.tools.SmeltersPic * and follow Minecraft's tags.json format. * * @author TheBusyBiscuit + * + * @see TagParser * */ public enum SlimefunTag implements Tag { @@ -214,6 +216,17 @@ public enum SlimefunTag implements Tag { }); } + /** + * This method reloads every single {@link SlimefunTag} from the resources directory. + * It is equivalent to running {@link #reload()} on every single {@link SlimefunTag} manually. + * + * Do keep in mind though that any misconfigured {@link SlimefunTag} will abort the entire + * method and throw a {@link TagMisconfigurationException}. So one faulty {@link SlimefunTag} + * will stop the reloading process. + * + * @throws TagMisconfigurationException + * This is thrown if one of the {@link SlimefunTag SlimefunTags} could not be parsed correctly + */ public static void reloadAll() throws TagMisconfigurationException { for (SlimefunTag tag : valuesCache) { tag.reload(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java index aee7dcbfc..766f4edb2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java @@ -35,6 +35,8 @@ import io.github.thebusybiscuit.slimefun4.utils.PatternUtils; * The {@link TagParser} is responsible for parsing a JSON input into a {@link SlimefunTag}. * * @author TheBusyBiscuit + * + * @see SlimefunTag * */ public class TagParser implements Keyed { From 72d3d243940b75aaa7e72ef3464f40b5abfe55b6 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 9 Oct 2020 17:44:15 +0200 Subject: [PATCH 084/178] Two annotations! --- .../slimefun4/api/items/settings/MaterialTagSetting.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/MaterialTagSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/MaterialTagSetting.java index b229fa9b4..cddaa8af6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/MaterialTagSetting.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/MaterialTagSetting.java @@ -69,7 +69,8 @@ public class MaterialTagSetting extends ItemSetting> { * Our {@link Tag} * @return The {@link String} {@link List} */ - private static List getAsStringList(Tag tag) { + @Nonnull + private static List getAsStringList(@Nonnull Tag tag) { return tag.getValues().stream().map(Material::name).collect(Collectors.toList()); } From ab1dc5733698e9b3b91b49874a3862d16e4d419a Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 9 Oct 2020 20:42:26 +0200 Subject: [PATCH 085/178] [CI skip] trying out this workflow again --- .github/workflows/imports.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/imports.yml diff --git a/.github/workflows/imports.yml b/.github/workflows/imports.yml new file mode 100644 index 000000000..9bb3a0fa9 --- /dev/null +++ b/.github/workflows/imports.yml @@ -0,0 +1,29 @@ +name: Clean up Imports + +on: + push: + paths: + - 'src/main/java/**' + +jobs: + cleanup: + + name: Clean up Imports + runs-on: ubuntu-latest + if: github.event.pull_request.base.repo.full_name != 'Slimefun/Slimefun4' + + steps: + - name: Checkout repository + uses: actions/checkout@v2.3.3 + - name: Set up Java JDK 11 + uses: actions/setup-java@v1.4.3 + with: + java-version: 11 + - name: Google Java Format + uses: axel-op/googlejavaformat-action@v3.4.0 + with: + files: '**/*.java' + skipCommit: false + commitMessage: "[CI skip] Cleaned up Imports" + args: "--fix-imports-only --replace" + githubToken: ${{ secrets.GITHUB_TOKEN }} From 7cf01a5b926bc100c0a09f5b7266b10fbf66d510 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 9 Oct 2020 20:49:10 +0200 Subject: [PATCH 086/178] [CI skip] Nope --- .github/workflows/imports.yml | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 .github/workflows/imports.yml diff --git a/.github/workflows/imports.yml b/.github/workflows/imports.yml deleted file mode 100644 index 9bb3a0fa9..000000000 --- a/.github/workflows/imports.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Clean up Imports - -on: - push: - paths: - - 'src/main/java/**' - -jobs: - cleanup: - - name: Clean up Imports - runs-on: ubuntu-latest - if: github.event.pull_request.base.repo.full_name != 'Slimefun/Slimefun4' - - steps: - - name: Checkout repository - uses: actions/checkout@v2.3.3 - - name: Set up Java JDK 11 - uses: actions/setup-java@v1.4.3 - with: - java-version: 11 - - name: Google Java Format - uses: axel-op/googlejavaformat-action@v3.4.0 - with: - files: '**/*.java' - skipCommit: false - commitMessage: "[CI skip] Cleaned up Imports" - args: "--fix-imports-only --replace" - githubToken: ${{ secrets.GITHUB_TOKEN }} From 47bcee9d652f84a9b8269e8a79cc9f9b339a8c1c Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 10 Oct 2020 01:28:43 +0200 Subject: [PATCH 087/178] [CI skip] URL checks are now push-only --- .github/workflows/url-checker.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/url-checker.yml b/.github/workflows/url-checker.yml index e0e150008..523248f00 100644 --- a/.github/workflows/url-checker.yml +++ b/.github/workflows/url-checker.yml @@ -4,9 +4,6 @@ on: push: branches: - master - pull_request: - branches: - - master jobs: build: From cf6add1149571b6d3e0d32c3499afdd5ffb7c2f9 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 10 Oct 2020 13:36:07 +0200 Subject: [PATCH 088/178] Some small improvements before the merge --- .../slimefun4/implementation/SlimefunPlugin.java | 2 +- .../tags/block_placer_ignored_materials.json | 15 ++++++++++++--- .../tags/crop_growth_accelerator_blocks.json | 11 ++++++++++- 3 files changed, 23 insertions(+), 5 deletions(-) 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 c98640a32..b2656d623 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java @@ -498,7 +498,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { try { tag.reload(); } catch (TagMisconfigurationException e) { - getLogger().log(Level.SEVERE, "Failed to load a Tag!", e); + getLogger().log(Level.SEVERE, e, () -> "Failed to load Tag: " + tag.name()); } } } diff --git a/src/main/resources/tags/block_placer_ignored_materials.json b/src/main/resources/tags/block_placer_ignored_materials.json index 5c3f4c887..a41e8050e 100644 --- a/src/main/resources/tags/block_placer_ignored_materials.json +++ b/src/main/resources/tags/block_placer_ignored_materials.json @@ -2,9 +2,18 @@ "values" : [ "#slimefun:sensitive_materials", "#slimefun:mushrooms", - "#minecraft:tall_flowers", - "#minecraft:beds", - "#minecraft:doors", + { + "id" : "#minecraft:tall_flowers", + "required" : false + }, + { + "id" : "#minecraft:beds", + "required" : false + }, + { + "id" : "#minecraft:doors", + "required" : false + }, "minecraft:sugar_cane", "minecraft:lily_pad", "minecraft:dead_bush", diff --git a/src/main/resources/tags/crop_growth_accelerator_blocks.json b/src/main/resources/tags/crop_growth_accelerator_blocks.json index 7d858380a..97af19e67 100644 --- a/src/main/resources/tags/crop_growth_accelerator_blocks.json +++ b/src/main/resources/tags/crop_growth_accelerator_blocks.json @@ -1,6 +1,15 @@ { "values" : [ - "#minecraft:crops", + { + "id" : "#minecraft:crops", + "required" : false + }, + "minecraft:beetroots", + "minecraft:carrots", + "minecraft:potatoes", + "minecraft:wheat", + "minecraft:melon_stem", + "minecraft:pumpkin_stem", "minecraft:nether_wart", "minecraft:cocoa", { From f895adde61beb75c7db9b5a905c6c8221326719a Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 10 Oct 2020 14:17:05 +0200 Subject: [PATCH 089/178] [CI skip] Reduced technical debt --- .../TagMisconfigurationException.java | 14 +++++++++++ .../slimefun4/api/geo/ResourceManager.java | 8 +++++-- .../slimefun4/api/gps/GPSNetwork.java | 8 +++++-- .../api/gps/TeleportationManager.java | 3 ++- .../electric/machines/AutoDisenchanter.java | 10 ++++---- .../setup/SlimefunItemSetup.java | 5 ---- .../slimefun4/utils/NumberUtils.java | 23 ++++++++++++++----- .../slimefun4/utils/SlimefunUtils.java | 19 +++++++-------- .../slimefun4/utils/tags/SlimefunTag.java | 6 +++-- .../slimefun4/utils/tags/TagParser.java | 7 +++--- 10 files changed, 66 insertions(+), 37 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/TagMisconfigurationException.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/TagMisconfigurationException.java index 332031986..165f5c3be 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/TagMisconfigurationException.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/TagMisconfigurationException.java @@ -31,4 +31,18 @@ public class TagMisconfigurationException extends Exception { super("Tag '" + key + "' has been misconfigured: " + message); } + /** + * This constructs a new {@link TagMisconfigurationException} for the given + * {@link SlimefunTag}'s {@link NamespacedKey} with the provided context. + * + * @param key + * The {@link NamespacedKey} of our {@link SlimefunTag} + * @param cause + * The {@link Throwable} which has caused this to happen + */ + @ParametersAreNonnullByDefault + public TagMisconfigurationException(NamespacedKey key, Throwable cause) { + super("Tag '" + key + "' has been misconfigured (" + cause.getMessage() + ')', cause); + } + } 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 b8fcbc218..81eb79474 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 @@ -201,15 +201,19 @@ public class ResourceManager { menu.addItem(47, ChestMenuUtils.getPreviousButton(p, page + 1, pages)); menu.addMenuClickHandler(47, (pl, slot, item, action) -> { - if (page > 0) + if (page > 0) { scan(pl, block, page - 1); + } + return false; }); menu.addItem(51, ChestMenuUtils.getNextButton(p, page + 1, pages)); menu.addMenuClickHandler(51, (pl, slot, item, action) -> { - if (page + 1 < pages) + if (page + 1 < pages) { scan(pl, block, page + 1); + } + return false; }); 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 1e7d7e311..649a0ea48 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 @@ -148,10 +148,12 @@ public class GPSNetwork { int index = 0; for (Location l : getTransmitters(p.getUniqueId())) { - if (index >= inventory.length) + if (index >= inventory.length) { break; + } SlimefunItem sfi = BlockStorage.check(l); + if (sfi instanceof GPSTransmitter) { int slot = inventory[index]; @@ -216,8 +218,10 @@ public class GPSNetwork { int index = 0; for (Waypoint waypoint : profile.getWaypoints()) { - if (index >= inventory.length) + if (index >= inventory.length) { break; + } + int slot = inventory[index]; Location l = waypoint.getLocation(); 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 e81bcf6a4..eb0ee827a 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 @@ -92,8 +92,9 @@ public final class TeleportationManager { @ParametersAreNonnullByDefault public int getTeleportationTime(int complexity, Location source, Location destination) { - if (complexity < 100) + if (complexity < 100) { return 100; + } int speed = 50_000 + complexity * complexity; return 1 + Math.min(4 * distanceSquared(source, destination) / speed, 40); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDisenchanter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDisenchanter.java index c61241b64..f023a42ac 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDisenchanter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDisenchanter.java @@ -5,6 +5,8 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import javax.annotation.Nullable; + import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; @@ -144,18 +146,16 @@ public class AutoDisenchanter extends AContainer { book.setItemMeta(meta); } - private boolean isDisenchantable(ItemStack item) { + private boolean isDisenchantable(@Nullable ItemStack item) { if (item == null) { return false; - } - // stops endless checks of getByItem for books - else if (item.getType() != Material.BOOK) { + } else if (item.getType() != Material.BOOK) { + // ^ This stops endless checks of getByItem for books SlimefunItem sfItem = SlimefunItem.getByItem(item); return sfItem == null || sfItem.isDisenchantable(); } else { return true; } - } @Override 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 2ce593999..840ef13f5 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 @@ -1986,11 +1986,6 @@ public final class SlimefunItemSetup { new AutoDrier(categories.electricity, SlimefunItems.AUTO_DRIER, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[]{null, null, null, SlimefunItems.HEATING_COIL, new ItemStack(Material.SMOKER), SlimefunItems.HEATING_COIL, null, new ItemStack(Material.CAMPFIRE), null}) .register(plugin); - } - else { - new AutoDrier(categories.electricity, SlimefunItems.AUTO_DRIER, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[]{null, null, null, SlimefunItems.HEATING_COIL, new ItemStack(Material.FURNACE), SlimefunItems.HEATING_COIL, null, new ItemStack(Material.TORCH), null}) - .register(plugin); } new AutoBrewer(categories.electricity, SlimefunItems.AUTO_BREWER, RecipeType.ENHANCED_CRAFTING_TABLE, diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/NumberUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/NumberUtils.java index 445937f94..a84293946 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/NumberUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/NumberUtils.java @@ -27,19 +27,30 @@ public final class NumberUtils { return LocalDateTime.parse(date.substring(0, date.length() - 1)); } + /** + * This will return a representative color for the given percentage. + * Lower levels will result in a darker tone of red, higher levels will + * result in more brighter shades of green. + * + * @param percentage + * The amount of percentage as a float + * + * @return A representative {@link ChatColor} + */ public static ChatColor getColorFromPercentage(float percentage) { - if (percentage < 16.0F) + if (percentage < 16.0F) { return ChatColor.DARK_RED; - else if (percentage < 32.0F) + } else if (percentage < 32.0F) { return ChatColor.RED; - else if (percentage < 48.0F) + } else if (percentage < 48.0F) { return ChatColor.GOLD; - else if (percentage < 64.0F) + } else if (percentage < 64.0F) { return ChatColor.YELLOW; - else if (percentage < 80.0F) + } else if (percentage < 80.0F) { return ChatColor.DARK_GREEN; - else + } else { return ChatColor.GREEN; + } } public static String getElapsedTime(@Nonnull LocalDateTime date) { 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 19936524b..7b13a3535 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java @@ -250,20 +250,17 @@ public final class SlimefunUtils { } public static boolean isItemSimilar(@Nullable ItemStack item, @Nullable ItemStack sfitem, boolean checkLore, boolean checkAmount) { - if (item == null) + if (item == null) { return sfitem == null; - if (sfitem == null) + } else if (sfitem == null) { return false; - if (item.getType() != sfitem.getType()) + } else if (item.getType() != sfitem.getType()) { return false; - if (checkAmount && item.getAmount() < sfitem.getAmount()) + } else if (checkAmount && item.getAmount() < sfitem.getAmount()) { return false; - - if (sfitem instanceof SlimefunItemStack && item instanceof SlimefunItemStack) { + } else if (sfitem instanceof SlimefunItemStack && item instanceof SlimefunItemStack) { return ((SlimefunItemStack) item).getItemId().equals(((SlimefunItemStack) sfitem).getItemId()); - } - - if (item.hasItemMeta()) { + } else if (item.hasItemMeta()) { ItemMeta itemMeta = item.getItemMeta(); if (sfitem instanceof SlimefunItemStack) { @@ -277,12 +274,12 @@ public final class SlimefunUtils { return equalsItemMeta(itemMeta, meta, checkLore); } else if (sfitem.hasItemMeta()) { return equalsItemMeta(itemMeta, sfitem.getItemMeta(), checkLore); + } else { + return false; } } else { return !sfitem.hasItemMeta(); } - - return false; } private static boolean equalsItemMeta(@Nonnull ItemMeta itemMeta, @Nonnull ImmutableItemMeta meta, boolean checkLore) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java index c5bf0556e..98e0340b5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java @@ -1,6 +1,7 @@ package io.github.thebusybiscuit.slimefun4.utils.tags; import java.util.Collections; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.Locale; @@ -188,7 +189,7 @@ public enum SlimefunTag implements Tag { } private final NamespacedKey key; - private final Set includedMaterials = new HashSet<>(); + private final Set includedMaterials = EnumSet.noneOf(Material.class); private final Set> additionalTags = new HashSet<>(); /** @@ -262,7 +263,8 @@ public enum SlimefunTag implements Tag { if (additionalTags.isEmpty()) { return Collections.unmodifiableSet(includedMaterials); } else { - Set materials = new HashSet<>(includedMaterials); + Set materials = EnumSet.noneOf(Material.class); + materials.addAll(includedMaterials); for (Tag tag : additionalTags) { materials.addAll(tag.getValues()); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java index 766f4edb2..769789b05 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java @@ -4,6 +4,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; +import java.util.EnumSet; import java.util.HashSet; import java.util.Locale; import java.util.Set; @@ -69,7 +70,7 @@ public class TagParser implements Keyed { try (BufferedReader reader = new BufferedReader(new InputStreamReader(SlimefunPlugin.class.getResourceAsStream(path), StandardCharsets.UTF_8))) { parse(reader.lines().collect(Collectors.joining("")), callback); } catch (IOException x) { - throw new TagMisconfigurationException(key, x.getMessage()); + throw new TagMisconfigurationException(key, x); } } @@ -90,7 +91,7 @@ public class TagParser implements Keyed { Validate.notNull(json, "Cannot parse a null String"); try { - Set materials = new HashSet<>(); + Set materials = EnumSet.noneOf(Material.class); Set> tags = new HashSet<>(); JsonParser parser = new JsonParser(); @@ -120,7 +121,7 @@ public class TagParser implements Keyed { throw new TagMisconfigurationException(key, "No values array specified"); } } catch (IllegalStateException | JsonParseException x) { - throw new TagMisconfigurationException(key, x.getMessage()); + throw new TagMisconfigurationException(key, x); } } From 729facab613c9fd101725002adc6f348cf01f778 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sat, 10 Oct 2020 15:18:55 +0300 Subject: [PATCH 090/178] Added Energy Connector texture. --- .../io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java | 1 + 1 file changed, 1 insertion(+) 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 019979dfb..4359aeee8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java @@ -62,6 +62,7 @@ public enum HeadTexture { FUEL_BUCKET("a84ddca766725b8b97413f259c3f7668070f6ae55483a90c8e5525394f9c099"), ELECTRIC_PRESS("8d5cf92bc79ec19f4106441affff1406a1367010dcafb197dd94cfca1a6de0fc"), ENERGY_REGULATOR("d78f2b7e5e75639ea7fb796c35d364c4df28b4243e66b76277aadcd6261337"), + ENERGY_CONNECTOR("ewogICJ0aW1lc3RhbXAiIDogMTYwMjMzMjA1MzM4NywKICAicHJvZmlsZUlkIiA6ICIyODkzNGZhODc3Yzg0MGQ4YjdhNWZiMWZmZTBkMDJiNiIsCiAgInByb2ZpbGVOYW1lIiA6ICJhamFuXzEyIiwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzEwODVlMDk4NzU2Yjk5NWIwMDI0MTY0NDA4OWM1NWE4ZjlhY2RlMzViOWEzNzc4NWQ1ZTA1N2E5MjM2MTNiIgogICAgfQogIH0KfQ=="), NETHER_ICE("3ce2dad9baf7eaba7e80d4d0f9fac0aab01a76b12fb71c3d2af2a16fdd4c7383"), ENRICHED_NETHER_ICE("7c818aa13aabc7294838d21caac057e97bd8c89641a0c0f8a55442ff4e27"), NETHER_ICE_COOLANT_CELL("8d3cd412555f897016213e5d6c7431b448b9e5644e1b19ec51b5316f35840e0"), From 49eca61a2720ecf5870eeae2cffacf71dbdeee22 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sat, 10 Oct 2020 15:21:44 +0300 Subject: [PATCH 091/178] Changed HeadTexture. --- .../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 4cd441d08..2dc52420f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -750,7 +750,7 @@ public final class SlimefunItems { public static final SlimefunItemStack BLISTERING_INGOT_3 = new SlimefunItemStack("BLISTERING_INGOT_3", Material.GOLD_INGOT, "&6Blistering Ingot", "", LoreBuilder.radioactive(Radioactivity.VERY_HIGH), LoreBuilder.HAZMAT_SUIT_REQUIRED); public static final SlimefunItemStack ENERGY_REGULATOR = new SlimefunItemStack("ENERGY_REGULATOR", HeadTexture.ENERGY_REGULATOR, "&6Energy Regulator", "", "&fCore Component of an Energy Network"); - public static final SlimefunItemStack ENERGY_CONNECTOR = new SlimefunItemStack("ENERGY_CONNECTOR", HeadTexture.CARGO_CONNECTOR_NODE, "&cEnergy Connector", "", "&fEnergy Connector Wire"); + public static final SlimefunItemStack ENERGY_CONNECTOR = new SlimefunItemStack("ENERGY_CONNECTOR", HeadTexture.ENERGY_CONNECTOR, "&cEnergy Connector", "", "&fEnergy Connector Wire"); public static final SlimefunItemStack DEBUG_FISH = new SlimefunItemStack("DEBUG_FISH", Material.SALMON, "&3How much is the Fish?", "", "&eRight Click &fany Block to view it's BlockData", "&eLeft Click &fto break a Block", "&eShift + Left Click &fany Block to erase it's BlockData", "&eShift + Right Click &fto place a Placeholder Block"); public static final SlimefunItemStack NETHER_ICE = new SlimefunItemStack("NETHER_ICE", HeadTexture.NETHER_ICE, "&eNether Ice", "", LoreBuilder.radioactive(Radioactivity.MODERATE), LoreBuilder.HAZMAT_SUIT_REQUIRED); From fd123b0bc23d6e7be84fcce2fb1c2637ca738906 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 10 Oct 2020 14:22:14 +0200 Subject: [PATCH 092/178] [CI skip] Added another validation to head textures, looks at Linox --- .../io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java | 1 + .../io/github/thebusybiscuit/slimefun4/utils/PatternUtils.java | 2 +- .../io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java | 2 +- .../java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) 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 8db1b1e07..6d9cf0bc0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java @@ -115,6 +115,7 @@ public enum HeadTexture { HeadTexture(@Nonnull String texture) { Validate.notNull(texture, "Texture cannot be null"); + Validate.isTrue(PatternUtils.HEXADECIMAL.matcher(texture).matches(), "Textures must be in hexadecimal."); this.texture = texture; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/PatternUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/PatternUtils.java index d3da91f63..59b3118c0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/PatternUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/PatternUtils.java @@ -24,7 +24,7 @@ public final class PatternUtils { public static final Pattern DASH = Pattern.compile("-"); public static final Pattern UNDERSCORE = Pattern.compile("_"); public static final Pattern ASCII = Pattern.compile("[A-Za-z \"_]+"); - public static final Pattern ALPHANUMERIC = Pattern.compile("[A-Fa-f0-9]+"); + public static final Pattern HEXADECIMAL = Pattern.compile("[A-Fa-f0-9]+"); public static final Pattern NUMERIC = Pattern.compile("[0-9]+"); public static final Pattern NUMBER_SEPARATOR = Pattern.compile("[,.]"); 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 7b13a3535..8c90ef203 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java @@ -215,7 +215,7 @@ public final class SlimefunUtils { String base64 = texture; - if (PatternUtils.ALPHANUMERIC.matcher(texture).matches()) { + if (PatternUtils.HEXADECIMAL.matcher(texture).matches()) { base64 = Base64.getEncoder().encodeToString(("{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/" + texture + "\"}}}").getBytes(StandardCharsets.UTF_8)); } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java b/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java index abd54af89..9e2963f5c 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java @@ -274,7 +274,7 @@ public class SlimefunItemStack extends CustomItem { if (texture.startsWith("ey")) { return texture; - } else if (PatternUtils.ALPHANUMERIC.matcher(texture).matches()) { + } else if (PatternUtils.HEXADECIMAL.matcher(texture).matches()) { return Base64.getEncoder().encodeToString(("{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/" + texture + "\"}}}").getBytes(StandardCharsets.UTF_8)); } else { throw new IllegalArgumentException("The provided texture for Item \"" + id + "\" does not seem to be a valid texture String!"); From e80b3b64d23e85871f803a2299172cb2a341a78b Mon Sep 17 00:00:00 2001 From: Senne Van Rompaey Date: Sat, 10 Oct 2020 12:27:12 +0000 Subject: [PATCH 093/178] Translate messages_nl.yml via GitLocalize --- src/main/resources/languages/messages_nl.yml | 465 ++++++++++--------- 1 file changed, 238 insertions(+), 227 deletions(-) diff --git a/src/main/resources/languages/messages_nl.yml b/src/main/resources/languages/messages_nl.yml index bd8d75256..2589909bd 100644 --- a/src/main/resources/languages/messages_nl.yml +++ b/src/main/resources/languages/messages_nl.yml @@ -1,120 +1,61 @@ --- -android: - scripts: - already-uploaded: "&4Dit script is al geupload" - enter-name: - - - - "&eType astublieft de gewenste naam in voor het script" - instructions: - ATTACK_ANIMALS: "&4Val aan &c(Dieren)" - ATTACK_ANIMALS_ADULT: "&4Val aan &c(Dieren &7[volwassen]&c)" - ATTACK_MOBS: "&4Val aan &c(Vijandelijke mobs)" - ATTACK_MOBS_ANIMALS: "&4Val aan &c(Vijandelijke mobs & dieren)" - CATCH_FISH: "&bVang vissen" - CHOP_TREE: "&bHak en herplant" - DIG_DOWN: "&bGraaf omlaag" - DIG_FORWARD: "&bGraaf vooruit" - DIG_UP: "&bGraaf omhoog" - FARM_DOWN: "&bOogst en herplant &7(Onderliggende blok)" - FARM_FORWARD: "&bOogst en herplant" - GO_DOWN: "&7Beweeg omlaag" - GO_FORWARD: "&7Beweeg vooruit" - GO_UP: "&7Beweeg omhoog" - INTERFACE_FUEL: "&cOntvang brandstof van de geconfronteerde interface" - INTERFACE_ITEMS: "&9Geef inventaris aan de geconfronteerde interface" - MOVE_AND_DIG_DOWN: "&bBeweeg & Graaf omlaag" - MOVE_AND_DIG_FORWARD: "&bBeweeg & Graaf vooruit" - MOVE_AND_DIG_UP: "&bBeweeg & Graaf omhoog" - REPEAT: "&9Herhaal het script" - START: "&2Start het script" - TURN_LEFT: "&7Sla links af" - TURN_RIGHT: "&7Sla rechts af" - WAIT: "&eWacht een halve seconde (0.5s)" - FARM_EXOTIC_FORWARD: "&bGeavanceerde oogst and herplant" - FARM_EXOTIC_DOWN: "&bGeavanceerde oogst and herplant &7(Onderliggende blok)" - rating: - own: "&4Je kan je eigen script geen waardering geven!" - already: "&4Je hebt aan een waardering achtergelaten voor dit script!" - uploaded: - - "&bBezig met uploaden..." - - "&aHet script is succesvol geupload!" - editor: Scripteditor - started: "&7Je robot gaat weer door met het script" - stopped: "&7Je robot is gestopt met het script" -anvil: - not-working: "&4Je kan geen Slimefun voorwerpen gebruiken in een aambeeld!" -backpack: - already-open: "&cSorry, deze rugzak is al ergens anders geopend!" - no-stack: "&cJe kan geen rugzakken stapelen" commands: + help: Laat het hulpmenu zien cheat: Geeft je toestemming om gratis spullen in het spel te brengen give: Geef iemand een aantal Slimefun spullen guide: Geef jezelf een Slimefun Handboek - help: Laat het hulpmenu zien + timings: Laat informatie over de server's prestaties zien + teleporter: Bekijk de opgeslagen locaties van andere spelers + versions: Laat een lijst met alle geïnstalleerde uitbreidingen zien + search: Doorzoek de Slimefun handleiding voor een bepaald trefwoord open_guide: Open de Slimefun handleiding zonder gebruik te maken van het Slimefun boek + stats: Laat een aantal statistieken van een speler zien research: description: Ontgrendel of herstart Slimefun kennissen van een speler reset: "&cJe hebt %player%'s Slimefun kennis herstart" reset-target: "&cJe Slimefun kennis is herstart" - search: Doorzoek de Slimefun handleiding voor een bepaald trefwoord - stats: Laat een aantal statistieken van een speler zien - teleporter: Bekijk de opgeslagen locaties van andere spelers - timings: Laat informatie over de server's prestaties zien - versions: Laat een lijst met alle geïnstalleerde uitbreidingen zien -gps: - deathpoint: "&4Dode locatie &7%date%" - geo: - scan-required: "&4Een GEO-Scan is nodig! &cScan deze chunk eerst met behulp van - een GEO-Scanner!" - insufficient-complexity: - - "&4Er is te weinig GPS netwerk complexiteit: &c%complexity%" - - "&4a) Je hebt nog geen GPS netwerk opgezet" - - "&4b) Je GPS netwerk is niet complex genoeg" - waypoint: - added: "&aEen nieuw locatiepunt is succesvol toegevoegd" - max: "&4Je hebt het maximum aantal locatiepunten bereikt" - new: "&7Type astublieft de gewenste naam voor je locatiepunt in het gespreksvenster. - &r(Kleurcodes zijn ondersteund)" guide: - cheat: - no-multiblocks: "&4Je kan geen Slimefun machines in het spel brengen, je moet - ze bouwen zoals aangegeven." - credits: - commit: Bijdrage - commits: Bijdragen - profile-link: Klik om hun profielen op Github te bezoeken - roles: - developer: "&6Ontwikkelaar" - resourcepack: "&cGrafische bundel Ontwikkelaar" - translator: "&9Vertaler" - wiki: "&3Wiki Ontwikkelaar" - languages: - select: Klik om deze taal te selecteren - select-default: Klik om de standaard taal te selecteren - selected-language: 'Momenteel geselecteerd:' - translations: - lore: Klik om een eigen vertaling toe the voegen - name: "&aOntbreekt er iets?" - updated: "&aJe taal instelling is succesvol veranderd naar: &b%lang%" - pages: - next: Volgende bladzijde - previous: Vorige bladzijde search: + message: "&bOp welk woord zou je willen zoeken?" + name: "&7Zoeken..." + tooltip: "&bKlik om naar een item te zoeken" + inventory: 'Zoeken naar: %item%' lore: - "&bOp welk woord zou je willen zoeken?" - "&7Type je zoekterm in het gespreksvenster" - message: "&bOp welk woord zou je willen zoeken?" - name: "&7Zoeken..." + cheat: + no-multiblocks: "&4Je kan geen Slimefun machines in het spel brengen, je moet + ze bouwen zoals aangegeven." + languages: + updated: "&aJe taal instelling is succesvol veranderd naar: &b%lang%" + translations: + name: "&aOntbreekt er iets?" + lore: Klik om een eigen vertaling toe the voegen + select: Klik om deze taal te selecteren + select-default: Klik om de standaard taal te selecteren + selected-language: 'Momenteel geselecteerd:' title: - addons: Uitbreidingen voor Slimefun4 - bugs: Fouten rapporteren - credits: Slimefun4 Bijdragers - languages: Kies een taal bij voorkeur main: Slimefun Handboek settings: Instellingen & Informatie + languages: Kies een taal bij voorkeur + credits: Slimefun4 Bijdragers wiki: Slimefun4 Wiki + addons: Uitbreidingen voor Slimefun4 + bugs: Fouten rapporteren source: Source Code + credits: + commit: Bijdrage + commits: Bijdragen + roles: + developer: "&6Ontwikkelaar" + wiki: "&3Wiki Ontwikkelaar" + resourcepack: "&cGrafische bundel Ontwikkelaar" + translator: "&9Vertaler" + profile-link: Klik om hun profielen op Github te bezoeken + pages: + previous: Vorige bladzijde + next: Volgende bladzijde tooltips: open-category: Klik om te openen versions-notice: Deze zijn erg belangrijk voor het rapporteren van fouten! @@ -128,91 +69,65 @@ guide: title: Terug guide: Ga terug naar de Slimefun Handleiding settings: Ga terug naar Instellingen -inventory: - no-access: "&4Je hebt geen toegang tot dit block" -languages: - cs: Tsjechisch - de: Duits - default: Server-Standaard - el: Grieks - en: Engels - es: Spaans - fr: Frans - he: Hebreeuws - hu: Hongaars - id: Indonesisch - it: Italiaans - lv: Lets - nl: Nederlands - pl: Pools - pt: Portugees (Portugal) - pt-BR: Portugees (Brazilië) - ru: Russisch - sk: Slowaaks - sv: Zweeds - vi: Vietnamees - zh-CN: Chinees (China) - zh-TW: Chinees (Taiwan) - ar: Arabisch - af: Afrikaans - da: Deens - fi: Fins - uk: Oekraïens - ms: Maleis - 'no': Noors - ja: Japans - fa: Perzisch - th: Thais - ro: Roemeens - bg: Bulgaars - ko: Koreaans - tr: Turks -machines: - ANCIENT_ALTAR: - not-enough-pedestals: "&4Het altaar is niet omringt met het nodige aantal sokkels - &c(%pedestals% / 8)" - unknown-catalyst: "&4Onbepaalde katalysator! &cGebruik het juiste recept" - unknown-recipe: "&4Onbepaald recept! &cGebruik het juiste recept" - ANCIENT_PEDESTAL: - obstructed: "&4Een sokkel is onderbroken! &cVerwijder alles boven de sokkel!" - CARGO_NODES: - must-be-placed: "&4Dit moet geplaatst worden op een kist of op een machine!" - ELEVATOR: - click-to-teleport: "&eKlik &7om naar deze verdieping te gaan:" - current-floor: "&eDit is de verdieping waar je nu bent:" - enter-name: "&7Type astublieft de gewenste verdieping in het gespreksvenster. - &r(Kleurcodes zijn ondersteund)" - named: "&2Deze verdieping succesvol vernoemt naar: &r%floor%" - no-destinations: "&4Geen doelen gevonden" - pick-a-floor: "&3- Kies een verdieping -" - full-inventory: "&eSorry, mijn inventaris is te vol!" - HOLOGRAM_PROJECTOR: - enter-text: "&7Type astublieft de gewenste text in het gespreksvenster. &r(Kleurcodes - zijn ondersteund)" - inventory-title: Hologram-editor - ignition-chamber-no-flint: "&cDe ontstekingskamer heeft geen aansteker meer" - in-use: "&cDit blok is al in gebruik door een andere speler" - pattern-not-found: "&eSorry, ik heb het recept niet herkend. Plaats astublieft de - spullen in het correcte patroon in de dispenser" - TELEPORTER: - cancelled: "&4Teleportatie geannuleerd!" - invulnerability: "&b&lJe hebt 30 seconden immuniteit ontvangen!" - teleported: "&3Geteleporteerd!" - teleporting: "&3Bezig met teleporteren..." - unknown-material: "&eSorry, ik heb het object in mijn dispenser niet herkend. Plaats - er astublieft iets in dat ik herken" - wrong-item: "& eSorry, ik heb het object waarmee je mij aan hebt geklikt niet herkend. - Controleer de recepten en kijk welke spullen je kan gebruiken" - GPS_CONTROL_PANEL: - title: GPS - Configuratiescherm - transmitters: Transmitter-overzicht - waypoints: Waypoint-overzicht + locked: VERGRENDELD + locked-category: + - Om deze categorie te ontgrendelen zul je + - alle items moeten ontgrendelen van de + - volgende categorieën messages: - cannot-place: "&cJe kan dat blok daar niet plaatsen!" - diet-cookie: "&eJe begint je zo ligt als een veertje te voelen..." + not-researched: "&4Je hebt niet genoeg Slimefun kennis om dit te begrijpen" + not-enough-xp: "&4Je hebt niet genoeg XP om dit te ontgrendelen" + unlocked: '&bJe hebt &7"%research%" ontgrendeld' + only-players: "&4Dit commando is alleen voor spelers" + unknown-player: "&4Onbepaalde speler: &c%player%" + no-permission: "&4Je hebt geen toestemming om deze actie uit te voeren" + usage: "&4Gebruik, zoals: &c%usage%" + not-online: "&4%player% &cis niet online!" + not-valid-item: "&4%item% &cis geen geldig voorwerp!" + not-valid-amount: "&4%amount% &cis geen geldige hoeveelheid: het moet meer zijn + dan 0!" + given-item: '&bJe hebt &a%amount% keer &7"%item%&7" ontvangen' + give-item: '&bJe hebt %player% &a%amount% keer &7"%item%&7" gegeven' + not-valid-research: "&4%research% &cis geen geldig Slimefun onderzoek" + give-research: '&bJe hebt %player% de kennis over &7"%research%&7" gegeven' + hungry: "&cJe hebt teveel honger om zoiets te doen!" disabled-in-world: "&4&lDit voorwerp is uitgeschakeld in deze wereld" disabled-item: "&4&lDit voorwerp is uitgeschakeld! Hoe heb je dat ooit verkregen?!" + no-tome-yourself: "&cJe kan deze &4Tome of Knowledge &con niet op jezelf gebruiken..." + multimeter: "&bOpgeslagen energie: &3%stored% &b/ &3%capacity%" + talisman: + anvil: "&a&oJe Talisman heeft voorkomen dat je uitrusting is gebroken" + miner: "&a&oJe Talisman heeft zonet de gewonnen mineralen verdubbeld" + hunter: "&a&oJe Talisman heeft zonet je buit verdubbeld" + lava: "&a&oJe Talisman heeft je gered van een vurige dood" + water: "&a&oJe Talisman heeft je gered van de verdrinkingsdood" + angel: "&a&oJe Talisman heeft je gered van val schade" + fire: "&a&oJe Talisman heeft je gered van een vurige dood" + magician: "&a&oJe Talisman heeft je een extra betovering gegeven" + traveller: "&a&oJe Talisman heeft je een snelheidsboost gegeven" + warrior: "&a&oJe Talisman heeft je kracht voor een tijdje verbeterd" + knight: "&a&oJe Talisman heeft je 5 seconden genezing gegeven" + whirlwind: "&a&oJe Talisman heeft het projectiel weerkaatst" + wizard: "&a&oJe Talisman heeft je een hoger level van geluk gegeven, maar heeft + misschien ook de levels van andere betoveringen verlaagd" + soulbound-rune: + fail: "&cJe kan maar één voorwerp met je ziel verbinden op elk moment" + success: "&aJe hebt dit voorwerp succesvol met je ziel verbonden! Het blijft bij + je als je dood gaat" + research: + start: "& 7De wijze geesten fluisteren mysterieuze woorden in je hoofd!" + progress: "&7Je begint na te filosoferen over &b%research% &e(%progress%)" fire-extinguish: "&7Je hebt jezelf geblust! ..." + cannot-place: "&cJe kan dat blok daar niet plaatsen!" + no-pvp: "&cJe kan hier geen pvp aan gaan!" + radiation: "&4Je bent blootgesteld aan dodelijke straling! &cGooi het radioactieve + voorwerp weg of draag een volledige hazmat suit!" + opening-guide: "&bBezig met het handboek openen, dit kan even duren..." + opening-backpack: "&bBezig met een rugzag openen, dit kan even duren..." + no-iron-golem-heal: "&cDat is geen ijzerstaaf! Je kan dit niet gebruiken om ijzeren + golems te genezen!" + link-prompt: "&eKlik mij:" + diet-cookie: "&eJe begint je zo ligt als een veertje te voelen..." fortune-cookie: - "&7Hellup mij, ik zit vast in een gelukskoekjes-fabriek!" - "&7Je overlijdt morgen... door een creeper..." @@ -227,56 +142,152 @@ messages: - "&742. Het antwoord op alles is 42" - "&7A Walshy, één dag houdt alle problemen weg" - "&7Graaf nooit recht naar beneden!" - give-item: '&bJe hebt %player% &a%amount% keer &7"%item%&7" gegeven' - given-item: '&bJe hebt &a%amount% keer &7"%item%&7" ontvangen' - give-research: '&bJe hebt %player% de kennis over &7"%research%&7" gegeven' - hungry: "&cJe hebt teveel honger om zoiets te doen!" - link-prompt: "&eKlik mij:" mode-change: "&b%device% mode is veranderd naar: &9%mode%" - multimeter: "&bOpgeslagen energie: &3%stored% &b/ &3%capacity%" - no-iron-golem-heal: "&cDat is geen ijzerstaaf! Je kan dit niet gebruiken om ijzeren - golems te genezen!" - no-permission: "&4Je hebt geen toestemming om deze actie uit te voeren" - no-pvp: "&cJe kan hier geen pvp aan gaan!" - not-enough-xp: "&4Je hebt niet genoeg XP om dit te ontgrendelen" - no-tome-yourself: "&cJe kan deze &4Tome of Knowledge &con niet op jezelf gebruiken..." - not-online: "&4%player% &cis niet online!" - not-researched: "&4Je hebt niet genoeg Slimefun kennis om dit te begrijpen" - not-valid-amount: "&4%amount% &cis geen geldige hoeveelheid: het moet meer zijn - dan 0!" - not-valid-item: "&4%item% &cis geen geldig voorwerp!" - not-valid-research: "&4%research% &cis geen geldig Slimefun onderzoek" - only-players: "&4Dit commando is alleen voor spelers" - opening-backpack: "&bBezig met een rugzag openen, dit kan even duren..." - opening-guide: "&bBezig met het handboek openen, dit kan even duren..." - radiation: "&4Je bent blootgesteld aan dodelijke straling! &cGooi het radioactieve - voorwerp weg of draag een volledige hazmat suit!" - research: - progress: "&7Je begint na te filosoferen over &b%research% &e(%progress%)" - start: "& 7De wijze geesten fluisteren mysterieuze woorden in je hoofd!" - soulbound-rune: - fail: "&cJe kan maar één voorwerp met je ziel verbinden op elk moment" - success: "&aJe hebt dit voorwerp succesvol met je ziel verbonden! Het blijft bij - je als je dood gaat" - talisman: - angel: "&a&oJe Talisman heeft je gered van val schade" - anvil: "&a&oJe Talisman heeft voorkomen dat je uitrusting is gebroken" - fire: "&a&oJe Talisman heeft je gered van een vurige dood" - hunter: "&a&oJe Talisman heeft zonet je buit verdubbeld" - knight: "&a&oJe Talisman heeft je 5 seconden genezing gegeven" - lava: "&a&oJe Talisman heeft je gered van een vurige dood" - magician: "&a&oJe Talisman heeft je een extra betovering gegeven" - miner: "&a&oJe Talisman heeft zonet de gewonnen mineralen verdubbeld" - traveller: "&a&oJe Talisman heeft je een snelheidsboost gegeven" - warrior: "&a&oJe Talisman heeft je kracht voor een tijdje verbeterd" - water: "&a&oJe Talisman heeft je gered van de verdrinkingsdood" - whirlwind: "&a&oJe Talisman heeft het projectiel weerkaatst" - wizard: "&a&oJe Talisman heeft je een hoger level van geluk gegeven, maar heeft - misschien ook de levels van andere betoveringen verlaagd" - unknown-player: "&4Onbepaalde speler: &c%player%" - unlocked: '&bJe hebt &7"%research%" ontgrendeld' - usage: "&4Gebruik, zoals: &c%usage%" -miner: - no-ores: "&eSorry, ik kon geen ertsen vinden dichtbij!" +machines: + pattern-not-found: "&eSorry, ik heb het recept niet herkend. Plaats astublieft de + spullen in het correcte patroon in de dispenser" + unknown-material: "&eSorry, ik heb het object in mijn dispenser niet herkend. Plaats + er astublieft iets in dat ik herken" + wrong-item: "& eSorry, ik heb het object waarmee je mij aan hebt geklikt niet herkend. + Controleer de recepten en kijk welke spullen je kan gebruiken" + full-inventory: "&eSorry, mijn inventaris is te vol!" + in-use: "&cDit blok is al in gebruik door een andere speler" + ignition-chamber-no-flint: "&cDe ontstekingskamer heeft geen aansteker meer" + ANCIENT_ALTAR: + not-enough-pedestals: "&4Het altaar is niet omringt met het nodige aantal sokkels + &c(%pedestals% / 8)" + unknown-catalyst: "&4Onbepaalde katalysator! &cGebruik het juiste recept" + unknown-recipe: "&4Onbepaald recept! &cGebruik het juiste recept" + ANCIENT_PEDESTAL: + obstructed: "&4Een sokkel is onderbroken! &cVerwijder alles boven de sokkel!" + HOLOGRAM_PROJECTOR: + enter-text: "&7Type astublieft de gewenste text in het gespreksvenster. &r(Kleurcodes + zijn ondersteund)" + inventory-title: Hologram-editor + ELEVATOR: + no-destinations: "&4Geen doelen gevonden" + pick-a-floor: "&3- Kies een verdieping -" + current-floor: "&eDit is de verdieping waar je nu bent:" + click-to-teleport: "&eKlik &7om naar deze verdieping te gaan:" + enter-name: "&7Type astublieft de gewenste verdieping in het gespreksvenster. + &r(Kleurcodes zijn ondersteund)" + named: "&2Deze verdieping succesvol vernoemt naar: &r%floor%" + TELEPORTER: + teleporting: "&3Bezig met teleporteren..." + teleported: "&3Geteleporteerd!" + cancelled: "&4Teleportatie geannuleerd!" + invulnerability: "&b&lJe hebt 30 seconden immuniteit ontvangen!" + gui: + title: Jouw locatiepunt + tooltip: Klik om te teleporteren + time: Geschatte tijd + CARGO_NODES: + must-be-placed: "&4Dit moet geplaatst worden op een kist of op een machine!" + GPS_CONTROL_PANEL: + title: GPS - Configuratiescherm + transmitters: Transmitter-overzicht + waypoints: Waypoint-overzicht +anvil: + not-working: "&4Je kan geen Slimefun voorwerpen gebruiken in een aambeeld!" +backpack: + already-open: "&cSorry, deze rugzak is al ergens anders geopend!" + no-stack: "&cJe kan geen rugzakken stapelen" workbench: not-enhanced: "&4Je kan geen Slimefun voorwerpen in een normale werkbank gebruiken" +gps: + deathpoint: "&4Dode locatie &7%date%" + waypoint: + new: "&7Type astublieft de gewenste naam voor je locatiepunt in het gespreksvenster. + &r(Kleurcodes zijn ondersteund)" + added: "&aEen nieuw locatiepunt is succesvol toegevoegd" + max: "&4Je hebt het maximum aantal locatiepunten bereikt" + insufficient-complexity: + - "&4Er is te weinig GPS netwerk complexiteit: &c%complexity%" + - "&4a) Je hebt nog geen GPS netwerk opgezet" + - "&4b) Je GPS netwerk is niet complex genoeg" + geo: + scan-required: "&4Een GEO-Scan is nodig! &cScan deze chunk eerst met behulp van + een GEO-Scanner!" +inventory: + no-access: "&4Je hebt geen toegang tot dit block" +android: + started: "&7Je robot gaat weer door met het script" + stopped: "&7Je robot is gestopt met het script" + scripts: + already-uploaded: "&4Dit script is al geupload" + instructions: + START: "&2Start het script" + REPEAT: "&9Herhaal het script" + WAIT: "&eWacht een halve seconde (0.5s)" + GO_FORWARD: "&7Beweeg vooruit" + GO_UP: "&7Beweeg omhoog" + GO_DOWN: "&7Beweeg omlaag" + TURN_LEFT: "&7Sla links af" + TURN_RIGHT: "&7Sla rechts af" + DIG_UP: "&bGraaf omhoog" + DIG_FORWARD: "&bGraaf vooruit" + DIG_DOWN: "&bGraaf omlaag" + MOVE_AND_DIG_UP: "&bBeweeg & Graaf omhoog" + MOVE_AND_DIG_FORWARD: "&bBeweeg & Graaf vooruit" + MOVE_AND_DIG_DOWN: "&bBeweeg & Graaf omlaag" + ATTACK_MOBS_ANIMALS: "&4Val aan &c(Vijandelijke mobs & dieren)" + ATTACK_MOBS: "&4Val aan &c(Vijandelijke mobs)" + ATTACK_ANIMALS: "&4Val aan &c(Dieren)" + ATTACK_ANIMALS_ADULT: "&4Val aan &c(Dieren &7[volwassen]&c)" + CHOP_TREE: "&bHak en herplant" + CATCH_FISH: "&bVang vissen" + FARM_FORWARD: "&bOogst en herplant" + FARM_DOWN: "&bOogst en herplant &7(Onderliggende blok)" + FARM_EXOTIC_FORWARD: "&bGeavanceerde oogst and herplant" + FARM_EXOTIC_DOWN: "&bGeavanceerde oogst and herplant &7(Onderliggende blok)" + INTERFACE_ITEMS: "&9Geef inventaris aan de geconfronteerde interface" + INTERFACE_FUEL: "&cOntvang brandstof van de geconfronteerde interface" + enter-name: + - + - "&eType astublieft de gewenste naam in voor het script" + uploaded: + - "&bBezig met uploaden..." + - "&aHet script is succesvol geupload!" + rating: + own: "&4Je kan je eigen script geen waardering geven!" + already: "&4Je hebt aan een waardering achtergelaten voor dit script!" + editor: Scripteditor +languages: + default: Server-Standaard + en: Engels + de: Duits + fr: Frans + it: Italiaans + es: Spaans + pl: Pools + sv: Zweeds + nl: Nederlands + cs: Tsjechisch + hu: Hongaars + lv: Lets + ru: Russisch + sk: Slowaaks + zh-TW: Chinees (Taiwan) + vi: Vietnamees + id: Indonesisch + zh-CN: Chinees (China) + el: Grieks + he: Hebreeuws + ar: Arabisch + af: Afrikaans + da: Deens + fi: Fins + uk: Oekraïens + ms: Maleis + 'no': Noors + ja: Japans + fa: Perzisch + th: Thais + ro: Roemeens + pt: Portugees (Portugal) + pt-BR: Portugees (Brazilië) + bg: Bulgaars + ko: Koreaans + tr: Turks +miner: + no-ores: "&eSorry, ik kon geen ertsen vinden dichtbij!" From eab50659bc522b29ad2d83fd5bb8614cfe95b1c3 Mon Sep 17 00:00:00 2001 From: Sven313D Date: Sat, 10 Oct 2020 12:27:13 +0000 Subject: [PATCH 094/178] Translate messages_nl.yml via GitLocalize From 973f92c9797b8f7dd21300f34ed75c3d51c4e4ee Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sat, 10 Oct 2020 15:33:41 +0300 Subject: [PATCH 095/178] Update HeadTexture.java I guess this is correct now. --- .../io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 4359aeee8..89e97424a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java @@ -62,7 +62,7 @@ public enum HeadTexture { FUEL_BUCKET("a84ddca766725b8b97413f259c3f7668070f6ae55483a90c8e5525394f9c099"), ELECTRIC_PRESS("8d5cf92bc79ec19f4106441affff1406a1367010dcafb197dd94cfca1a6de0fc"), ENERGY_REGULATOR("d78f2b7e5e75639ea7fb796c35d364c4df28b4243e66b76277aadcd6261337"), - ENERGY_CONNECTOR("ewogICJ0aW1lc3RhbXAiIDogMTYwMjMzMjA1MzM4NywKICAicHJvZmlsZUlkIiA6ICIyODkzNGZhODc3Yzg0MGQ4YjdhNWZiMWZmZTBkMDJiNiIsCiAgInByb2ZpbGVOYW1lIiA6ICJhamFuXzEyIiwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzEwODVlMDk4NzU2Yjk5NWIwMDI0MTY0NDA4OWM1NWE4ZjlhY2RlMzViOWEzNzc4NWQ1ZTA1N2E5MjM2MTNiIgogICAgfQogIH0KfQ=="), + ENERGY_CONNECTOR("1085e098756b995b00241644089c55a8f9acde35b9a37785d5e057a923613b"), NETHER_ICE("3ce2dad9baf7eaba7e80d4d0f9fac0aab01a76b12fb71c3d2af2a16fdd4c7383"), ENRICHED_NETHER_ICE("7c818aa13aabc7294838d21caac057e97bd8c89641a0c0f8a55442ff4e27"), NETHER_ICE_COOLANT_CELL("8d3cd412555f897016213e5d6c7431b448b9e5644e1b19ec51b5316f35840e0"), From af608e3c13924080626e5a30fc2beef26b90ae44 Mon Sep 17 00:00:00 2001 From: Sven313D Date: Sat, 10 Oct 2020 12:42:09 +0000 Subject: [PATCH 096/178] Translate recipes_nl.yml via GitLocalize --- src/main/resources/languages/recipes_nl.yml | 43 ++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/main/resources/languages/recipes_nl.yml b/src/main/resources/languages/recipes_nl.yml index 765287008..d7e90581e 100644 --- a/src/main/resources/languages/recipes_nl.yml +++ b/src/main/resources/languages/recipes_nl.yml @@ -81,12 +81,48 @@ slimefun: name: " Food Fabricator" lore: - Maak dit item zoals afgebeeld - - met behulp van een Food Fabricator. + - Met behulp van een Food Fabricator food_composter: name: " Food Composter" lore: - Maak dit item zoals afgebeeld - met behulp van een Food Composter. + freezer: + name: Freezer + lore: + - Maak dit item zoals afgebeeld + - met behulp van een Freezer + geo_miner: + name: GEO Miner + lore: + - Dit item kan worden verzameld + - met behulp van een GEO Miner + nuclear_reactor: + name: Nuclear Reactor + lore: + - Dit item is een bijproduct + - als je een kernreactor gebruikt + oil_pump: + name: Oil Pump + lore: + - Dit item kan worden verzameld + - door een Oil Pump te gebruiken + pickaxe_of_containment: + name: de Pickaxe of Containment + lore: + - Dit blok kan worden verzameld + - door een Spawner te minen met + - Pickaxe of Containment + refinery: + name: Refinery + lore: + - Maak dit item zoals afgebeeld + - met behulp van een Refinery + barter_drop: + name: Piglin ruilhandel drop + lore: + - 'Ruil Goud met Piglins ' + - Om dit item te verkrijgen minecraft: shaped: name: Gevormd Verwerkingsrecept @@ -125,3 +161,8 @@ minecraft: lore: - Maak dit item zoals afgebeeld - met behulp van een Steenzaag. + smithing: + name: Smeedstafel recept + lore: + - Maak dit item zoals afgebeeld + - met behulp van een Smeedstafel From 44c1238ef1206e3f88b108d82e9fb43e1c00304d Mon Sep 17 00:00:00 2001 From: Senne Van Rompaey Date: Sat, 10 Oct 2020 12:42:10 +0000 Subject: [PATCH 097/178] Translate recipes_nl.yml via GitLocalize From 35f68e5ab230b8ba1b17935e982111d6a8a51249 Mon Sep 17 00:00:00 2001 From: TypischTeun Date: Sat, 10 Oct 2020 12:42:11 +0000 Subject: [PATCH 098/178] Translate recipes_nl.yml via GitLocalize From 8ce474331e3434a9596f9037c1f910ab575ad873 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sat, 10 Oct 2020 16:05:41 +0300 Subject: [PATCH 099/178] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5f708932..d2a6007b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ * Added Elytra Cap * Added Planks to Sticks recipe to the Table Saw * Added "slimefun.gps.bypass" permission to open GPS devices anywhere +* Added Energy Connector #### Changes * Improved Auto-Updater (Multi-Threading and more) From 025021f5b5e680868b13eed8e5124bb4e1055a91 Mon Sep 17 00:00:00 2001 From: milvantiou Date: Sat, 10 Oct 2020 13:12:27 +0000 Subject: [PATCH 100/178] Translate categories_nl.yml via GitLocalize --- src/main/resources/languages/categories_nl.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/languages/categories_nl.yml b/src/main/resources/languages/categories_nl.yml index f70448379..aa98aac91 100644 --- a/src/main/resources/languages/categories_nl.yml +++ b/src/main/resources/languages/categories_nl.yml @@ -23,3 +23,4 @@ slimefun: easter: Pasen (April) birthday: TheBusyBiscuit's Verjaardag (26 October) halloween: Halloween (31 October) + androids: programeerbare robots From 47d39cdc3c41ad38e473549923d11178b2ec234e Mon Sep 17 00:00:00 2001 From: Senne Van Rompaey Date: Sat, 10 Oct 2020 13:12:28 +0000 Subject: [PATCH 101/178] Translate categories_nl.yml via GitLocalize --- src/main/resources/languages/categories_nl.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/languages/categories_nl.yml b/src/main/resources/languages/categories_nl.yml index aa98aac91..eef15e6b7 100644 --- a/src/main/resources/languages/categories_nl.yml +++ b/src/main/resources/languages/categories_nl.yml @@ -23,4 +23,4 @@ slimefun: easter: Pasen (April) birthday: TheBusyBiscuit's Verjaardag (26 October) halloween: Halloween (31 October) - androids: programeerbare robots + androids: Programmeerbare Robots From 08bb3291c15485a4e49d12b8842b930f44de4322 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 10 Oct 2020 15:25:03 +0200 Subject: [PATCH 102/178] [CI skip] Updated translators list --- .../slimefun4/core/services/localization/Translators.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Translators.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Translators.java index 80a235dbe..dd5f95a95 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Translators.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Translators.java @@ -99,6 +99,9 @@ public class Translators { addTranslator("Dr4gonD", "DragonD", SupportedLanguage.DUTCH, true); addTranslator("svr333", SupportedLanguage.DUTCH, false); addTranslator("PabloMarcendo", SupportedLanguage.DUTCH, true); + addTranslator("milvantiou", SupportedLanguage.DUTCH, true); + addTranslator("Sven313D", SupportedLanguage.DUTCH, true); + addTranslator("TypischTeun", SupportedLanguage.DUTCH, true); // Translators - Danish addTranslator("Mini-kun", SupportedLanguage.DANISH, true); From 0580a873ec204f3372dca87e233c29c6731fcf34 Mon Sep 17 00:00:00 2001 From: Silent Date: Sat, 10 Oct 2020 18:50:41 +0200 Subject: [PATCH 103/178] Stop unwanted actions with StrangeNetherGoo and HeavyCream --- .../implementation/items/food/HeavyCream.java | 28 +++++++++++++++++++ .../items/misc/StrangeNetherGoo.java | 7 +++++ .../setup/SlimefunItemSetup.java | 3 +- 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/HeavyCream.java diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/HeavyCream.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/HeavyCream.java new file mode 100644 index 000000000..2a10fb906 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/HeavyCream.java @@ -0,0 +1,28 @@ +package io.github.thebusybiscuit.slimefun4.implementation.items.food; + +import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; +import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; +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.inventory.ItemStack; + +/** + * This {@link SlimefunItem} can be obtained by crafting and, it's + * used for various food recipes recipes + * + * @author TheSilentPro + */ +public class HeavyCream extends SlimefunItem { + + public HeavyCream(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { + super(category, item, recipeType, recipe, recipeOutput); + } + + @Override + public void preRegister() { + addItemHandler((ItemUseHandler) PlayerRightClickEvent::cancel); + } + +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java index eb6aa7716..05b6e812d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java @@ -1,5 +1,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.misc; +import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; +import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; import org.bukkit.entity.Piglin; import org.bukkit.inventory.ItemStack; @@ -36,4 +38,9 @@ public class StrangeNetherGoo extends SlimefunItem implements PiglinBarterDrop { return chance.getValue(); } + @Override + public void preRegister() { + addItemHandler((ItemUseHandler) PlayerRightClickEvent::cancel); + } + } 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 2ce593999..5015b8568 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 @@ -115,6 +115,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.food.Juice; import io.github.thebusybiscuit.slimefun4.implementation.items.food.MagicSugar; import io.github.thebusybiscuit.slimefun4.implementation.items.food.MeatJerky; import io.github.thebusybiscuit.slimefun4.implementation.items.food.MonsterJerky; +import io.github.thebusybiscuit.slimefun4.implementation.items.food.HeavyCream; import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner; import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner; import io.github.thebusybiscuit.slimefun4.implementation.items.geo.OilPump; @@ -907,7 +908,7 @@ public final class SlimefunItemSetup { new ItemStack[] {new ItemStack(Material.SAND, 2), null, null, null, null, null, null, null, null}) .register(plugin); - new SlimefunItem(categories.misc, SlimefunItems.HEAVY_CREAM, RecipeType.ENHANCED_CRAFTING_TABLE, + new HeavyCream(categories.misc, SlimefunItems.HEAVY_CREAM, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] {new ItemStack(Material.MILK_BUCKET), null, null, null, null, null, null, null, null}, new SlimefunItemStack(SlimefunItems.HEAVY_CREAM, 2)) .register(plugin); From b60c2382a5745353e2fb399ff59c7a30bb11b517 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 10 Oct 2020 18:52:22 +0200 Subject: [PATCH 104/178] [CI skip] Quickly added DoubleRangeSetting copy --- .../items/settings/DoubleRangeSetting.java | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/DoubleRangeSetting.java diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/DoubleRangeSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/DoubleRangeSetting.java new file mode 100644 index 000000000..e83ebf1d7 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/DoubleRangeSetting.java @@ -0,0 +1,53 @@ +package io.github.thebusybiscuit.slimefun4.api.items.settings; + +import javax.annotation.ParametersAreNonnullByDefault; + +import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; + +/** + * This variation of {@link ItemSetting} allows you to define an {@link Double} range + * and enforces this range using the {@link #validateInput(Double)} method. + * + * @author TheBusyBiscuit + * + * @see ItemSetting + * @see IntRangeSetting + * + */ +public class DoubleRangeSetting extends ItemSetting { + + private final double min; + private final double max; + + @ParametersAreNonnullByDefault + public DoubleRangeSetting(String key, double min, double defaultValue, double max) { + super(key, defaultValue); + + this.min = min; + this.max = max; + } + + @Override + public boolean validateInput(Double input) { + return super.validateInput(input) && input >= min && input <= max; + } + + /** + * This returns the minimum value of this {@link DoubleRangeSetting}. + * + * @return The minimum value + */ + public double getMinimum() { + return min; + } + + /** + * This returns the maximum value of this {@link DoubleRangeSetting}. + * + * @return The maximum value + */ + public double getMaximum() { + return max; + } + +} From 2da7efd3801f585c2b7b2fd604db687886bb0248 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 10 Oct 2020 19:18:15 +0200 Subject: [PATCH 105/178] [CI skip] Updated a javadocs tag --- .../slimefun4/api/items/settings/IntRangeSetting.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java index 3f62e355c..90856147f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java @@ -11,6 +11,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; * @author TheBusyBiscuit * * @see ItemSetting + * @see DoubleRangeSetting * */ public class IntRangeSetting extends ItemSetting { From c2ca5a1ea5f8bc4e8fbffedadc417b71043bf1bc Mon Sep 17 00:00:00 2001 From: DNBGlol Date: Sat, 10 Oct 2020 17:28:02 +0000 Subject: [PATCH 106/178] Translate resources_bg.yml via GitLocalize --- src/main/resources/languages/resources_bg.yml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/resources/languages/resources_bg.yml diff --git a/src/main/resources/languages/resources_bg.yml b/src/main/resources/languages/resources_bg.yml new file mode 100644 index 000000000..25631c483 --- /dev/null +++ b/src/main/resources/languages/resources_bg.yml @@ -0,0 +1,24 @@ +--- +tooltips: + results: Резултати от ГЕО-сканиране + chunk: Сканиран Чънк + world: Свят + unit: Единица + units: Единици +resources: + slimefun: + oil: Масло + nether_ice: Лед от Недъра + salt: Сол + uranium: Уран + slimefunorechunks: + iron_ore_chunk: Чънк с Желязна Руда + gold_ore_chunk: Чънк със Златна Руда + copper_ore_chunk: Чънк с Медна Руда + tin_ore_chunk: Чънк със Калаена Руда + silver_ore_chunk: Чънк със Сребърна Руда + aluminum_ore_chunk: Чънк с Алуминиева Руда + lead_ore_chunk: Чънк с Олова Руда + zinc_ore_chunk: Чънк с Цинкова Руда + nickel_ore_chunk: Чънк с Никелова Руда + cobalt_ore_chunk: Чънк с Кобалтова Руда From 01fc7cd536652fc83a1b08c837acc156ff5f1c48 Mon Sep 17 00:00:00 2001 From: DNBGlol Date: Sat, 10 Oct 2020 17:28:03 +0000 Subject: [PATCH 107/178] Translate categories_bg.yml via GitLocalize --- src/main/resources/languages/categories_bg.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/languages/categories_bg.yml b/src/main/resources/languages/categories_bg.yml index 6db802086..49dc67d43 100644 --- a/src/main/resources/languages/categories_bg.yml +++ b/src/main/resources/languages/categories_bg.yml @@ -23,3 +23,4 @@ slimefun: easter: Великден (април) birthday: Рожденият Ден на TheBusyBiscuit (26ти Октомври) halloween: Хелоуин (31и Октомври) + androids: Програмируеми Андроиди From 1088aea40e1fdba8b0a679a8e09d92654bdd4159 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 10 Oct 2020 17:33:20 +0000 Subject: [PATCH 108/178] Translate researches_de.yml via GitLocalize --- src/main/resources/languages/researches_de.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/resources/languages/researches_de.yml b/src/main/resources/languages/researches_de.yml index 45d4f28de..d75aaf821 100644 --- a/src/main/resources/languages/researches_de.yml +++ b/src/main/resources/languages/researches_de.yml @@ -243,3 +243,6 @@ slimefun: climbing_pick: Lara Craft shulker_shell: Synthetische Shulkerschalen villager_rune: Dorfbewohner wie neugeboren + caveman_talisman: Des Höhlenmenschen's Talisman + even_higher_tier_capacitors: Kondensatoren Stufe 3 + elytra_cap: Harter Aufprall From 9328fba062ac158ff5de3b5c0c69117e8de99dfd Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 10 Oct 2020 17:33:21 +0000 Subject: [PATCH 109/178] Translate recipes_de.yml via GitLocalize From 6434c79a0ad7a90a4ddf1b23b67b39975637291a Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 10 Oct 2020 17:33:22 +0000 Subject: [PATCH 110/178] Translate messages_de.yml via GitLocalize --- src/main/resources/languages/messages_de.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/resources/languages/messages_de.yml b/src/main/resources/languages/messages_de.yml index b09bccc7d..b45b3b598 100644 --- a/src/main/resources/languages/messages_de.yml +++ b/src/main/resources/languages/messages_de.yml @@ -21,6 +21,10 @@ commands: backpack-does-not-exist: "&4Der angegebene Rucksack konnte nicht gefunden werden!" restored-backpack-given: "&aDein Rucksack wurde erfolgreich wiederhergestellt und deinem Inventar hinzugefügt!" + charge: + description: Lädt das Item in deiner Hand auf + charge-success: Dein Item wurde erfolgreich aufgeladen! + not-rechargeable: Dieses Item kann nicht aufgeladen werden! guide: search: message: "&bWonach möchtest du suchen?" @@ -130,6 +134,7 @@ messages: whirlwind: "&a&oDein Talisman hat soeben ein Projektil reflektiert" wizard: "&a&oDein Talisman hat dein Glück-Level erhöht aber möglicherweise das Level einer anderen Verzauberung vermindert" + caveman: "&a&oDein Talisman hat dir einen Abbau-Boost verschafft" soulbound-rune: fail: "&cDu kannst nicht mehrere Items auf einmal an deine Seele binden" success: "&aDu hast dieses Item erfolgreich an deine Seele gebunden! Solltest @@ -329,7 +334,6 @@ languages: zh-CN: Chinesisch (China) el: Griechisch he: Hebräisch - pt: Portugiesisch (Portugal) pt-BR: Portugiesisch (Brasilien) ar: Arabisch af: Afrikaans @@ -342,6 +346,7 @@ languages: fa: Persisch th: Thailändisch ro: Rumänisch + pt: Portugiesisch (Portugal) bg: Bulgarisch ko: Koreanisch tr: Türkisch @@ -354,5 +359,7 @@ brewing_stand: not-working: "&4Items von Slimefun können nicht zum Brauen verwendet werden!" villagers: no-trading: "&4Items von Slimefun können nicht zum Handeln verwendet werden!" +cartography_table: + not-working: "&4Slimefun Items können nicht in einem Kartentisch verwendet werden!" miner: no-ores: "&eIch konnte leider keine Erze in der Nähe finden!" From 0457c9cd2425418215fdb24647d1a4139a5d1fff Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 10 Oct 2020 19:37:35 +0200 Subject: [PATCH 111/178] [CI skip] Exclude language updates from discord --- .github/workflows/discord-webhook.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/discord-webhook.yml b/.github/workflows/discord-webhook.yml index f6c11887b..da05e0f9e 100644 --- a/.github/workflows/discord-webhook.yml +++ b/.github/workflows/discord-webhook.yml @@ -4,6 +4,7 @@ on: push: paths: - 'src/**' + - '!src/test/resources/languages/**' - 'pom.xml' jobs: @@ -15,11 +16,13 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v1 - - name: Set up JDK 1.8 - uses: actions/setup-java@master + uses: actions/checkout@v2.3.3 + - name: Set up Java JDK 11 + uses: actions/setup-java@v1.4.3 with: - java-version: 1.8 + java-version: '11' + java-package: jdk + architecture: x64 - name: Run Discord Webhook uses: Slimefun/discord-webhook@master with: From 457153371c388c0b186292f824488057798ac13b Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 10 Oct 2020 19:40:45 +0200 Subject: [PATCH 112/178] [CI skip] I need coffee --- .github/workflows/discord-webhook.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/discord-webhook.yml b/.github/workflows/discord-webhook.yml index da05e0f9e..a4845bb6f 100644 --- a/.github/workflows/discord-webhook.yml +++ b/.github/workflows/discord-webhook.yml @@ -4,7 +4,7 @@ on: push: paths: - 'src/**' - - '!src/test/resources/languages/**' + - '!src/main/resources/languages/**' - 'pom.xml' jobs: From f9928e5e109bdb57b02db1ba755cfad8e701251b Mon Sep 17 00:00:00 2001 From: Silent Date: Sat, 10 Oct 2020 20:20:08 +0200 Subject: [PATCH 113/178] Add requested changes --- .../implementation/items/food/HeavyCream.java | 27 +++++++++++++++---- .../items/misc/StrangeNetherGoo.java | 23 ++++++++++++---- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/HeavyCream.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/HeavyCream.java index 2a10fb906..34f3018b4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/HeavyCream.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/HeavyCream.java @@ -2,27 +2,44 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.food; import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; 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.inventory.ItemStack; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + /** - * This {@link SlimefunItem} can be obtained by crafting and, it's - * used for various food recipes recipes + * This {@link SlimefunItem} can be obtained by crafting, it's + * used for various foods and recipes * * @author TheSilentPro */ -public class HeavyCream extends SlimefunItem { +public class HeavyCream extends SimpleSlimefunItem { + @ParametersAreNonnullByDefault public HeavyCream(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { super(category, item, recipeType, recipe, recipeOutput); } + @Nonnull @Override - public void preRegister() { - addItemHandler((ItemUseHandler) PlayerRightClickEvent::cancel); + public ItemUseHandler getItemHandler() { + return this::use; + } + + public void use(PlayerRightClickEvent e) { + if (e.getClickedBlock().isPresent()) { + if (!e.getClickedBlock().get().getType().isInteractable()) { + e.cancel(); + } + } + else { + e.cancel(); + } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java index b84780f75..36c1ccbd0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java @@ -1,19 +1,23 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.misc; -import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; +import org.bukkit.block.Block; import org.bukkit.entity.Piglin; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; +import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; +import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; import io.github.thebusybiscuit.slimefun4.core.attributes.PiglinBarterDrop; +import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.VillagerRune; 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 javax.annotation.Nonnull; + /** * This {@link SlimefunItem} can only be obtained via bartering with a {@link Piglin}, its * only current uses is the recipe for crafting the {@link VillagerRune}. @@ -24,7 +28,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; * @see PiglinBarterDrop * */ -public class StrangeNetherGoo extends SlimefunItem implements PiglinBarterDrop { +public class StrangeNetherGoo extends SimpleSlimefunItem implements PiglinBarterDrop { private final ItemSetting chance = new IntRangeSetting("barter-chance", 0, 7, 100); @@ -39,9 +43,18 @@ public class StrangeNetherGoo extends SlimefunItem implements PiglinBarterDrop { return chance.getValue(); } + @Nonnull @Override - public void preRegister() { - addItemHandler((ItemUseHandler) PlayerRightClickEvent::cancel); + public ItemUseHandler getItemHandler() { + return this::use; + } + + public void use(PlayerRightClickEvent e) { + if (e.getClickedBlock().isPresent()) { + if (e.getClickedBlock().get().getType().name().contains("SIGN")) { + e.cancel(); + } + } } } From a44f2fa62620989aaba2b4eb255888f981206d98 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 10 Oct 2020 20:46:17 +0200 Subject: [PATCH 114/178] [CI skip] Some cleanup --- .../slimefun4/api/player/StatusEffect.java | 25 +++++++---- .../commands/subcommands/ResearchCommand.java | 3 +- .../commands/subcommands/StatsCommand.java | 3 +- .../slimefun4/core/guide/SlimefunGuide.java | 9 +++- .../core/services/MetricsService.java | 9 +--- .../guide/ChestSlimefunGuide.java | 10 ++++- .../items/blocks/InfusedHopper.java | 3 +- .../items/electric/gadgets/SolarHelmet.java | 3 +- .../items/magical/InfusedMagnet.java | 3 +- .../items/medical/MedicalSupply.java | 44 ++++++++++++------- .../settings/ClimbableSurface.java | 10 ++--- .../slimefun4/utils/tags/TagParser.java | 28 +++++------- 12 files changed, 85 insertions(+), 65 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/StatusEffect.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/StatusEffect.java index c108221ce..d8e658e66 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/StatusEffect.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/StatusEffect.java @@ -4,6 +4,8 @@ import java.util.Optional; import java.util.OptionalInt; import java.util.concurrent.TimeUnit; +import javax.annotation.Nonnull; + import io.github.thebusybiscuit.slimefun4.utils.PatternUtils; import org.bukkit.Keyed; import org.bukkit.NamespacedKey; @@ -27,10 +29,11 @@ public class StatusEffect implements Keyed { private final NamespacedKey key; - public StatusEffect(NamespacedKey key) { + public StatusEffect(@Nonnull NamespacedKey key) { this.key = key; } + @Nonnull @Override public NamespacedKey getKey() { return key; @@ -48,7 +51,7 @@ public class StatusEffect implements Keyed { * @param unit * The {@link TimeUnit} for the given duration */ - public void add(Player p, int duration, TimeUnit unit) { + public void add(@Nonnull Player p, int duration, @Nonnull TimeUnit unit) { add(p, 1, duration, unit); } @@ -64,7 +67,7 @@ public class StatusEffect implements Keyed { * @param unit * The {@link TimeUnit} for the given duration */ - public void add(Player p, int level, int duration, TimeUnit unit) { + public void add(@Nonnull Player p, int level, int duration, @Nonnull TimeUnit unit) { PersistentDataAPI.setString(p, getKey(), level + ";" + System.currentTimeMillis() + unit.toMillis(duration)); } @@ -77,7 +80,7 @@ public class StatusEffect implements Keyed { * @param level * The level of this effect */ - public void addPermanent(Player p, int level) { + public void addPermanent(@Nonnull Player p, int level) { PersistentDataAPI.setString(p, getKey(), level + ";0"); } @@ -91,7 +94,7 @@ public class StatusEffect implements Keyed { * The {@link Player} to check for * @return Whether this {@link StatusEffect} is currently applied */ - public boolean isPresent(Player p) { + public boolean isPresent(@Nonnull Player p) { Optional optional = PersistentDataAPI.getOptionalString(p, getKey()); if (optional.isPresent()) { @@ -99,13 +102,16 @@ public class StatusEffect implements Keyed { long timestamp = Long.parseLong(data[1]); if (timestamp == 0 || timestamp >= System.currentTimeMillis()) { - return true; + { + return true; + } } else { clear(p); return false; } - } else + } else { return false; + } } /** @@ -116,7 +122,8 @@ public class StatusEffect implements Keyed { * The {@link Player} to check for * @return An {@link OptionalInt} that describes the result */ - public OptionalInt getLevel(Player p) { + @Nonnull + public OptionalInt getLevel(@Nonnull Player p) { Optional optional = PersistentDataAPI.getOptionalString(p, getKey()); if (optional.isPresent()) { @@ -133,7 +140,7 @@ public class StatusEffect implements Keyed { * @param p * The {@link Player} to clear it from */ - public void clear(Player p) { + public void clear(@Nonnull Player p) { PersistentDataAPI.remove(p, getKey()); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ResearchCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ResearchCommand.java index dacdb30e2..8bc1d7e2d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ResearchCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ResearchCommand.java @@ -49,8 +49,9 @@ class ResearchCommand extends SubCommand { } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.not-online", true, msg -> msg.replace(PLACEHOLDER_PLAYER, args[1])); } - } else + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true); + } } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf research ")); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/StatsCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/StatsCommand.java index 11abe9817..1bb18b3e6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/StatsCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/StatsCommand.java @@ -29,8 +29,9 @@ class StatsCommand extends SubCommand { } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.not-online", true, msg -> msg.replace("%player%", args[1])); } - } else + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true); + } } else if (sender instanceof Player) { PlayerProfile.get((Player) sender, profile -> profile.sendStats(sender)); } else { 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 0fd23d500..94970ac43 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 @@ -78,15 +78,20 @@ public final class SlimefunGuide { } public static void openCategory(PlayerProfile profile, Category category, SlimefunGuideLayout layout, int selectedPage) { - if (category == null) + if (category == null) { return; + } + SlimefunPlugin.getRegistry().getGuideLayout(layout).openCategory(profile, category, selectedPage); } public static void openSearch(PlayerProfile profile, String input, boolean survival, boolean addToHistory) { SlimefunGuideImplementation layout = SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideLayout.CHEST); - if (!survival) + + if (!survival) { layout = SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideLayout.CHEAT_SHEET); + } + layout.openSearch(profile, input, addToHistory); } 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 2da170c23..5835e9f86 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 @@ -48,12 +48,7 @@ public class MetricsService { private boolean hasDownloadedUpdate = false; static { - Unirest.config() - .concurrency(2, 1) - .setDefaultHeader("User-Agent", "MetricsModule Auto-Updater") - .setDefaultHeader("Accept", "application/vnd.github.v3+json") - .enableCookieManagement(false) - .cookieSpec("ignoreCookies"); + Unirest.config().concurrency(2, 1).setDefaultHeader("User-Agent", "MetricsModule Auto-Updater").setDefaultHeader("Accept", "application/vnd.github.v3+json").enableCookieManagement(false).cookieSpec("ignoreCookies"); } public MetricsService(@Nonnull SlimefunPlugin plugin) { @@ -221,7 +216,7 @@ public class MetricsService { return true; } } catch (UnirestException e) { - plugin.getLogger().log(Level.WARNING, "Failed to fetch the latest jar file from the builds page. Perhaps GitHub is down?"); + plugin.getLogger().log(Level.WARNING, "Failed to fetch the latest jar file from the builds page. Perhaps GitHub is down? Response: {0}", e.getMessage()); } catch (IOException e) { plugin.getLogger().log(Level.WARNING, "Failed to replace the old metric file with the new one. Please do this manually! Error: {0}", e.getMessage()); } 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 5ca33706b..4f346f291 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 @@ -233,16 +233,22 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { menu.addItem(46, ChestMenuUtils.getPreviousButton(p, page, pages)); menu.addMenuClickHandler(46, (pl, slot, item, action) -> { int next = page - 1; - if (next != page && next > 0) + + if (next != page && next > 0) { openCategory(profile, category, next); + } + return false; }); menu.addItem(52, ChestMenuUtils.getNextButton(p, page, pages)); menu.addMenuClickHandler(52, (pl, slot, item, action) -> { int next = page + 1; - if (next != page && next <= pages) + + if (next != page && next <= pages) { openCategory(profile, category, next); + } + return false; }); 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 b94e1305d..26f776093 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 @@ -11,6 +11,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.api.items.settings.DoubleRangeSetting; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; @@ -24,7 +25,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class InfusedHopper extends SimpleSlimefunItem { private final ItemSetting silent = new ItemSetting<>("silent", false); - private final ItemSetting radius = new ItemSetting<>("radius", 3.5); + private final ItemSetting radius = new DoubleRangeSetting("radius", 0.1, 3.5, Double.MAX_VALUE); public InfusedHopper(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/electric/gadgets/SolarHelmet.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/SolarHelmet.java index 681f18922..916dbbffe 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/SolarHelmet.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/SolarHelmet.java @@ -9,6 +9,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.api.items.settings.DoubleRangeSetting; import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; import io.github.thebusybiscuit.slimefun4.implementation.tasks.ArmorTask; import me.mrCookieSlime.Slimefun.Lists.RecipeType; @@ -40,7 +41,7 @@ public class SolarHelmet extends SlimefunItem { throw new IllegalArgumentException("A Solar Helmet must have a positive charging level!"); } - charge = new ItemSetting<>("charge-amount", defaultChargingLevel); + charge = new DoubleRangeSetting("charge-amount", 0.5, defaultChargingLevel, Double.MAX_VALUE); addItemSetting(charge); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/InfusedMagnet.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/InfusedMagnet.java index 4c9b59b09..5a4318044 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/InfusedMagnet.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/InfusedMagnet.java @@ -5,6 +5,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.api.items.settings.DoubleRangeSetting; import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.UnplaceableBlock; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; @@ -21,7 +22,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; */ public class InfusedMagnet extends UnplaceableBlock { - private final ItemSetting radius = new ItemSetting<>("pickup-radius", 6.0); + private final ItemSetting radius = new DoubleRangeSetting("pickup-radius", 0.1, 6.0, Double.MAX_VALUE); public InfusedMagnet(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/medical/MedicalSupply.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/MedicalSupply.java index a3e5fdbbb..7cb19928c 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 @@ -1,5 +1,9 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.medical; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + import javax.annotation.Nonnull; import org.bukkit.attribute.Attribute; @@ -16,12 +20,31 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public abstract class MedicalSupply extends SimpleSlimefunItem { + private final Set curedEffects = new HashSet<>(); private final int healAmount; public MedicalSupply(Category category, int healAmount, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); this.healAmount = healAmount; + + curedEffects.add(PotionEffectType.POISON); + curedEffects.add(PotionEffectType.WITHER); + curedEffects.add(PotionEffectType.SLOW); + curedEffects.add(PotionEffectType.SLOW_DIGGING); + curedEffects.add(PotionEffectType.WEAKNESS); + curedEffects.add(PotionEffectType.CONFUSION); + curedEffects.add(PotionEffectType.BLINDNESS); + curedEffects.add(PotionEffectType.BAD_OMEN); + } + + /** + * This returns the {@link PotionEffect PotionEffects} cured from this {@link MedicalSupply}. + * + * @return An immutable {@link Set} of cured {@link PotionEffect PotionEffects} + */ + public Set getCuredEffects() { + return Collections.unmodifiableSet(curedEffects); } /** @@ -31,22 +54,11 @@ public abstract class MedicalSupply extends SimpleSlimefu * The {@link LivingEntity} to clear the effects from. */ public void clearNegativeEffects(@Nonnull LivingEntity n) { - if (n.hasPotionEffect(PotionEffectType.POISON)) - n.removePotionEffect(PotionEffectType.POISON); - if (n.hasPotionEffect(PotionEffectType.WITHER)) - n.removePotionEffect(PotionEffectType.WITHER); - if (n.hasPotionEffect(PotionEffectType.SLOW)) - n.removePotionEffect(PotionEffectType.SLOW); - if (n.hasPotionEffect(PotionEffectType.SLOW_DIGGING)) - n.removePotionEffect(PotionEffectType.SLOW_DIGGING); - 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.BAD_OMEN); + for (PotionEffectType effect : curedEffects) { + if (n.hasPotionEffect(effect)) { + n.removePotionEffect(effect); + } + } } /** diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/ClimbableSurface.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/ClimbableSurface.java index a430001e3..d88191053 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/ClimbableSurface.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/ClimbableSurface.java @@ -6,6 +6,7 @@ import org.bukkit.Material; import io.github.thebusybiscuit.slimefun4.api.events.ClimbingPickLaunchEvent; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.api.items.settings.DoubleRangeSetting; import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ClimbingPick; /** @@ -17,7 +18,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ClimbingPic * @see ClimbingPickLaunchEvent * */ -public class ClimbableSurface extends ItemSetting { +public class ClimbableSurface extends DoubleRangeSetting { private final Material type; @@ -30,15 +31,10 @@ public class ClimbableSurface extends ItemSetting { * The default launch amount */ public ClimbableSurface(@Nonnull Material surface, double defaultValue) { - super("launch-amounts." + surface.name(), defaultValue); + super("launch-amounts." + surface.name(), 0, defaultValue, Double.MAX_VALUE); this.type = surface; } - @Override - public boolean validateInput(Double input) { - return super.validateInput(input) && input >= 0; - } - /** * This returns the {@link Material} of this surface. * diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java index 769789b05..6b9f10792 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java @@ -104,7 +104,7 @@ public class TagParser implements Keyed { for (JsonElement element : values) { if (element instanceof JsonPrimitive && ((JsonPrimitive) element).isString()) { // Strings will be parsed directly - parsePrimitiveValue(element.getAsString(), materials, tags); + parsePrimitiveValue(element.getAsString(), materials, tags, true); } else if (element instanceof JsonObject) { // JSONObjects can have a "required" property which can make // it optional to resolve the underlying value @@ -126,7 +126,7 @@ public class TagParser implements Keyed { } @ParametersAreNonnullByDefault - private void parsePrimitiveValue(String value, Set materials, Set> tags) throws TagMisconfigurationException { + private void parsePrimitiveValue(String value, Set materials, Set> tags, boolean throwException) throws TagMisconfigurationException { if (PatternUtils.MINECRAFT_MATERIAL.matcher(value).matches()) { // Match the NamespacedKey against Materials Material material = Material.matchMaterial(value); @@ -134,7 +134,7 @@ public class TagParser implements Keyed { if (material != null) { // If the Material could be matched, simply add it to our Set materials.add(material); - } else { + } else if (throwException) { throw new TagMisconfigurationException(key, "Minecraft Material '" + value + "' seems to not exist!"); } } else if (PatternUtils.MINECRAFT_TAG.matcher(value).matches()) { @@ -150,7 +150,7 @@ public class TagParser implements Keyed { } else if (blocksTag != null) { // If no item tag exists, fall back to the block tag tags.add(blocksTag); - } else { + } else if (throwException) { // If both fail, then the tag does not exist. throw new TagMisconfigurationException(key, "There is no '" + value + "' tag in Minecraft."); } @@ -161,10 +161,10 @@ public class TagParser implements Keyed { if (tag != null) { tags.add(tag); - } else { + } else if (throwException) { throw new TagMisconfigurationException(key, "There is no '" + value + "' tag in Slimefun"); } - } else { + } else if (throwException) { // If no RegEx pattern matched, it's malformed. throw new TagMisconfigurationException(key, "Could not recognize value '" + value + "'"); } @@ -177,17 +177,11 @@ public class TagParser implements Keyed { // Check if the entry contains elements of the correct type if (id instanceof JsonPrimitive && ((JsonPrimitive) id).isString() && required instanceof JsonPrimitive && ((JsonPrimitive) required).isBoolean()) { - if (required.getAsBoolean()) { - // If this entry is required, parse it like normal - parsePrimitiveValue(id.getAsString(), materials, tags); - } else { - // If the entry is not required, validation will be optional - try { - parsePrimitiveValue(id.getAsString(), materials, tags); - } catch (TagMisconfigurationException x) { - // This is an optional entry, so we will ignore the validation here - } - } + boolean isRequired = required.getAsBoolean(); + + // If the Tag is required, an exception may be thrown. + // Otherwise it will just ignore the value + parsePrimitiveValue(id.getAsString(), materials, tags, isRequired); } else { throw new TagMisconfigurationException(key, "Found a JSON Object value without an id!"); } From 594d322df2e0611cb7fa4525eef7b598ca1e00e9 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 10 Oct 2020 21:20:25 +0200 Subject: [PATCH 115/178] [CI skip] Added EnumSetting --- .../slimefun4/api/items/ItemSetting.java | 12 ++++ .../items/settings/DoubleRangeSetting.java | 11 +++- .../api/items/settings/EnumSetting.java | 63 +++++++++++++++++++ .../api/items/settings/IntRangeSetting.java | 11 +++- 4 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/EnumSetting.java diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java index 7f0d27af6..68266f5d2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java @@ -119,6 +119,17 @@ public class ItemSetting { return c.isInstance(defaultValue); } + /** + * This is an error message which should provide further context on what values + * are allowed. + * + * @return An error message which is displayed when this {@link ItemSetting} is misconfigured. + */ + @Nonnull + protected String getErrorMessage() { + return "Only '" + defaultValue.getClass().getSimpleName() + "' values are allowed!"; + } + /** * This method is called by a {@link SlimefunItem} which wants to load its {@link ItemSetting} * from the {@link Config} file. @@ -138,6 +149,7 @@ public class ItemSetting { Slimefun.getLogger().log(Level.WARNING, "Slimefun has found an invalid config setting in your Items.yml!"); Slimefun.getLogger().log(Level.WARNING, " at \"{0}.{1}\"", new Object[] { item.getID(), getKey() }); Slimefun.getLogger().log(Level.WARNING, "{0} is not a valid input!", configuredValue); + Slimefun.getLogger().log(Level.WARNING, getErrorMessage()); } } else { this.value = defaultValue; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/DoubleRangeSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/DoubleRangeSetting.java index e83ebf1d7..82ea0e2c0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/DoubleRangeSetting.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/DoubleRangeSetting.java @@ -1,5 +1,6 @@ package io.github.thebusybiscuit.slimefun4.api.items.settings; +import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; @@ -27,6 +28,12 @@ public class DoubleRangeSetting extends ItemSetting { this.max = max; } + @Nonnull + @Override + protected String getErrorMessage() { + return "Only decimal numbers from " + min + '-' + max + "(inclusive) are allowed!"; + } + @Override public boolean validateInput(Double input) { return super.validateInput(input) && input >= min && input <= max; @@ -37,7 +44,7 @@ public class DoubleRangeSetting extends ItemSetting { * * @return The minimum value */ - public double getMinimum() { + public final double getMinimum() { return min; } @@ -46,7 +53,7 @@ public class DoubleRangeSetting extends ItemSetting { * * @return The maximum value */ - public double getMaximum() { + public final double getMaximum() { return max; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/EnumSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/EnumSetting.java new file mode 100644 index 000000000..54f9e25e3 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/EnumSetting.java @@ -0,0 +1,63 @@ +package io.github.thebusybiscuit.slimefun4.api.items.settings; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + +import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; + +/** + * This variation of {@link ItemSetting} allows you to allow {@link Enum} constants to be + * used for {@link ItemSetting} validation. + * + * @author TheBusyBiscuit + * + * @see ItemSetting + * + */ +public class EnumSetting> extends ItemSetting { + + private final Class enumClass; + + @ParametersAreNonnullByDefault + public EnumSetting(String key, Class enumClass, T defaultValue) { + super(key, defaultValue.name()); + + this.enumClass = enumClass; + } + + @Nonnull + @Override + protected String getErrorMessage() { + String values = Arrays.stream(getAllowedValues()).map(Enum::name).collect(Collectors.joining(", ")); + return "The following values are valid: " + values; + } + + /** + * This returns an array of valid {@link Enum} values. + * This method may be overridden to further limit the allowed values. + * + * @return An array of allowed {@link Enum} constants. + */ + public Enum[] getAllowedValues() { + return enumClass.getEnumConstants(); + } + + @Override + public boolean validateInput(String input) { + if (!super.validateInput(input)) { + return false; + } else { + for (Enum value : getAllowedValues()) { + if (value.name().equals(input)) { + return true; + } + } + + return false; + } + } + +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java index 90856147f..b3a54e04e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java @@ -1,5 +1,6 @@ package io.github.thebusybiscuit.slimefun4.api.items.settings; +import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; @@ -27,6 +28,12 @@ public class IntRangeSetting extends ItemSetting { this.max = max; } + @Nonnull + @Override + protected String getErrorMessage() { + return "Only whole numbers from " + min + '-' + max + "(inclusive) are allowed!"; + } + @Override public boolean validateInput(Integer input) { return super.validateInput(input) && input >= min && input <= max; @@ -37,7 +44,7 @@ public class IntRangeSetting extends ItemSetting { * * @return The minimum value */ - public int getMinimum() { + public final int getMinimum() { return min; } @@ -46,7 +53,7 @@ public class IntRangeSetting extends ItemSetting { * * @return The maximum value */ - public int getMaximum() { + public final int getMaximum() { return max; } From bf25fc0b9d4d90eade979b41865faf3f9ba358ec Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 10 Oct 2020 21:55:54 +0200 Subject: [PATCH 116/178] [CI skip] Added Unit Tests for new Item Settings --- .../items/settings/DoubleRangeSetting.java | 3 + .../api/items/settings/EnumSetting.java | 13 +++- .../api/items/settings/IntRangeSetting.java | 3 + .../items/settings/MaterialTagSetting.java | 8 +- .../items/electric/gadgets/SolarHelmet.java | 2 +- .../settings/TestDoubleRangeSetting.java | 76 +++++++++++++++++++ .../tests/settings/TestEnumSetting.java | 68 +++++++++++++++++ .../tests/settings/TestIntRangeSetting.java | 76 +++++++++++++++++++ .../{items => settings}/TestItemSettings.java | 22 ++++-- .../settings/TestMaterialTagSetting.java | 76 +++++++++++++++++++ 10 files changed, 335 insertions(+), 12 deletions(-) create mode 100644 src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/settings/TestDoubleRangeSetting.java create mode 100644 src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/settings/TestEnumSetting.java create mode 100644 src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/settings/TestIntRangeSetting.java rename src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/{items => settings}/TestItemSettings.java (83%) create mode 100644 src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/settings/TestMaterialTagSetting.java diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/DoubleRangeSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/DoubleRangeSetting.java index 82ea0e2c0..86b02ac05 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/DoubleRangeSetting.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/DoubleRangeSetting.java @@ -3,6 +3,8 @@ package io.github.thebusybiscuit.slimefun4.api.items.settings; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import org.apache.commons.lang.Validate; + import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; /** @@ -23,6 +25,7 @@ public class DoubleRangeSetting extends ItemSetting { @ParametersAreNonnullByDefault public DoubleRangeSetting(String key, double min, double defaultValue, double max) { super(key, defaultValue); + Validate.isTrue(defaultValue >= min && defaultValue <= max, "The default value is not in range."); this.min = min; this.max = max; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/EnumSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/EnumSetting.java index 54f9e25e3..d952286af 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/EnumSetting.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/EnumSetting.java @@ -39,12 +39,21 @@ public class EnumSetting> extends ItemSetting { * This returns an array of valid {@link Enum} values. * This method may be overridden to further limit the allowed values. * - * @return An array of allowed {@link Enum} constants. + * @return An array of allowed {@link Enum} constants */ - public Enum[] getAllowedValues() { + public T[] getAllowedValues() { return enumClass.getEnumConstants(); } + /** + * This will attempt to get the configured value as a constant of the desired {@link Enum}. + * + * @return The value as an {@link Enum} constant + */ + public T getAsEnumConstant() { + return Enum.valueOf(enumClass, getValue()); + } + @Override public boolean validateInput(String input) { if (!super.validateInput(input)) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java index b3a54e04e..f4b41ed38 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java @@ -3,6 +3,8 @@ package io.github.thebusybiscuit.slimefun4.api.items.settings; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import org.apache.commons.lang.Validate; + import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; /** @@ -23,6 +25,7 @@ public class IntRangeSetting extends ItemSetting { @ParametersAreNonnullByDefault public IntRangeSetting(String key, int min, int defaultValue, int max) { super(key, defaultValue); + Validate.isTrue(defaultValue >= min && defaultValue <= max, "The default value is not in range."); this.min = min; this.max = max; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/MaterialTagSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/MaterialTagSetting.java index cddaa8af6..b856d5614 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/MaterialTagSetting.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/MaterialTagSetting.java @@ -44,9 +44,15 @@ public class MaterialTagSetting extends ItemSetting> { return defaultTag; } + @Nonnull + @Override + protected String getErrorMessage() { + return "This List can only contain Materials in the format of e.g. REDSTONE_BLOCK"; + } + @Override public boolean validateInput(List input) { - if (input != null) { + if (super.validateInput(input)) { for (String value : input) { Material material = Material.matchMaterial(value); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/SolarHelmet.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/SolarHelmet.java index 916dbbffe..e539a845b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/SolarHelmet.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/SolarHelmet.java @@ -41,7 +41,7 @@ public class SolarHelmet extends SlimefunItem { throw new IllegalArgumentException("A Solar Helmet must have a positive charging level!"); } - charge = new DoubleRangeSetting("charge-amount", 0.5, defaultChargingLevel, Double.MAX_VALUE); + charge = new DoubleRangeSetting("charge-amount", 0.01, defaultChargingLevel, Double.MAX_VALUE); addItemSetting(charge); } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/settings/TestDoubleRangeSetting.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/settings/TestDoubleRangeSetting.java new file mode 100644 index 000000000..e99f1c15a --- /dev/null +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/settings/TestDoubleRangeSetting.java @@ -0,0 +1,76 @@ +package io.github.thebusybiscuit.slimefun4.testing.tests.settings; + +import org.bukkit.Material; +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.cscorelib2.item.CustomItem; +import io.github.thebusybiscuit.slimefun4.api.items.settings.DoubleRangeSetting; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.testing.TestUtilities; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; + +class TestDoubleRangeSetting { + + private static SlimefunPlugin plugin; + private final double min = 0.0; + private final double max = 1.0; + + @BeforeAll + public static void load() { + MockBukkit.mock(); + plugin = MockBukkit.load(SlimefunPlugin.class); + } + + @AfterAll + public static void unload() { + MockBukkit.unmock(); + } + + @Test + @DisplayName("Test Constructor validation") + void testConstructorValidation() { + Assertions.assertThrows(IllegalArgumentException.class, () -> new DoubleRangeSetting("test", min, -1.0, max)); + } + + @Test + @DisplayName("Test min and max getters") + void testMinMaxGetters() { + DoubleRangeSetting setting = new DoubleRangeSetting("test", min, 0.5, max); + + Assertions.assertEquals(min, setting.getMinimum()); + Assertions.assertEquals(max, setting.getMaximum()); + } + + @Test + @DisplayName("Test illegal values") + void testIllegalValues() { + DoubleRangeSetting setting = new DoubleRangeSetting("test", min, 0.5, max); + + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "DOUBLE_RANGE_TEST", new CustomItem(Material.DIAMOND, "&cTest")); + item.addItemSetting(setting); + item.register(plugin); + + Assertions.assertThrows(IllegalArgumentException.class, () -> setting.update(null)); + Assertions.assertThrows(IllegalArgumentException.class, () -> setting.update(-0.1)); + Assertions.assertThrows(IllegalArgumentException.class, () -> setting.update(1.1)); + } + + @Test + @DisplayName("Test allowed value") + void testAllowedValue() { + DoubleRangeSetting setting = new DoubleRangeSetting("test", min, 0.25, max); + + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "DOUBLE_RANGE_TEST_2", new CustomItem(Material.DIAMOND, "&cTest")); + item.addItemSetting(setting); + item.register(plugin); + + Assertions.assertEquals(0.25, setting.getValue()); + setting.update(0.75); + Assertions.assertEquals(0.75, setting.getValue()); + } +} diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/settings/TestEnumSetting.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/settings/TestEnumSetting.java new file mode 100644 index 000000000..b6d377040 --- /dev/null +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/settings/TestEnumSetting.java @@ -0,0 +1,68 @@ +package io.github.thebusybiscuit.slimefun4.testing.tests.settings; + +import org.bukkit.Material; +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.cscorelib2.item.CustomItem; +import io.github.thebusybiscuit.slimefun4.api.items.settings.EnumSetting; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.testing.TestUtilities; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; + +class TestEnumSetting { + + private static SlimefunPlugin plugin; + + @BeforeAll + public static void load() { + MockBukkit.mock(); + plugin = MockBukkit.load(SlimefunPlugin.class); + } + + @AfterAll + public static void unload() { + MockBukkit.unmock(); + } + + @Test + @DisplayName("Test Enum Getters") + void testEnumGetters() { + EnumSetting setting = new EnumSetting<>("test", Material.class, Material.DIAMOND); + Assertions.assertArrayEquals(Material.values(), setting.getAllowedValues()); + } + + @Test + @DisplayName("Test illegal values") + void testIllegalValues() { + EnumSetting setting = new EnumSetting<>("test", Material.class, Material.DIAMOND); + + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ENUM_SETTING_TEST", new CustomItem(Material.DIAMOND, "&cTest")); + item.addItemSetting(setting); + item.register(plugin); + + Assertions.assertThrows(IllegalArgumentException.class, () -> setting.update("I_DO_NOT_EXIST")); + Assertions.assertThrows(IllegalArgumentException.class, () -> setting.update(null)); + } + + @Test + @DisplayName("Test allowed value") + void testAllowedValue() { + EnumSetting setting = new EnumSetting<>("test", Material.class, Material.DIAMOND); + + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MATERIAL_SETTING_TEST_2", new CustomItem(Material.DIAMOND, "&cTest")); + item.addItemSetting(setting); + item.register(plugin); + + Assertions.assertEquals(Material.DIAMOND.name(), setting.getValue()); + Assertions.assertEquals(Material.DIAMOND, setting.getAsEnumConstant()); + + setting.update(Material.EMERALD.name()); + Assertions.assertEquals(Material.EMERALD.name(), setting.getValue()); + Assertions.assertEquals(Material.EMERALD, setting.getAsEnumConstant()); + } +} diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/settings/TestIntRangeSetting.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/settings/TestIntRangeSetting.java new file mode 100644 index 000000000..1ca8841d5 --- /dev/null +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/settings/TestIntRangeSetting.java @@ -0,0 +1,76 @@ +package io.github.thebusybiscuit.slimefun4.testing.tests.settings; + +import org.bukkit.Material; +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.cscorelib2.item.CustomItem; +import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.testing.TestUtilities; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; + +class TestIntRangeSetting { + + private static SlimefunPlugin plugin; + private final int min = 0; + private final int max = 100; + + @BeforeAll + public static void load() { + MockBukkit.mock(); + plugin = MockBukkit.load(SlimefunPlugin.class); + } + + @AfterAll + public static void unload() { + MockBukkit.unmock(); + } + + @Test + @DisplayName("Test Constructor validation") + void testConstructorValidation() { + Assertions.assertThrows(IllegalArgumentException.class, () -> new IntRangeSetting("test", min, -50, max)); + } + + @Test + @DisplayName("Test min and max getters") + void testMinMaxGetters() { + IntRangeSetting setting = new IntRangeSetting("test", min, 1, max); + + Assertions.assertEquals(min, setting.getMinimum()); + Assertions.assertEquals(max, setting.getMaximum()); + } + + @Test + @DisplayName("Test illegal values") + void testIllegalValues() { + IntRangeSetting setting = new IntRangeSetting("test", min, 1, max); + + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "INT_RANGE_TEST", new CustomItem(Material.DIAMOND, "&cTest")); + item.addItemSetting(setting); + item.register(plugin); + + Assertions.assertThrows(IllegalArgumentException.class, () -> setting.update(null)); + Assertions.assertThrows(IllegalArgumentException.class, () -> setting.update(-1)); + Assertions.assertThrows(IllegalArgumentException.class, () -> setting.update(101)); + } + + @Test + @DisplayName("Test allowed value") + void testAllowedValue() { + IntRangeSetting setting = new IntRangeSetting("test", min, 1, max); + + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "INT_RANGE_TEST_2", new CustomItem(Material.DIAMOND, "&cTest")); + item.addItemSetting(setting); + item.register(plugin); + + Assertions.assertEquals(1, setting.getValue()); + setting.update(42); + Assertions.assertEquals(42, setting.getValue()); + } +} diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestItemSettings.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/settings/TestItemSettings.java similarity index 83% rename from src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestItemSettings.java rename to src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/settings/TestItemSettings.java index 394d21648..eedfd3ab8 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestItemSettings.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/settings/TestItemSettings.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.testing.tests.items; +package io.github.thebusybiscuit.slimefun4.testing.tests.settings; import java.util.Optional; @@ -6,6 +6,7 @@ import org.bukkit.Material; 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 TestItemSettings { +class TestItemSettings { private static SlimefunPlugin plugin; @@ -31,7 +32,8 @@ public class TestItemSettings { } @Test - public void testIllegalItemSettings() { + @DisplayName("Test illegal Item Settings arguments") + void testIllegalItemSettings() { SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_SETTINGS_TEST", new CustomItem(Material.DIAMOND, "&cTest")); item.register(plugin); @@ -42,7 +44,8 @@ public class TestItemSettings { } @Test - public void testAddItemSetting() { + @DisplayName("Test adding an Item Setting") + void testAddItemSetting() { SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_SETTINGS_TEST_2", new CustomItem(Material.DIAMOND, "&cTest")); ItemSetting setting = new ItemSetting<>("test", "Hello World"); @@ -64,7 +67,8 @@ public class TestItemSettings { } @Test - public void testUpdateItemSetting() { + @DisplayName("Test updating an Item Settings value") + void testUpdateItemSetting() { SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_SETTINGS_TEST_3", new CustomItem(Material.DIAMOND, "&cTest")); ItemSetting setting = new ItemSetting<>("test", "Hello World"); @@ -80,10 +84,12 @@ public class TestItemSettings { } @Test - public void testAlreadyExistingItemSetting() { + @DisplayName("Test Item Settings double-registration") + void testAlreadyExistingItemSetting() { SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_SETTINGS_TEST", new CustomItem(Material.DIAMOND, "&cTest")); + ItemSetting setting = new ItemSetting<>("test", "Hello World"); - item.addItemSetting(new ItemSetting<>("test", "Hello World")); - Assertions.assertThrows(IllegalArgumentException.class, () -> item.addItemSetting(new ItemSetting<>("test", "Hello World"))); + item.addItemSetting(setting); + Assertions.assertThrows(IllegalArgumentException.class, () -> item.addItemSetting(setting)); } } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/settings/TestMaterialTagSetting.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/settings/TestMaterialTagSetting.java new file mode 100644 index 000000000..4edb31b01 --- /dev/null +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/settings/TestMaterialTagSetting.java @@ -0,0 +1,76 @@ +package io.github.thebusybiscuit.slimefun4.testing.tests.settings; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import org.bukkit.Material; +import org.bukkit.Tag; +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.cscorelib2.item.CustomItem; +import io.github.thebusybiscuit.slimefun4.api.items.settings.MaterialTagSetting; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.testing.TestUtilities; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; + +class TestMaterialTagSetting { + + private static SlimefunPlugin plugin; + private static Tag tag; + + @BeforeAll + public static void load() { + MockBukkit.mock(); + plugin = MockBukkit.load(SlimefunPlugin.class); + tag = Tag.LOGS; + } + + @AfterAll + public static void unload() { + MockBukkit.unmock(); + } + + @Test + @DisplayName("Test Constructor") + void testConstructorValidation() { + MaterialTagSetting setting = new MaterialTagSetting("test", tag); + Assertions.assertEquals(tag, setting.getDefaultTag()); + } + + @Test + @DisplayName("Test illegal values") + void testIllegalValues() { + MaterialTagSetting setting = new MaterialTagSetting("test", tag); + + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MATERIAL_SETTING_TEST", new CustomItem(Material.DIAMOND, "&cTest")); + item.addItemSetting(setting); + item.register(plugin); + + List materials = Arrays.asList("I_DO_NOT_EXIST"); + Assertions.assertThrows(IllegalArgumentException.class, () -> setting.update(materials)); + Assertions.assertThrows(IllegalArgumentException.class, () -> setting.update(null)); + } + + @Test + @DisplayName("Test allowed value") + void testAllowedValue() { + MaterialTagSetting setting = new MaterialTagSetting("test", tag); + + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MATERIAL_SETTING_TEST_2", new CustomItem(Material.DIAMOND, "&cTest")); + item.addItemSetting(setting); + item.register(plugin); + + List tagContents = tag.getValues().stream().map(Material::name).collect(Collectors.toList()); + Assertions.assertIterableEquals(tagContents, setting.getValue()); + + List materials = Arrays.asList(Material.REDSTONE.name(), Material.DIAMOND.name()); + setting.update(materials); + Assertions.assertIterableEquals(materials, setting.getValue()); + } +} From dfe33b35346c24552ed949b4d1756b43c7bfd447 Mon Sep 17 00:00:00 2001 From: Silent Date: Sat, 10 Oct 2020 22:05:50 +0200 Subject: [PATCH 117/178] Didn't know this existed --- .../slimefun4/implementation/items/misc/StrangeNetherGoo.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java index 36c1ccbd0..3a66362d6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java @@ -1,5 +1,6 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.misc; +import org.bukkit.Tag; import org.bukkit.block.Block; import org.bukkit.entity.Piglin; import org.bukkit.inventory.ItemStack; @@ -51,7 +52,7 @@ public class StrangeNetherGoo extends SimpleSlimefunItem impleme public void use(PlayerRightClickEvent e) { if (e.getClickedBlock().isPresent()) { - if (e.getClickedBlock().get().getType().name().contains("SIGN")) { + if (Tag.SIGNS.isTagged(e.getClickedBlock().get().getType())) { e.cancel(); } } From 05d7ab5643ca71ebbb33509ed7c6d4c21ab135ee Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sun, 11 Oct 2020 00:12:42 +0300 Subject: [PATCH 118/178] Update ExplosiveTool.java --- .../slimefun4/implementation/items/tools/ExplosiveTool.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java index f9c9a78dc..0d5a67c57 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java @@ -52,6 +52,8 @@ class ExplosiveTool extends SimpleSlimefunItem implements NotPla @Override public ToolUseHandler getItemHandler() { return (e, tool, fortune, drops) -> { + if (e.isCancelled()) return; + Player p = e.getPlayer(); Block b = e.getBlock(); From bf3e6754cc0539a4f1a5553befe83e58997580e9 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sun, 11 Oct 2020 00:19:15 +0300 Subject: [PATCH 119/178] Changed event priorities. --- .../slimefun4/implementation/listeners/BlockListener.java | 4 ++-- 1 file changed, 2 insertions(+), 2 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 28f037681..a20780be7 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 @@ -63,7 +63,7 @@ public class BlockListener implements Listener { sensitiveMaterials.addAll(Tag.WOODEN_PRESSURE_PLATES.getValues()); } - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBlockPlace(BlockPlaceEvent e) { if (BlockStorage.hasBlockInfo(e.getBlock())) { e.setCancelled(true); @@ -87,7 +87,7 @@ public class BlockListener implements Listener { } } - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBlockBreak(BlockBreakEvent e) { checkForSensitiveBlockAbove(e.getPlayer(), e.getBlock()); From fdd33f91828ed6214dcf3b1cf08b0c8070d7c6e3 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sun, 11 Oct 2020 00:20:02 +0300 Subject: [PATCH 120/178] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5f708932..0fabb6e64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,7 @@ * Fixed #2391 * Fixed #2403 * Fixed #2405 +* Fixed #2439 ## Release Candidate 16 (07 Sep 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 From d3c0a110a985f8b7e5212f1c2452a9020e842bf7 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sun, 11 Oct 2020 00:31:06 +0300 Subject: [PATCH 121/178] Changed capacitor recipe. --- .../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 1506d76a7..260bee75b 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 @@ -1516,7 +1516,7 @@ public final class SlimefunItemSetup { .register(plugin); new Capacitor(categories.electricity, 128, SlimefunItems.SMALL_CAPACITOR, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {SlimefunItems.DURALUMIN_INGOT, SlimefunItems.REDSTONE_ALLOY, SlimefunItems.DURALUMIN_INGOT, new ItemStack(Material.REDSTONE), SlimefunItems.SULFATE, new ItemStack(Material.REDSTONE), SlimefunItems.DURALUMIN_INGOT, SlimefunItems.REDSTONE_ALLOY, SlimefunItems.DURALUMIN_INGOT}) + new ItemStack[] {SlimefunItems.DURALUMIN_INGOT, SlimefunItems.SULFATE, SlimefunItems.DURALUMIN_INGOT, SlimefunItems.REDSTONE_ALLOY, SlimefunItems.ENERGY_CONNECTOR, SlimefunItems.REDSTONE_ALLOY, SlimefunItems.DURALUMIN_INGOT, new ItemStack(Material.REDSTONE), SlimefunItems.DURALUMIN_INGOT}) .register(plugin); new Capacitor(categories.electricity, 512, SlimefunItems.MEDIUM_CAPACITOR, RecipeType.ENHANCED_CRAFTING_TABLE, From 957bcd9a3a03561cbb1b592e80f824809f5f89c0 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sun, 11 Oct 2020 02:01:54 +0300 Subject: [PATCH 122/178] Update src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java Co-authored-by: TheBusyBiscuit --- .../slimefun4/implementation/listeners/BlockListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 57f0d8b38..0ef709cd9 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 @@ -75,7 +75,7 @@ public class BlockListener implements Listener { } } - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockBreak(BlockBreakEvent e) { checkForSensitiveBlockAbove(e.getPlayer(), e.getBlock()); From 4a91e99be60703770817e1444234e3daadf4fdb9 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 11 Oct 2020 01:02:39 +0200 Subject: [PATCH 123/178] [CI skip] Restructuring test classes --- .../{implementations => }/backpacks/TestEnderBackpack.java | 2 +- .../tests/items/{implementations => }/food/TestDietCookie.java | 2 +- .../tests/items/{implementations => }/food/TestMeatJerky.java | 2 +- .../items/{implementations => }/food/TestMonsterJerky.java | 2 +- .../items/{implementations => }/tools/TestClimbingPick.java | 2 +- .../items/{implementations => }/tools/TestPortableDustbin.java | 2 +- .../testing/tests/{items => registration}/TestCategories.java | 2 +- .../testing/tests/{items => registration}/TestItemHandlers.java | 2 +- .../testing/tests/{items => registration}/TestItemSetup.java | 2 +- .../tests/{items => registration}/TestRechargeableItems.java | 2 +- .../{items => registration}/TestSlimefunItemRegistration.java | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) rename src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/{implementations => }/backpacks/TestEnderBackpack.java (95%) rename src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/{implementations => }/food/TestDietCookie.java (96%) rename src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/{implementations => }/food/TestMeatJerky.java (95%) rename src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/{implementations => }/food/TestMonsterJerky.java (96%) rename src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/{implementations => }/tools/TestClimbingPick.java (98%) rename src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/{implementations => }/tools/TestPortableDustbin.java (96%) rename src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/{items => registration}/TestCategories.java (99%) rename src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/{items => registration}/TestItemHandlers.java (98%) rename src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/{items => registration}/TestItemSetup.java (97%) rename src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/{items => registration}/TestRechargeableItems.java (98%) rename src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/{items => registration}/TestSlimefunItemRegistration.java (99%) diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/backpacks/TestEnderBackpack.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/backpacks/TestEnderBackpack.java similarity index 95% rename from src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/backpacks/TestEnderBackpack.java rename to src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/backpacks/TestEnderBackpack.java index 12fab7fa3..5e50a08e0 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/backpacks/TestEnderBackpack.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/backpacks/TestEnderBackpack.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.testing.tests.items.implementations.backpacks; +package io.github.thebusybiscuit.slimefun4.testing.tests.items.backpacks; import org.bukkit.Material; import org.bukkit.entity.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/food/TestDietCookie.java similarity index 96% rename from src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/food/TestDietCookie.java rename to src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/food/TestDietCookie.java index 606c2acff..75bf7f6a9 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/food/TestDietCookie.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.testing.tests.items.implementations.food; +package io.github.thebusybiscuit.slimefun4.testing.tests.items.food; import org.bukkit.Material; import org.bukkit.Sound; 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/food/TestMeatJerky.java similarity index 95% rename from src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/food/TestMeatJerky.java rename to src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/food/TestMeatJerky.java index 40aba208c..18fc7c29c 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/food/TestMeatJerky.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.testing.tests.items.implementations.food; +package io.github.thebusybiscuit.slimefun4.testing.tests.items.food; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; 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/food/TestMonsterJerky.java similarity index 96% rename from src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/food/TestMonsterJerky.java rename to src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/food/TestMonsterJerky.java index 4b23f7d20..b326cfb20 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/food/TestMonsterJerky.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.testing.tests.items.implementations.food; +package io.github.thebusybiscuit.slimefun4.testing.tests.items.food; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/tools/TestClimbingPick.java similarity index 98% rename from src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java rename to src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/tools/TestClimbingPick.java index 8eec62f8e..89dd43be8 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/tools/TestClimbingPick.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.testing.tests.items.implementations.tools; +package io.github.thebusybiscuit.slimefun4.testing.tests.items.tools; import java.util.stream.Stream; 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/tools/TestPortableDustbin.java similarity index 96% rename from src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestPortableDustbin.java rename to src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/tools/TestPortableDustbin.java index 41ac7fe2c..14b41c9ac 100644 --- 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/tools/TestPortableDustbin.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.testing.tests.items.implementations.tools; +package io.github.thebusybiscuit.slimefun4.testing.tests.items.tools; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestCategories.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/registration/TestCategories.java similarity index 99% rename from src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestCategories.java rename to src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/registration/TestCategories.java index bd4bf5d7e..5a6d87450 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestCategories.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/registration/TestCategories.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.testing.tests.items; +package io.github.thebusybiscuit.slimefun4.testing.tests.registration; import java.time.LocalDate; import java.time.Month; diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestItemHandlers.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/registration/TestItemHandlers.java similarity index 98% rename from src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestItemHandlers.java rename to src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/registration/TestItemHandlers.java index e28d9cb7b..81c675d3f 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestItemHandlers.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/registration/TestItemHandlers.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.testing.tests.items; +package io.github.thebusybiscuit.slimefun4.testing.tests.registration; import java.util.Map; import java.util.Optional; diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestItemSetup.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/registration/TestItemSetup.java similarity index 97% rename from src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestItemSetup.java rename to src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/registration/TestItemSetup.java index 86462ab4c..ae0589208 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestItemSetup.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/registration/TestItemSetup.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.testing.tests.items; +package io.github.thebusybiscuit.slimefun4.testing.tests.registration; import java.io.BufferedReader; import java.io.IOException; diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestRechargeableItems.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/registration/TestRechargeableItems.java similarity index 98% rename from src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestRechargeableItems.java rename to src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/registration/TestRechargeableItems.java index f4fde025c..097f745ed 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestRechargeableItems.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/registration/TestRechargeableItems.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.testing.tests.items; +package io.github.thebusybiscuit.slimefun4.testing.tests.registration; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestSlimefunItemRegistration.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/registration/TestSlimefunItemRegistration.java similarity index 99% rename from src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestSlimefunItemRegistration.java rename to src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/registration/TestSlimefunItemRegistration.java index 490de2e34..9fa917323 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestSlimefunItemRegistration.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/registration/TestSlimefunItemRegistration.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.testing.tests.items; +package io.github.thebusybiscuit.slimefun4.testing.tests.registration; import java.util.Optional; From 1fb8a2f66c95a7fbb99a1bbdad20d3f3dd29b3ee Mon Sep 17 00:00:00 2001 From: Pierre Date: Sat, 10 Oct 2020 23:22:38 +0000 Subject: [PATCH 124/178] Translate researches_fr.yml via GitLocalize --- src/main/resources/languages/researches_fr.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/resources/languages/researches_fr.yml b/src/main/resources/languages/researches_fr.yml index 2687e13d9..673bb4c2f 100644 --- a/src/main/resources/languages/researches_fr.yml +++ b/src/main/resources/languages/researches_fr.yml @@ -143,8 +143,8 @@ slimefun: oil: Pétrole fuel: Fioul hologram_projector: Hologrammes - capacitors: Condensateurs de niveau 1 - high_tier_capacitors: Condensateurs de niveau 2 + capacitors: Condensateur de niveau 1 + high_tier_capacitors: Condensateur de niveau 2 solar_generators: Centrale solaire electric_furnaces: Fourneau électrique electric_ore_grinding: Concassage et broyage @@ -243,3 +243,6 @@ slimefun: climbing_pick: Piolet d'escalade shulker_shell: Carapace de Shulker synthétique villager_rune: Réinitialiser les échanges des villageois + caveman_talisman: Talisman de l'Homme des cavernes + even_higher_tier_capacitors: Condensateurs de niveau 3 + elytra_cap: Matériel d'urgence From b7da3d816dc52610d0e7793a181762c263715ad4 Mon Sep 17 00:00:00 2001 From: Pierre Date: Sat, 10 Oct 2020 23:22:55 +0000 Subject: [PATCH 125/178] Translate messages_fr.yml via GitLocalize --- src/main/resources/languages/messages_fr.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/resources/languages/messages_fr.yml b/src/main/resources/languages/messages_fr.yml index d65854159..80d93db36 100644 --- a/src/main/resources/languages/messages_fr.yml +++ b/src/main/resources/languages/messages_fr.yml @@ -21,6 +21,10 @@ commands: backpack-does-not-exist: "&4Le sac à dos spécifié n'existe pas!" restored-backpack-given: "&aVotre sac à dos a été restauré et a été ajouté à votre inventaire!" + charge: + description: Charge l'objet que vous avez en main + charge-success: L'objet a été chargé ! + not-rechargeable: Cet objet ne peut pas être chargé ! guide: search: message: "&bQue souhaitez-vous rechercher?" @@ -133,6 +137,7 @@ messages: whirlwind: "&a&oVotre talisman a renvoyé le projectile" wizard: "&a&oVotre talisman vous a donné un meilleur niveau de Fortune mais a peut-être diminué plusieurs autres enchantements" + caveman: "&a&oVotre Talisman vous a donné Célérité" soulbound-rune: fail: "&cVous pouvez lier un seul objet à la fois à votre âme" success: "&aVous avez réussi à lier cet objet à votre âme! Vous le garderez quand @@ -335,7 +340,6 @@ languages: zh-CN: Chinois (Chine) el: Grec he: Hébreu - pt-BR: Portugais (Brésil) ar: Arabe af: Afrikaans da: Danois @@ -348,6 +352,7 @@ languages: th: Thaï ro: Roumain pt: Portugais (Portugal) + pt-BR: Portugais (Brésil) bg: Bulgare ko: Coréen tr: Turc @@ -361,5 +366,8 @@ brewing_stand: villagers: no-trading: "&4Vous ne pouvez pas échanger des objets Slimefun avec les villageois !" +cartography_table: + not-working: "&4Vous ne pouvez pas utiliser d'objets Slimefun dans une table de + cartographie !" miner: no-ores: "&eDésolé, je n'ai pas pu trouver de minerai à proximité !" From bc6ac0a4d1404455e1a8f91b24d4d3bd19c321c0 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 11 Oct 2020 01:27:38 +0200 Subject: [PATCH 126/178] [CI skip] Added Tape Measure Unit Tests --- .../items/tools/TapeMeasure.java | 22 ++- .../testing/interfaces/SlimefunItemTest.java | 10 +- .../tests/items/tools/TestClimbingPick.java | 2 +- .../tests/items/tools/TestTapeMeasure.java | 148 ++++++++++++++++++ 4 files changed, 175 insertions(+), 7 deletions(-) create mode 100644 src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/tools/TestTapeMeasure.java 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 ff1ce7a98..79baeb90b 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 @@ -2,6 +2,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.tools; import java.text.DecimalFormat; import java.util.Optional; +import java.util.OptionalDouble; import java.util.UUID; import javax.annotation.Nonnull; @@ -9,6 +10,7 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Location; import org.bukkit.NamespacedKey; +import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -77,9 +79,20 @@ public class TapeMeasure extends SimpleSlimefunItem implements N item.setItemMeta(meta); } + @ParametersAreNonnullByDefault + private void measure(Player p, ItemStack item, Block block) { + OptionalDouble distance = getDistance(p, item, block); + + if (distance.isPresent()) { + p.playSound(block.getLocation(), Sound.ITEM_BOOK_PUT, 1, 0.7F); + String label = format.format(distance.getAsDouble()); + SlimefunPlugin.getLocalization().sendMessage(p, "messages.tape-measure.distance", msg -> msg.replace("%distance%", label)); + } + } + @Nonnull @ParametersAreNonnullByDefault - private Optional getAnchor(Player p, ItemStack item) { + public Optional getAnchor(Player p, ItemStack item) { ItemMeta meta = item.getItemMeta(); String data = meta.getPersistentDataContainer().get(key, PersistentDataType.STRING); @@ -106,13 +119,14 @@ public class TapeMeasure extends SimpleSlimefunItem implements N } @ParametersAreNonnullByDefault - private void measure(Player p, ItemStack item, Block block) { + public OptionalDouble getDistance(Player p, ItemStack item, Block block) { Optional anchor = getAnchor(p, item); if (anchor.isPresent()) { Location loc = anchor.get(); - double distance = loc.distance(block.getLocation()); - SlimefunPlugin.getLocalization().sendMessage(p, "messages.tape-measure.distance", msg -> msg.replace("%distance%", format.format(distance))); + return OptionalDouble.of(loc.distance(block.getLocation())); + } else { + return OptionalDouble.empty(); } } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/interfaces/SlimefunItemTest.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/interfaces/SlimefunItemTest.java index b61f6e4dd..d97f56f91 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/interfaces/SlimefunItemTest.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/interfaces/SlimefunItemTest.java @@ -1,11 +1,14 @@ package io.github.thebusybiscuit.slimefun4.testing.interfaces; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.ItemStack; import be.seeseemelk.mockbukkit.block.BlockMock; import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; @@ -30,18 +33,21 @@ public interface SlimefunItemTest { */ T registerSlimefunItem(SlimefunPlugin plugin, String id); + @ParametersAreNonnullByDefault default void simulateRightClick(Player player, T item) { PlayerInteractEvent e = new PlayerInteractEvent(player, Action.RIGHT_CLICK_AIR, item.getItem().clone(), null, null, EquipmentSlot.HAND); PlayerRightClickEvent event = new PlayerRightClickEvent(e); item.callItemHandler(ItemUseHandler.class, handler -> handler.onRightClick(event)); } - default void simulateRightClickBlock(Player player, T item, BlockMock block, BlockFace face) { - PlayerInteractEvent e = new PlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, item.getItem().clone(), block, face, EquipmentSlot.HAND); + @ParametersAreNonnullByDefault + default void simulateRightClickBlock(Player player, T item, ItemStack heldItem, BlockMock block, BlockFace face) { + PlayerInteractEvent e = new PlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, heldItem, block, face, EquipmentSlot.HAND); PlayerRightClickEvent event = new PlayerRightClickEvent(e); item.callItemHandler(ItemUseHandler.class, handler -> handler.onRightClick(event)); } + @ParametersAreNonnullByDefault default void simulateConsumption(Player player, T item) { PlayerItemConsumeEvent event = new PlayerItemConsumeEvent(player, item.getItem().clone()); item.callItemHandler(ItemConsumptionHandler.class, handler -> handler.onConsume(event, player, event.getItem())); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/tools/TestClimbingPick.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/tools/TestClimbingPick.java index 89dd43be8..9753b62de 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/tools/TestClimbingPick.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/tools/TestClimbingPick.java @@ -134,7 +134,7 @@ class TestClimbingPick implements SlimefunItemTest { boolean shouldFireEvent = face != BlockFace.DOWN && face != BlockFace.UP; BlockMock block = new BlockMock(Material.ICE, blockLocation); - simulateRightClickBlock(player, pick, block, face); + simulateRightClickBlock(player, pick, pick.getItem().clone(), block, face); if (shouldFireEvent) { Assertions.assertTrue(pick.getClimbingSpeed(block.getType()) > 0); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/tools/TestTapeMeasure.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/tools/TestTapeMeasure.java new file mode 100644 index 000000000..93452df72 --- /dev/null +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/tools/TestTapeMeasure.java @@ -0,0 +1,148 @@ +package io.github.thebusybiscuit.slimefun4.testing.tests.items.tools; + +import java.util.Optional; +import java.util.OptionalDouble; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.BlockFace; +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; + +import be.seeseemelk.mockbukkit.MockBukkit; +import be.seeseemelk.mockbukkit.ServerMock; +import be.seeseemelk.mockbukkit.WorldMock; +import be.seeseemelk.mockbukkit.block.BlockMock; +import be.seeseemelk.mockbukkit.entity.PlayerMock; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.implementation.items.tools.TapeMeasure; +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 TestTapeMeasure 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 TapeMeasure registerSlimefunItem(SlimefunPlugin plugin, String id) { + SlimefunItemStack item = new SlimefunItemStack(id, Material.PLAYER_HEAD, "&5Test Pick", id); + TapeMeasure tapeMeasure = new TapeMeasure(TestUtilities.getCategory(plugin, "tape_measure"), item, RecipeType.NULL, new ItemStack[9]); + tapeMeasure.register(plugin); + return tapeMeasure; + } + + @Test + @DisplayName("Test setting anchor") + void testAnchor() { + TapeMeasure tm = registerSlimefunItem(plugin, "TEST_ANCHOR"); + Player player = server.addPlayer(); + ItemStack item = tm.getItem().clone(); + Location loc = new Location(player.getWorld(), 10, 60, 1000); + BlockMock block = new BlockMock(loc); + + player.setSneaking(true); + simulateRightClickBlock(player, tm, item, block, BlockFace.UP); + + Optional anchor = tm.getAnchor(player, item); + Assertions.assertTrue(anchor.isPresent()); + Assertions.assertEquals(loc, anchor.get()); + } + + @Test + @DisplayName("Test measuring distance") + void testMeasuring() { + TapeMeasure tm = registerSlimefunItem(plugin, "TEST_MEASURE_DISTANCE"); + Player player = server.addPlayer(); + ItemStack item = tm.getItem().clone(); + + Location loc1 = new Location(player.getWorld(), 10, 60, 1000); + BlockMock block1 = new BlockMock(loc1); + + Location loc2 = new Location(player.getWorld(), 10, 60, 1080); + BlockMock block2 = new BlockMock(loc2); + + player.setSneaking(true); + simulateRightClickBlock(player, tm, item, block1, BlockFace.UP); + + OptionalDouble distance = tm.getDistance(player, item, block2); + Assertions.assertTrue(distance.isPresent()); + Assertions.assertEquals(loc1.distance(loc2), distance.getAsDouble()); + } + + @Test + @DisplayName("Test measuring player") + void testMeasuringFeedback() { + TapeMeasure tm = registerSlimefunItem(plugin, "TEST_MEASURE_FEEDBACK"); + PlayerMock player = server.addPlayer(); + ItemStack item = tm.getItem().clone(); + + Location loc1 = new Location(player.getWorld(), 10, 60, 1000); + BlockMock block1 = new BlockMock(loc1); + + Location loc2 = new Location(player.getWorld(), 10, 60, 1080); + BlockMock block2 = new BlockMock(loc2); + + player.setSneaking(true); + simulateRightClickBlock(player, tm, item, block1, BlockFace.UP); + + player.setSneaking(false); + simulateRightClickBlock(player, tm, item, block2, BlockFace.UP); + + player.assertSoundHeard(Sound.ITEM_BOOK_PUT); + } + + @Test + @DisplayName("Test measuring without anchor") + void testNoAnchor() { + TapeMeasure tm = registerSlimefunItem(plugin, "TEST_MEASURE_NO_ANCHOR"); + Player player = server.addPlayer(); + ItemStack item = tm.getItem().clone(); + + Location loc = new Location(player.getWorld(), 10, 60, 50); + BlockMock block = new BlockMock(loc); + + OptionalDouble distance = tm.getDistance(player, item, block); + Assertions.assertFalse(distance.isPresent()); + } + + @Test + @DisplayName("Test anchor in different world") + void testOtherWorld() { + TapeMeasure tm = registerSlimefunItem(plugin, "TEST_ANCHOR_DIFFERENT_WORLD"); + Player player = server.addPlayer(); + ItemStack item = tm.getItem().clone(); + + Location loc1 = new Location(player.getWorld(), 10, 60, 1000); + BlockMock block1 = new BlockMock(loc1); + + player.setSneaking(true); + simulateRightClickBlock(player, tm, item, block1, BlockFace.UP); + + Assertions.assertTrue(tm.getAnchor(player, item).isPresent()); + + Location loc2 = new Location(new WorldMock(), 10, 60, 1080); + + player.teleport(loc2); + Assertions.assertFalse(tm.getAnchor(player, item).isPresent()); + } +} From 7af1e8144d62380def5769b14e81915a8611f40c Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sun, 11 Oct 2020 08:48:27 +0300 Subject: [PATCH 127/178] Update ExplosiveTool.java --- .../slimefun4/implementation/items/tools/ExplosiveTool.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java index 056eb62d0..ada035c21 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java @@ -52,8 +52,6 @@ class ExplosiveTool extends SimpleSlimefunItem implements NotPla @Override public ToolUseHandler getItemHandler() { return (e, tool, fortune, drops) -> { - if (e.isCancelled()) return; - Player p = e.getPlayer(); Block b = e.getBlock(); From 4980b078a10d91cec8e7fd266f53740b0a974f29 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sun, 11 Oct 2020 08:50:04 +0300 Subject: [PATCH 128/178] Update BlockListener.java --- .../slimefun4/implementation/listeners/BlockListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 0ef709cd9..625a7911c 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 @@ -51,7 +51,7 @@ public class BlockListener implements Listener { plugin.getServer().getPluginManager().registerEvents(this, plugin); } - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockPlace(BlockPlaceEvent e) { if (BlockStorage.hasBlockInfo(e.getBlock())) { e.setCancelled(true); From 2902f74d10bf547fb92615d284b3c1cbd80d2608 Mon Sep 17 00:00:00 2001 From: Silent Date: Sun, 11 Oct 2020 12:14:58 +0200 Subject: [PATCH 129/178] Changes --- .../implementation/items/food/HeavyCream.java | 21 +++++++++---------- .../items/misc/StrangeNetherGoo.java | 13 +++++------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/HeavyCream.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/HeavyCream.java index 34f3018b4..9d9459dac 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/HeavyCream.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/HeavyCream.java @@ -1,16 +1,17 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.food; -import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; 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.block.Block; import org.bukkit.inventory.ItemStack; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import java.util.Optional; /** * This {@link SlimefunItem} can be obtained by crafting, it's @@ -28,18 +29,16 @@ public class HeavyCream extends SimpleSlimefunItem { @Nonnull @Override public ItemUseHandler getItemHandler() { - return this::use; - } - - public void use(PlayerRightClickEvent e) { - if (e.getClickedBlock().isPresent()) { - if (!e.getClickedBlock().get().getType().isInteractable()) { + return e -> { + Optional block = e.getClickedBlock(); + if (block.isPresent()) { + if (!block.get().getType().isInteractable()) { + e.cancel(); + } + } else { e.cancel(); } - } - else { - e.cancel(); - } + }; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java index 3a66362d6..146563aae 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java @@ -7,7 +7,6 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; -import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; import io.github.thebusybiscuit.slimefun4.core.attributes.PiglinBarterDrop; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; @@ -18,6 +17,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import javax.annotation.Nonnull; +import java.util.Optional; /** * This {@link SlimefunItem} can only be obtained via bartering with a {@link Piglin}, its @@ -47,15 +47,12 @@ public class StrangeNetherGoo extends SimpleSlimefunItem impleme @Nonnull @Override public ItemUseHandler getItemHandler() { - return this::use; - } - - public void use(PlayerRightClickEvent e) { - if (e.getClickedBlock().isPresent()) { - if (Tag.SIGNS.isTagged(e.getClickedBlock().get().getType())) { + return e -> { + Optional block = e.getClickedBlock(); + if (block.isPresent() && Tag.SIGNS.isTagged(block.get().getType())) { e.cancel(); } - } + }; } } From 7177946aaef78cb0ac0de5371ceac09a4047bdb7 Mon Sep 17 00:00:00 2001 From: Silent Date: Sun, 11 Oct 2020 12:44:15 +0200 Subject: [PATCH 130/178] Changes pt2 --- .../slimefun4/implementation/items/food/HeavyCream.java | 9 +++------ .../implementation/items/misc/StrangeNetherGoo.java | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/HeavyCream.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/HeavyCream.java index 9d9459dac..fdb6b60a9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/HeavyCream.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/HeavyCream.java @@ -31,14 +31,11 @@ public class HeavyCream extends SimpleSlimefunItem { public ItemUseHandler getItemHandler() { return e -> { Optional block = e.getClickedBlock(); - if (block.isPresent()) { - if (!block.get().getType().isInteractable()) { - e.cancel(); - } - } else { + + if (!block.isPresent() || !block.get().getType().isInteractable()) { e.cancel(); } }; } -} +} \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java index 146563aae..a1b0ab966 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java @@ -49,6 +49,7 @@ public class StrangeNetherGoo extends SimpleSlimefunItem impleme public ItemUseHandler getItemHandler() { return e -> { Optional block = e.getClickedBlock(); + if (block.isPresent() && Tag.SIGNS.isTagged(block.get().getType())) { e.cancel(); } From b4b18f548f11077db34663c6897b2a754288c229 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 11 Oct 2020 12:48:51 +0200 Subject: [PATCH 131/178] [CI skip] Reduced technical debt --- .../slimefun4/api/player/StatusEffect.java | 8 ++--- .../implementation/items/androids/Script.java | 36 +++++++++++++++---- .../machines/AutomatedCraftingChamber.java | 16 +++++++-- .../interfaces/InventoryBlock.java | 12 +++++-- .../Slimefun/api/inventory/BlockMenu.java | 4 ++- .../api/inventory/DirtyChestMenu.java | 29 +++------------ .../api/inventory/MenuSavingHandler.java | 30 ++++++++++++++++ .../api/inventory/UniversalBlockMenu.java | 4 ++- 8 files changed, 94 insertions(+), 45 deletions(-) create mode 100644 src/main/java/me/mrCookieSlime/Slimefun/api/inventory/MenuSavingHandler.java diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/StatusEffect.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/StatusEffect.java index d8e658e66..12a364457 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/StatusEffect.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/StatusEffect.java @@ -102,9 +102,7 @@ public class StatusEffect implements Keyed { long timestamp = Long.parseLong(data[1]); if (timestamp == 0 || timestamp >= System.currentTimeMillis()) { - { - return true; - } + return true; } else { clear(p); return false; @@ -129,9 +127,9 @@ public class StatusEffect implements Keyed { if (optional.isPresent()) { String[] data = PatternUtils.SEMICOLON.split(optional.get()); return OptionalInt.of(Integer.parseInt(data[0])); - - } else + } else { return OptionalInt.empty(); + } } /** diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java index 2b623dbc5..5d97975f7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java @@ -9,6 +9,9 @@ import java.util.List; import java.util.UUID; import java.util.logging.Level; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -22,6 +25,12 @@ import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; import me.mrCookieSlime.Slimefun.api.Slimefun; +/** + * A {@link Script} represents runnable code for a {@link ProgrammableAndroid}. + * + * @author TheBusyBiscuit + * + */ public final class Script { private final Config config; @@ -29,7 +38,13 @@ public final class Script { private final String author; private final String code; - private Script(Config config) { + /** + * This constructs a new {@link Script} from the given {@link Config}. + * + * @param config + * The {@link Config} + */ + private Script(@Nonnull Config config) { Validate.notNull(config); this.config = config; @@ -52,6 +67,7 @@ public final class Script { * * @return The name */ + @Nonnull public String getName() { return name; } @@ -62,6 +78,7 @@ public final class Script { * * @return The author of this {@link Script} */ + @Nonnull public String getAuthor() { return author; } @@ -73,6 +90,7 @@ public final class Script { * * @return The code for this {@link Script} */ + @Nonnull public String getSourceCode() { return code; } @@ -86,7 +104,7 @@ public final class Script { * * @return Whether the given {@link OfflinePlayer} is the author of this {@link Script}. */ - public boolean isAuthor(OfflinePlayer p) { + public boolean isAuthor(@Nonnull OfflinePlayer p) { return p.getUniqueId().equals(config.getUUID("author")); } @@ -99,7 +117,7 @@ public final class Script { * * @return Whether the given {@link Player} is able to rate this {@link Script} */ - public boolean canRate(Player p) { + public boolean canRate(@Nonnull Player p) { if (isAuthor(p)) { return false; } @@ -109,7 +127,8 @@ public final class Script { return !upvoters.contains(p.getUniqueId().toString()) && !downvoters.contains(p.getUniqueId().toString()); } - ItemStack getAsItemStack(ProgrammableAndroid android, Player p) { + @Nonnull + ItemStack getAsItemStack(@Nonnull ProgrammableAndroid android, @Nonnull Player p) { List lore = new LinkedList<>(); lore.add("&7by &r" + getAuthor()); lore.add(""); @@ -128,6 +147,7 @@ public final class Script { return new CustomItem(android.getItem(), "&b" + getName(), lore.toArray(new String[0])); } + @Nonnull private String getScriptRatingPercentage() { float percentage = getRating(); return NumberUtils.getColorFromPercentage(percentage) + String.valueOf(percentage) + ChatColor.RESET + "% "; @@ -181,7 +201,7 @@ public final class Script { config.save(); } - public void rate(Player p, boolean positive) { + public void rate(@Nonnull Player p, boolean positive) { config.reload(); String path = "rating." + (positive ? "positive" : "negative"); @@ -192,7 +212,8 @@ public final class Script { config.save(); } - public static List