From d72a60aed148e165bb15d2123f90848413355e72 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sat, 3 Oct 2020 23:04:39 +0300 Subject: [PATCH 01/94] Added GuideOpenEvent. --- .../slimefun4/api/events/GuideOpenEvent.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GuideOpenEvent.java diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GuideOpenEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GuideOpenEvent.java new file mode 100644 index 000000000..f04be968d --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GuideOpenEvent.java @@ -0,0 +1,64 @@ +package io.github.thebusybiscuit.slimefun4.api.events; + +import javax.annotation.Nonnull; + +import org.apache.commons.lang.Validate; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.bukkit.inventory.ItemStack; + +/** + * This {@link Event} is called whenever a {@link Player} tries to open the Slimefun Guide book. + * + * @author Linox + * + */ +public class GuideOpenEvent extends Event implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + + private final Player player; + private final ItemStack guide; + private boolean cancelled; + + public GuideOpenEvent(@Nonnull Player p, @Nonnull ItemStack guide) { + Validate.notNull(p, "The Player cannot be null"); + Validate.notNull(guide, "Guide cannot be null"); + this.player = p; + this.guide = guide; + } + + @Nonnull + public Player getPlayer() { + return player; + } + + @Nonnull + public ItemStack getGuide() { + return guide; + } + + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + + @Nonnull + public static HandlerList getHandlerList() { + return handlers; + } + + @Nonnull + @Override + public HandlerList getHandlers() { + return getHandlerList(); + } + +} From 2cfbaf3ca6d18459e78a22fdefa815985ced982b Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sat, 3 Oct 2020 23:05:23 +0300 Subject: [PATCH 02/94] Added GuideOpenEvent. --- .../listeners/SlimefunGuideListener.java | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java index 879a10025..85bff73a1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java @@ -3,6 +3,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.Event.Result; import org.bukkit.event.EventHandler; @@ -11,6 +12,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.inventory.ItemStack; +import io.github.thebusybiscuit.slimefun4.api.events.GuideOpenEvent; import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout; @@ -45,38 +47,46 @@ public class SlimefunGuideListener implements Listener { public void onInteract(PlayerRightClickEvent e) { Player p = e.getPlayer(); - if (openGuide(e, SlimefunGuideLayout.BOOK) == Result.ALLOW) { + if (tryGuide(e, SlimefunGuideLayout.BOOK) == Result.ALLOW) { if (p.isSneaking()) { SlimefunGuideSettings.openSettings(p, e.getItem()); } else { - SlimefunGuide.openGuide(p, SlimefunGuideLayout.BOOK); + openGuide(p, e, SlimefunGuideLayout.BOOK); } } - else if (openGuide(e, SlimefunGuideLayout.CHEST) == Result.ALLOW) { + else if (tryGuide(e, SlimefunGuideLayout.CHEST) == Result.ALLOW) { if (p.isSneaking()) { SlimefunGuideSettings.openSettings(p, e.getItem()); } else { - SlimefunGuide.openGuide(p, SlimefunGuideLayout.CHEST); + openGuide(p, e, SlimefunGuideLayout.CHEST); } } - else if (openGuide(e, SlimefunGuideLayout.CHEAT_SHEET) == Result.ALLOW) { + else if (tryGuide(e, SlimefunGuideLayout.CHEAT_SHEET) == Result.ALLOW) { // We rather just run the command here, // all necessary permission checks will be handled there. p.chat("/sf cheat"); } } + + @ParametersAreNonnullByDefault + private void openGuide(Player p, PlayerRightClickEvent e, SlimefunGuideLayout layout) { + GuideOpenEvent event = new GuideOpenEvent(p, e.getItem()) ; + Bukkit.getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + e.cancel(); + SlimefunGuide.openGuide(p, layout); + } + } @Nonnull @ParametersAreNonnullByDefault - private Result openGuide(PlayerRightClickEvent e, SlimefunGuideLayout layout) { - Player p = e.getPlayer(); + private Result tryGuide(Player p, PlayerRightClickEvent e, SlimefunGuideLayout layout) { ItemStack item = e.getItem(); - if (SlimefunUtils.isItemSimilar(item, SlimefunGuide.getItem(layout), true, false)) { - e.cancel(); - + if (!SlimefunPlugin.getWorldSettingsService().isWorldEnabled(p.getWorld())) { SlimefunPlugin.getLocalization().sendMessage(p, "messages.disabled-item", true); return Result.DENY; From 6d887b8abf7b44a7cb38039dddfaa54878eb3d85 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sat, 3 Oct 2020 23:17:09 +0300 Subject: [PATCH 03/94] Fixed some build errors. --- .../implementation/listeners/SlimefunGuideListener.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java index e3c8c7c22..02b296d9f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java @@ -47,7 +47,7 @@ public class SlimefunGuideListener implements Listener { public void onInteract(PlayerRightClickEvent e) { Player p = e.getPlayer(); - if (tryGuide(e, SlimefunGuideLayout.BOOK) == Result.ALLOW) { + if (tryGuide(p, e, SlimefunGuideLayout.BOOK) == Result.ALLOW) { if (p.isSneaking()) { SlimefunGuideSettings.openSettings(p, e.getItem()); } @@ -55,7 +55,7 @@ public class SlimefunGuideListener implements Listener { openGuide(p, e, SlimefunGuideLayout.BOOK); } } - else if (tryGuide(e, SlimefunGuideLayout.CHEST) == Result.ALLOW) { + else if (tryGuide(p, e, SlimefunGuideLayout.CHEST) == Result.ALLOW) { if (p.isSneaking()) { SlimefunGuideSettings.openSettings(p, e.getItem()); } @@ -63,7 +63,7 @@ public class SlimefunGuideListener implements Listener { openGuide(p, e, SlimefunGuideLayout.CHEST); } } - else if (openGuide(e, SlimefunGuideLayout.CHEAT_SHEET) == Result.ALLOW) { + else if (openGuide(p, e, SlimefunGuideLayout.CHEAT_SHEET) == Result.ALLOW) { if (p.isSneaking()) { SlimefunGuideSettings.openSettings(p, e.getItem()); } From 5e038d1cc8191b1b3009d86ec7a6d896c3757606 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sat, 3 Oct 2020 23:20:51 +0300 Subject: [PATCH 04/94] And this is the last build error. Hopefully... --- .../implementation/listeners/SlimefunGuideListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java index 02b296d9f..fa4b7765c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java @@ -63,7 +63,7 @@ public class SlimefunGuideListener implements Listener { openGuide(p, e, SlimefunGuideLayout.CHEST); } } - else if (openGuide(p, e, SlimefunGuideLayout.CHEAT_SHEET) == Result.ALLOW) { + else if (tryGuide(p, e, SlimefunGuideLayout.CHEAT_SHEET) == Result.ALLOW) { if (p.isSneaking()) { SlimefunGuideSettings.openSettings(p, e.getItem()); } From 9e0485e526e02446e334f0416dd8a224b9c1047b Mon Sep 17 00:00:00 2001 From: Seggan Date: Sat, 3 Oct 2020 16:21:39 -0400 Subject: [PATCH 05/94] Added crash helmet --- .../slimefun4/implementation/SlimefunItems.java | 2 ++ .../slimefun4/implementation/setup/SlimefunItemSetup.java | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java index 254a3f511..463e84234 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -838,6 +838,8 @@ public final class SlimefunItems { public static final SlimefunItemStack MAGNESIUM_SALT = new SlimefunItemStack("MAGNESIUM_SALT", Material.SUGAR, "&cMagnesium Salt", "", "&7A special type of fuel that can be", "&7used in a Magnesium-powered Generator"); public static final SlimefunItemStack MAGNESIUM_GENERATOR = new SlimefunItemStack("MAGNESIUM_GENERATOR", HeadTexture.GENERATOR, "&cMagnesium-powered Generator", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.GENERATOR), LoreBuilder.powerBuffer(128), LoreBuilder.powerPerSecond(36)); + public static final SlimefunItemStack CRASH_HELMET = new SlimefunItemStack("CRASH_HELMET", Material.IRON_HELMET, "&5Crash Helmet", "", "&7This helmet will protect you from", "&7crashing while flying elytra."); + static { INFUSED_ELYTRA.addUnsafeEnchantment(Enchantment.MENDING, 1); 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 2ce4ff063..ce6b1e3e4 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 @@ -1016,6 +1016,10 @@ public final class SlimefunItemSetup { new PotionEffect[] {new PotionEffect(PotionEffectType.NIGHT_VISION, 600, 20)}) .register(plugin); + new SlimefunItem(categories.technicalGadgets, SlimefunItems.CRASH_HELMET, RecipeType.ARMOR_FORGE, + new ItemStack[]{new ItemStack(Material.IRON_INGOT), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.LEATHER_HELMET), new ItemStack(Material.IRON_INGOT)}) + .register(plugin); + new PickaxeOfContainment(categories.tools, SlimefunItems.PICKAXE_OF_CONTAINMENT, RecipeType.MAGIC_WORKBENCH, new ItemStack[] {SlimefunItems.FERROSILICON, SlimefunItems.FERROSILICON, SlimefunItems.FERROSILICON, null, SlimefunItems.GILDED_IRON, null, null, SlimefunItems.GILDED_IRON, null}) .register(plugin); From 23efd62c4961c498cb083786cb6060fff56e60cc Mon Sep 17 00:00:00 2001 From: Seggan Date: Sat, 3 Oct 2020 16:31:27 -0400 Subject: [PATCH 06/94] Added crash helmet listener and research --- .../implementation/SlimefunPlugin.java | 37 +------------------ .../listeners/CrashHelmetListener.java | 31 ++++++++++++++++ .../implementation/setup/ResearchSetup.java | 1 + .../resources/languages/researches_en.yml | 1 + 4 files changed, 35 insertions(+), 35 deletions(-) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CrashHelmetListener.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 ab0b9e2d0..970fdfa82 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java @@ -13,6 +13,7 @@ import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.*; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.Server; @@ -56,41 +57,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors import io.github.thebusybiscuit.slimefun4.implementation.items.tools.GrapplingHook; import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.SeismicAxe; import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.VampireBlade; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.AncientAltarListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.BackpackListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.BeeListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockPhysicsListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.CargoNodeListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.CoolerListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.DeathpointListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.DebugFishListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.DispenserListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.EnhancedFurnaceListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.EntityInteractionListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.ExplosionsListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.FireworksListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.GadgetsListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.GrapplingHookListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.IronGolemListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.ItemPickupListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.MobDropListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.MultiBlockListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.PiglinListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.PlayerProfileListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.SeismicAxeListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunBootsListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunBowListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunGuideListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunItemConsumeListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunItemListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.SoulboundListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.TalismanListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.VampireBladeListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.VanillaMachinesListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.VillagerTradingListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.WitherListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.WorldListener; import io.github.thebusybiscuit.slimefun4.implementation.resources.GEOResourcesSetup; import io.github.thebusybiscuit.slimefun4.implementation.setup.PostSetup; import io.github.thebusybiscuit.slimefun4.implementation.setup.ResearchSetup; @@ -453,6 +419,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { new EntityInteractionListener(this); new MobDropListener(this); new VillagerTradingListener(this); + new CrashHelmetListener(this); if (minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_15)) { new BeeListener(this); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CrashHelmetListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CrashHelmetListener.java new file mode 100644 index 000000000..fbe40d78d --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CrashHelmetListener.java @@ -0,0 +1,31 @@ +package io.github.thebusybiscuit.slimefun4.implementation.listeners; + +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.inventory.ItemStack; + +import javax.annotation.Nonnull; + +public class CrashHelmetListener implements Listener { + + public CrashHelmetListener(@Nonnull SlimefunPlugin plugin) { + plugin.getServer().getPluginManager().registerEvents(this, plugin); + } + + @EventHandler + public void onPlayerCrash(EntityDamageEvent e) { + if (!(e.getCause() == EntityDamageEvent.DamageCause.FLY_INTO_WALL) || !(e.getEntity() instanceof Player)) { + return; + } + + ItemStack stack = ((Player) e.getEntity()).getInventory().getHelmet(); + SlimefunItem item = SlimefunItem.getByItem(stack); + if ((item != null) && (item.getID().equals("CRASH_HELMET"))) { + e.setCancelled(true); + } + } +} 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 ae98e4d27..87074f103 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 @@ -276,6 +276,7 @@ public final class ResearchSetup { register("climbing_pick", 265, "Block Raider", 20, SlimefunItems.CLIMBING_PICK); 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("crash_helmet", 268, "Crash Gear", 20, SlimefunItems.CRASH_HELMET); } private static void register(String key, int id, String name, int defaultCost, ItemStack... items) { diff --git a/src/main/resources/languages/researches_en.yml b/src/main/resources/languages/researches_en.yml index 7f7826637..6fb6c4811 100644 --- a/src/main/resources/languages/researches_en.yml +++ b/src/main/resources/languages/researches_en.yml @@ -244,3 +244,4 @@ slimefun: tape_measure: Tape Measure iron_golem_assembler: Automated Iron Golems villager_rune: Reset Villager Trades + crash_helmet: Crash Gear From a222295b039416613a54ac0986dfd55fd69db391 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sat, 3 Oct 2020 23:39:06 +0300 Subject: [PATCH 07/94] Did a requested change. --- .../implementation/listeners/SlimefunGuideListener.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java index fa4b7765c..e1f560ff0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java @@ -47,7 +47,7 @@ public class SlimefunGuideListener implements Listener { public void onInteract(PlayerRightClickEvent e) { Player p = e.getPlayer(); - if (tryGuide(p, e, SlimefunGuideLayout.BOOK) == Result.ALLOW) { + if (tryOpenGuide(p, e, SlimefunGuideLayout.BOOK) == Result.ALLOW) { if (p.isSneaking()) { SlimefunGuideSettings.openSettings(p, e.getItem()); } @@ -55,7 +55,7 @@ public class SlimefunGuideListener implements Listener { openGuide(p, e, SlimefunGuideLayout.BOOK); } } - else if (tryGuide(p, e, SlimefunGuideLayout.CHEST) == Result.ALLOW) { + else if (tryOpenGuide(p, e, SlimefunGuideLayout.CHEST) == Result.ALLOW) { if (p.isSneaking()) { SlimefunGuideSettings.openSettings(p, e.getItem()); } @@ -63,7 +63,7 @@ public class SlimefunGuideListener implements Listener { openGuide(p, e, SlimefunGuideLayout.CHEST); } } - else if (tryGuide(p, e, SlimefunGuideLayout.CHEAT_SHEET) == Result.ALLOW) { + else if (tryOpenGuide(p, e, SlimefunGuideLayout.CHEAT_SHEET) == Result.ALLOW) { if (p.isSneaking()) { SlimefunGuideSettings.openSettings(p, e.getItem()); } @@ -88,7 +88,7 @@ public class SlimefunGuideListener implements Listener { @Nonnull @ParametersAreNonnullByDefault - private Result tryGuide(Player p, PlayerRightClickEvent e, SlimefunGuideLayout layout) { + private Result tryOpenGuide(Player p, PlayerRightClickEvent e, SlimefunGuideLayout layout) { ItemStack item = e.getItem(); if (SlimefunUtils.isItemSimilar(item, SlimefunGuide.getItem(layout), true, false)) { From 33c8744478777e0b9b053c43e9c560f86d3457c8 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 3 Oct 2020 22:45:58 +0200 Subject: [PATCH 08/94] [CI skip] Added maven default goals --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 2442ec7d3..1930ec856 100644 --- a/pom.xml +++ b/pom.xml @@ -77,6 +77,7 @@ ${project.basedir}/src/main/java ${project.basedir}/src/test/java + clean package ${project.name} v${project.version} From 41fc987083d4dae8c171282518832fd26a2d5349 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sat, 3 Oct 2020 23:56:51 +0300 Subject: [PATCH 09/94] Did more requested changes. --- ...Event.java => SlimefunGuideOpenEvent.java} | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) rename src/main/java/io/github/thebusybiscuit/slimefun4/api/events/{GuideOpenEvent.java => SlimefunGuideOpenEvent.java} (57%) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GuideOpenEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java similarity index 57% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GuideOpenEvent.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java index f04be968d..5bd022f96 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GuideOpenEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java @@ -9,36 +9,59 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout; + /** * This {@link Event} is called whenever a {@link Player} tries to open the Slimefun Guide book. * * @author Linox * + * @see SlimefunGuideLayout */ -public class GuideOpenEvent extends Event implements Cancellable { +public class SlimefunGuideOpenEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); private final Player player; private final ItemStack guide; + private final SlimefunGuideLayout layout; private boolean cancelled; - public GuideOpenEvent(@Nonnull Player p, @Nonnull ItemStack guide) { + public SlimefunGuideOpenEvent(@Nonnull Player p, @Nonnull ItemStack guide, @Nonnull SlimefunGuideLayout layout) { Validate.notNull(p, "The Player cannot be null"); Validate.notNull(guide, "Guide cannot be null"); + Validate.notNull(layout, "Layout cannot be null"); this.player = p; this.guide = guide; + this.layout = layout; } + /** + * This returns the {@link Player} that tries to open + * the Slimefun Guide. + */ @Nonnull public Player getPlayer() { return player; } + /** + * This returns the {@link ItemStack} that {@link Player} + * tries to open the Slimefun Guide with. + */ @Nonnull public ItemStack getGuide() { return guide; } + + /** + * This returns the {@link SlimefunGuideLayout} of the Slimefun Guide + * that {@link Player} tries to open. + */ + @Nonnull + public SlimefunGuideLayout getGuideLayout() { + return layout; + } @Override public boolean isCancelled() { From fc999ae60d928569af82045be75e1bb07cf2b23b Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sat, 3 Oct 2020 23:57:27 +0300 Subject: [PATCH 10/94] Update SlimefunGuideListener.java --- .../implementation/listeners/SlimefunGuideListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java index e1f560ff0..b4dffdb6b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java @@ -77,7 +77,7 @@ public class SlimefunGuideListener implements Listener { @ParametersAreNonnullByDefault private void openGuide(Player p, PlayerRightClickEvent e, SlimefunGuideLayout layout) { - GuideOpenEvent event = new GuideOpenEvent(p, e.getItem()) ; + GuideOpenEvent event = new GuideOpenEvent(p, e.getItem(), layout) ; Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { From 0e530fe13ad55b24574dc0cd4c2f71c5c1097ea9 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sun, 4 Oct 2020 00:06:13 +0300 Subject: [PATCH 11/94] Update src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java Co-authored-by: poma123 <25465545+poma123@users.noreply.github.com> --- .../implementation/listeners/SlimefunGuideListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java index b4dffdb6b..e2e812f4f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java @@ -12,7 +12,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.GuideOpenEvent; +import io.github.thebusybiscuit.slimefun4.api.events.SlimefunGuideOpenEvent; import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout; From 4316f83a007d1b30fc3f1824f4bb014ad1da5349 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sun, 4 Oct 2020 00:06:20 +0300 Subject: [PATCH 12/94] Update src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java Co-authored-by: poma123 <25465545+poma123@users.noreply.github.com> --- .../implementation/listeners/SlimefunGuideListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java index e2e812f4f..46df132e0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java @@ -77,7 +77,7 @@ public class SlimefunGuideListener implements Listener { @ParametersAreNonnullByDefault private void openGuide(Player p, PlayerRightClickEvent e, SlimefunGuideLayout layout) { - GuideOpenEvent event = new GuideOpenEvent(p, e.getItem(), layout) ; + SlimefunGuideOpenEvent event = new SlimefunGuideOpenEvent(p, e.getItem(), layout); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { From f7c3a5b052e1ce0aad86487206dbe4b5c453933a Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sun, 4 Oct 2020 00:09:52 +0300 Subject: [PATCH 13/94] Did some more requestes changes. --- .../slimefun4/api/events/SlimefunGuideOpenEvent.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java index 5bd022f96..df2b33674 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java @@ -39,6 +39,8 @@ public class SlimefunGuideOpenEvent extends Event implements Cancellable { /** * This returns the {@link Player} that tries to open * the Slimefun Guide. + * + * @return The {@link Player} */ @Nonnull public Player getPlayer() { @@ -48,6 +50,8 @@ public class SlimefunGuideOpenEvent extends Event implements Cancellable { /** * This returns the {@link ItemStack} that {@link Player} * tries to open the Slimefun Guide with. + * + * @return The {@link ItemStack} */ @Nonnull public ItemStack getGuide() { @@ -57,6 +61,8 @@ public class SlimefunGuideOpenEvent extends Event implements Cancellable { /** * This returns the {@link SlimefunGuideLayout} of the Slimefun Guide * that {@link Player} tries to open. + * + * @return The {@link SlimefunGuideLayout} */ @Nonnull public SlimefunGuideLayout getGuideLayout() { From b540bc05bc96b1a9b925514ec61bb02cb64b8fbc Mon Sep 17 00:00:00 2001 From: Seggan Date: Sat, 3 Oct 2020 17:20:29 -0400 Subject: [PATCH 14/94] Crash helmet now works --- .../implementation/SlimefunPlugin.java | 37 ++++++++++++++++++- .../listeners/CrashHelmetListener.java | 17 +++++---- 2 files changed, 46 insertions(+), 8 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 970fdfa82..6f1a32240 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java @@ -13,7 +13,42 @@ import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.*; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.AncientAltarListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.BackpackListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.BeeListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockPhysicsListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.CargoNodeListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.CoolerListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.CrashHelmetListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.DeathpointListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.DebugFishListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.DispenserListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.EnhancedFurnaceListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.EntityInteractionListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.ExplosionsListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.FireworksListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.GadgetsListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.GrapplingHookListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.IronGolemListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.ItemPickupListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.MobDropListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.MultiBlockListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.PiglinListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.PlayerProfileListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.SeismicAxeListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunBootsListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunBowListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunGuideListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunItemConsumeListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunItemListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.SoulboundListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.TalismanListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.VampireBladeListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.VanillaMachinesListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.VillagerTradingListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.WitherListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.WorldListener; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.Server; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CrashHelmetListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CrashHelmetListener.java index fbe40d78d..d18f6b484 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CrashHelmetListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CrashHelmetListener.java @@ -18,14 +18,17 @@ public class CrashHelmetListener implements Listener { @EventHandler public void onPlayerCrash(EntityDamageEvent e) { - if (!(e.getCause() == EntityDamageEvent.DamageCause.FLY_INTO_WALL) || !(e.getEntity() instanceof Player)) { - return; - } + if (!(e.getEntity() instanceof Player)) return; + if (!(e.getCause() == EntityDamageEvent.DamageCause.FALL || + e.getCause() == EntityDamageEvent.DamageCause.FLY_INTO_WALL)) return; - ItemStack stack = ((Player) e.getEntity()).getInventory().getHelmet(); - SlimefunItem item = SlimefunItem.getByItem(stack); - if ((item != null) && (item.getID().equals("CRASH_HELMET"))) { - e.setCancelled(true); + Player p = (Player) e.getEntity(); + if (p.isGliding()) { + ItemStack stack = p.getInventory().getHelmet(); + SlimefunItem item = SlimefunItem.getByItem(stack); + if ((item != null) && (item.getID().equals("CRASH_HELMET"))) { + e.setDamage(0); + } } } } From 99e0c542aede9f7e8b225a1e67f377f254d7d090 Mon Sep 17 00:00:00 2001 From: Seggan Date: Sat, 3 Oct 2020 17:22:03 -0400 Subject: [PATCH 15/94] Moved crash helmet item declaration --- .../thebusybiscuit/slimefun4/implementation/SlimefunItems.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java index 463e84234..7deb21d4d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -56,6 +56,7 @@ public final class SlimefunItems { public static final SlimefunItemStack REINFORCED_CLOTH = new SlimefunItemStack("REINFORCED_CLOTH", Material.PAPER, "&bReinforced Cloth", "", "&fThis cloth has been reinforced", "&fwith &bLead &fto protect against", "&fradioactive substances"); public static final SlimefunItemStack TIN_CAN = new SlimefunItemStack("CAN", HeadTexture.TIN_CAN, "&fTin Can"); public static final SlimefunItemStack NIGHT_VISION_GOGGLES = new SlimefunItemStack("NIGHT_VISION_GOGGLES", Material.LEATHER_HELMET, Color.BLACK, "&aNight Vision Goggles", "", "&9+ Night Vision"); + public static final SlimefunItemStack CRASH_HELMET = new SlimefunItemStack("CRASH_HELMET", Material.IRON_HELMET, "&5Crash Helmet", "", "&7This helmet will protect you from", "&7crashing while flying elytra."); public static final SlimefunItemStack FARMER_SHOES = new SlimefunItemStack("FARMER_SHOES", Material.LEATHER_BOOTS, Color.YELLOW, "&eFarmer Shoes", "", "&6&oPrevents you from trampling your Crops"); public static final SlimefunItemStack INFUSED_MAGNET = new SlimefunItemStack("INFUSED_MAGNET", HeadTexture.MAGNET, "&aInfused Magnet", "", "&fMagical infused Magnets", "&fattract nearby Items", "&fas long as it is somewhere in", "&fyour Inventory", "", "&7Hold &eShift&7 to pick up nearby Items"); public static final SlimefunItemStack RAG = new SlimefunItemStack("RAG", Material.PAPER, "&cRag", "", "&aLevel I - Medical Supply", "", "&fRestores 2 Hearts", "&fExtinguishes Fire", "", LoreBuilder.RIGHT_CLICK_TO_USE); @@ -838,8 +839,6 @@ public final class SlimefunItems { public static final SlimefunItemStack MAGNESIUM_SALT = new SlimefunItemStack("MAGNESIUM_SALT", Material.SUGAR, "&cMagnesium Salt", "", "&7A special type of fuel that can be", "&7used in a Magnesium-powered Generator"); public static final SlimefunItemStack MAGNESIUM_GENERATOR = new SlimefunItemStack("MAGNESIUM_GENERATOR", HeadTexture.GENERATOR, "&cMagnesium-powered Generator", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.GENERATOR), LoreBuilder.powerBuffer(128), LoreBuilder.powerPerSecond(36)); - public static final SlimefunItemStack CRASH_HELMET = new SlimefunItemStack("CRASH_HELMET", Material.IRON_HELMET, "&5Crash Helmet", "", "&7This helmet will protect you from", "&7crashing while flying elytra."); - static { INFUSED_ELYTRA.addUnsafeEnchantment(Enchantment.MENDING, 1); From 2ed707b3b318a0d8a6dedb6a28a7fd56090ee332 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sun, 4 Oct 2020 00:25:27 +0300 Subject: [PATCH 16/94] Update SlimefunGuideOpenEvent.java --- .../slimefun4/api/events/SlimefunGuideOpenEvent.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java index df2b33674..d5f8109e9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java @@ -24,7 +24,7 @@ public class SlimefunGuideOpenEvent extends Event implements Cancellable { private final Player player; private final ItemStack guide; - private final SlimefunGuideLayout layout; + private SlimefunGuideLayout layout; private boolean cancelled; public SlimefunGuideOpenEvent(@Nonnull Player p, @Nonnull ItemStack guide, @Nonnull SlimefunGuideLayout layout) { @@ -68,6 +68,16 @@ public class SlimefunGuideOpenEvent extends Event implements Cancellable { public SlimefunGuideLayout getGuideLayout() { return layout; } + + /** + * Changes the {@link SlimefunGuideLayout} that was tried to be opened with. + * + * @param layout + * The new {@link SlimefunGuideLayout} + */ + public void setGuideLayout(@Nonnull SlimefunGuideLayout layout) { + this.layout = layout; + } @Override public boolean isCancelled() { From ca76411c403ec4ee9d6a314b8871a538b8236b4a Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sun, 4 Oct 2020 00:26:29 +0300 Subject: [PATCH 17/94] Update SlimefunGuideListener.java --- .../implementation/listeners/SlimefunGuideListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java index 46df132e0..e463df537 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java @@ -82,7 +82,7 @@ public class SlimefunGuideListener implements Listener { if (!event.isCancelled()) { e.cancel(); - SlimefunGuide.openGuide(p, layout); + SlimefunGuide.openGuide(p, event.getGuideLayout()); } } From d9aceea4d67aadeab0437d8ddecc2bdc7e0f4f10 Mon Sep 17 00:00:00 2001 From: Seggan Date: Sat, 3 Oct 2020 17:27:22 -0400 Subject: [PATCH 18/94] Changed 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 ce6b1e3e4..f6d93646c 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 @@ -1017,7 +1017,7 @@ public final class SlimefunItemSetup { .register(plugin); new SlimefunItem(categories.technicalGadgets, SlimefunItems.CRASH_HELMET, RecipeType.ARMOR_FORGE, - new ItemStack[]{new ItemStack(Material.IRON_INGOT), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.LEATHER_HELMET), new ItemStack(Material.IRON_INGOT)}) + new ItemStack[]{new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.LEATHER_HELMET), new ItemStack(Material.SLIME_BALL)}) .register(plugin); new PickaxeOfContainment(categories.tools, SlimefunItems.PICKAXE_OF_CONTAINMENT, RecipeType.MAGIC_WORKBENCH, From 766d0bbc53125b834fc1d84a207347504a98e04f Mon Sep 17 00:00:00 2001 From: Mooy1 <69326411+Mooy1@users.noreply.github.com> Date: Sat, 3 Oct 2020 16:27:54 -0500 Subject: [PATCH 19/94] Speed can affect enchanter/disenchanter times, fixed pom typo --- pom.xml | 2 +- .../items/electric/machines/AutoDisenchanter.java | 2 +- .../implementation/items/electric/machines/AutoEnchanter.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 2442ec7d3..167407083 100644 --- a/pom.xml +++ b/pom.xml @@ -213,7 +213,7 @@ ${spigot.javadocs} - + Slimefun4 - API 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 53c5e61b7..c7a145e0f 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 @@ -108,7 +108,7 @@ public class AutoDisenchanter extends AContainer { EmeraldEnchants.getInstance().getRegistry().applyEnchantment(disenchantedItem, ench.getEnchantment(), 0); } - MachineRecipe recipe = new MachineRecipe(90 * amount, new ItemStack[] { target, item }, new ItemStack[] { disenchantedItem, book }); + MachineRecipe recipe = new MachineRecipe(90 * amount / this.getSpeed() , new ItemStack[] { target, item }, new ItemStack[] { disenchantedItem, book }); if (!InvUtils.fitAll(menu.toInventory(), recipe.getOutput(), getOutputSlots())) { return null; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoEnchanter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoEnchanter.java index 9b9a0fe97..887b5ed74 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoEnchanter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoEnchanter.java @@ -97,7 +97,7 @@ public class AutoEnchanter extends AContainer { EmeraldEnchants.getInstance().getRegistry().applyEnchantment(enchantedItem, ench.getEnchantment(), ench.getLevel()); } - MachineRecipe recipe = new MachineRecipe(75 * amount, new ItemStack[] { target, item }, new ItemStack[] { enchantedItem, new ItemStack(Material.BOOK) }); + MachineRecipe recipe = new MachineRecipe(75 * amount / this.getSpeed(), new ItemStack[] { target, item }, new ItemStack[] { enchantedItem, new ItemStack(Material.BOOK) }); if (!InvUtils.fitAll(menu.toInventory(), recipe.getOutput(), getOutputSlots())) { return null; From e33c70e18913ba68c5f666ba6cf24e3531d3e6d3 Mon Sep 17 00:00:00 2001 From: Mooy1 <69326411+Mooy1@users.noreply.github.com> Date: Sat, 3 Oct 2020 16:33:29 -0500 Subject: [PATCH 20/94] removed accidental space --- .../implementation/items/electric/machines/AutoEnchanter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoEnchanter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoEnchanter.java index 887b5ed74..95a3c8c68 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoEnchanter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoEnchanter.java @@ -97,7 +97,7 @@ public class AutoEnchanter extends AContainer { EmeraldEnchants.getInstance().getRegistry().applyEnchantment(enchantedItem, ench.getEnchantment(), ench.getLevel()); } - MachineRecipe recipe = new MachineRecipe(75 * amount / this.getSpeed(), new ItemStack[] { target, item }, new ItemStack[] { enchantedItem, new ItemStack(Material.BOOK) }); + MachineRecipe recipe = new MachineRecipe(75 * amount / this.getSpeed(), new ItemStack[] { target, item }, new ItemStack[] { enchantedItem, new ItemStack(Material.BOOK) }); if (!InvUtils.fitAll(menu.toInventory(), recipe.getOutput(), getOutputSlots())) { return null; From dbe8755e4a23b1e5390b50b4bf90a2dac120a0f9 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sun, 4 Oct 2020 01:04:41 +0300 Subject: [PATCH 21/94] Update src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java Co-authored-by: TheBusyBiscuit --- .../slimefun4/api/events/SlimefunGuideOpenEvent.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java index d5f8109e9..77026b0ae 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java @@ -76,6 +76,7 @@ public class SlimefunGuideOpenEvent extends Event implements Cancellable { * The new {@link SlimefunGuideLayout} */ public void setGuideLayout(@Nonnull SlimefunGuideLayout layout) { + Validate.notNull(layout, "You must specify a layout that is not-null!"); this.layout = layout; } From e83e19478409004ac39c75dd8d5875c370d83ed1 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 4 Oct 2020 00:39:31 +0200 Subject: [PATCH 22/94] [CI skip] Updated changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4653ef0e..99252737f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ * Added a config option for Grappling Hooks to not be consumed on use * Added Talisman of the Caveman * You can now convert any gold ingot into gold dust with slightly less returns +* (API) Added SlimefunGuideOpenEvent #### Changes * Improved Auto-Updater (Multi-Threading and more) @@ -55,6 +56,8 @@ * Fixed #2360 * Fixed #2351 * Fixed #2357 +* Fixed Auto Enchanters being unaffected by speed modifications from addons +* Fixed Auto Disenchanters being unaffected by speed modifications from addons ## Release Candidate 16 (07 Sep 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 From f55ebc663f7e7f9c518b67f15246b673bb8eae66 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sun, 4 Oct 2020 09:47:32 +0000 Subject: [PATCH 23/94] Update dependency com.github.seeseemelk:MockBukkit-v1.16 to v0.7.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 70a205a84..e84354765 100644 --- a/pom.xml +++ b/pom.xml @@ -310,7 +310,7 @@ com.github.seeseemelk MockBukkit-v1.16 - 0.6.0 + 0.7.0 test From 91a5b5694785298d9586c5a9eafcb72855ac9ccb Mon Sep 17 00:00:00 2001 From: b10n1k Date: Sun, 4 Oct 2020 10:17:41 +0200 Subject: [PATCH 24/94] Define a constant instead of duplicating "backpacks." --- .../slimefun4/api/player/PlayerBackpack.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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 3ef400fd8..e0f2086f2 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 @@ -34,6 +34,7 @@ public class PlayerBackpack { private Inventory inventory; private int size; + private static final String CONFIG_PREFIX = "backpacks."; /** * This constructor loads an existing Backpack @@ -44,10 +45,10 @@ public class PlayerBackpack { * The id of this Backpack */ public PlayerBackpack(@Nonnull PlayerProfile profile, int id) { - this(profile, id, profile.getConfig().getInt("backpacks." + id + ".size")); + this(profile, id, profile.getConfig().getInt(CONFIG_PREFIX + id + ".size")); for (int i = 0; i < size; i++) { - inventory.setItem(i, cfg.getItem("backpacks." + id + ".contents." + i)); + inventory.setItem(i, cfg.getItem(CONFIG_PREFIX + id + ".contents." + i)); } } @@ -71,7 +72,7 @@ public class PlayerBackpack { this.cfg = profile.getConfig(); this.size = size; - cfg.setValue("backpacks." + id + ".size", size); + cfg.setValue(CONFIG_PREFIX + id + ".size", size); markDirty(); inventory = Bukkit.createInventory(null, size, "Backpack [" + size + " Slots]"); @@ -142,7 +143,7 @@ public class PlayerBackpack { } this.size = size; - cfg.setValue("backpacks." + id + ".size", size); + cfg.setValue(CONFIG_PREFIX + id + ".size", size); Inventory inv = Bukkit.createInventory(null, size, "Backpack [" + size + " Slots]"); @@ -160,7 +161,7 @@ public class PlayerBackpack { */ public void save() { for (int i = 0; i < size; i++) { - cfg.setValue("backpacks." + id + ".contents." + i, inventory.getItem(i)); + cfg.setValue(CONFIG_PREFIX + id + ".contents." + i, inventory.getItem(i)); } } From 70be1c38d0c79d82f1e1879a51aef15c7ec26149 Mon Sep 17 00:00:00 2001 From: Seggan Date: Sun, 4 Oct 2020 14:42:50 -0400 Subject: [PATCH 25/94] Did requested changes --- .../implementation/SlimefunItems.java | 2 +- .../implementation/SlimefunPlugin.java | 4 ++-- .../implementation/items/armor/ElytraCap.java | 19 +++++++++++++++++++ ...etListener.java => ElytraCapListener.java} | 16 ++++++++++++---- .../implementation/setup/ResearchSetup.java | 2 +- .../setup/SlimefunItemSetup.java | 3 ++- 6 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java rename src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/{CrashHelmetListener.java => ElytraCapListener.java} (69%) 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 7deb21d4d..0e16a5ce4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -56,7 +56,7 @@ public final class SlimefunItems { public static final SlimefunItemStack REINFORCED_CLOTH = new SlimefunItemStack("REINFORCED_CLOTH", Material.PAPER, "&bReinforced Cloth", "", "&fThis cloth has been reinforced", "&fwith &bLead &fto protect against", "&fradioactive substances"); public static final SlimefunItemStack TIN_CAN = new SlimefunItemStack("CAN", HeadTexture.TIN_CAN, "&fTin Can"); public static final SlimefunItemStack NIGHT_VISION_GOGGLES = new SlimefunItemStack("NIGHT_VISION_GOGGLES", Material.LEATHER_HELMET, Color.BLACK, "&aNight Vision Goggles", "", "&9+ Night Vision"); - public static final SlimefunItemStack CRASH_HELMET = new SlimefunItemStack("CRASH_HELMET", Material.IRON_HELMET, "&5Crash Helmet", "", "&7This helmet will protect you from", "&7crashing while flying elytra."); + public static final SlimefunItemStack ELYTRA_CAP = new SlimefunItemStack("CRASH_HELMET", Material.LEATHER_HELMET, Color.PURPLE, "&5Crash Helmet", "", "&7This helmet will protect you from", "&7crashing while flying elytra."); public static final SlimefunItemStack FARMER_SHOES = new SlimefunItemStack("FARMER_SHOES", Material.LEATHER_BOOTS, Color.YELLOW, "&eFarmer Shoes", "", "&6&oPrevents you from trampling your Crops"); public static final SlimefunItemStack INFUSED_MAGNET = new SlimefunItemStack("INFUSED_MAGNET", HeadTexture.MAGNET, "&aInfused Magnet", "", "&fMagical infused Magnets", "&fattract nearby Items", "&fas long as it is somewhere in", "&fyour Inventory", "", "&7Hold &eShift&7 to pick up nearby Items"); public static final SlimefunItemStack RAG = new SlimefunItemStack("RAG", Material.PAPER, "&cRag", "", "&aLevel I - Medical Supply", "", "&fRestores 2 Hearts", "&fExtinguishes Fire", "", LoreBuilder.RIGHT_CLICK_TO_USE); 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 6f1a32240..b8edb1107 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java @@ -20,7 +20,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockListener import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockPhysicsListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.CargoNodeListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.CoolerListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.CrashHelmetListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.ElytraCapListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.DeathpointListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.DebugFishListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.DispenserListener; @@ -454,7 +454,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { new EntityInteractionListener(this); new MobDropListener(this); new VillagerTradingListener(this); - new CrashHelmetListener(this); + new ElytraCapListener(this); if (minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_15)) { new BeeListener(this); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java new file mode 100644 index 000000000..3f95744f3 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java @@ -0,0 +1,19 @@ +package io.github.thebusybiscuit.slimefun4.implementation.items.armor; + +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; + +/** + * A class for the Elytra Cap. + * + * @author Seggan + */ +public class ElytraCap extends SlimefunItem { + + public ElytraCap(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/CrashHelmetListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java similarity index 69% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CrashHelmetListener.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java index d18f6b484..25b37bffa 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CrashHelmetListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java @@ -1,7 +1,9 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.implementation.items.armor.ElytraCap; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; +import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -10,9 +12,14 @@ import org.bukkit.inventory.ItemStack; import javax.annotation.Nonnull; -public class CrashHelmetListener implements Listener { +/** + * The {@link Listener} for the {@link ElytraCap}. + * + * @author Seggan + */ +public class ElytraCapListener implements Listener { - public CrashHelmetListener(@Nonnull SlimefunPlugin plugin) { + public ElytraCapListener(@Nonnull SlimefunPlugin plugin) { plugin.getServer().getPluginManager().registerEvents(this, plugin); } @@ -26,8 +33,9 @@ public class CrashHelmetListener implements Listener { if (p.isGliding()) { ItemStack stack = p.getInventory().getHelmet(); SlimefunItem item = SlimefunItem.getByItem(stack); - if ((item != null) && (item.getID().equals("CRASH_HELMET"))) { - e.setDamage(0); + if (item instanceof ElytraCap) { + e.setCancelled(true); + p.playSound(p.getLocation(), Sound.BLOCK_STONE_HIT, 10, 1); } } } 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 87074f103..a83b23872 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 @@ -276,7 +276,7 @@ public final class ResearchSetup { register("climbing_pick", 265, "Block Raider", 20, SlimefunItems.CLIMBING_PICK); 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("crash_helmet", 268, "Crash Gear", 20, SlimefunItems.CRASH_HELMET); + register("crash_helmet", 268, "Crash Gear", 20, SlimefunItems.ELYTRA_CAP); } private static void register(String key, int id, String name, int defaultCost, ItemStack... items) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java index f6d93646c..e87da5234 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 @@ -5,6 +5,7 @@ import java.util.List; import javax.annotation.Nonnull; +import io.github.thebusybiscuit.slimefun4.implementation.items.armor.ElytraCap; import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.inventory.ItemStack; @@ -1016,7 +1017,7 @@ public final class SlimefunItemSetup { new PotionEffect[] {new PotionEffect(PotionEffectType.NIGHT_VISION, 600, 20)}) .register(plugin); - new SlimefunItem(categories.technicalGadgets, SlimefunItems.CRASH_HELMET, RecipeType.ARMOR_FORGE, + new ElytraCap(categories.technicalGadgets, SlimefunItems.ELYTRA_CAP, RecipeType.ARMOR_FORGE, new ItemStack[]{new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.LEATHER_HELMET), new ItemStack(Material.SLIME_BALL)}) .register(plugin); From 1dbdd077ec3c4c8d2bf85d28fb8825872320e3b5 Mon Sep 17 00:00:00 2001 From: Seggan Date: Sun, 4 Oct 2020 14:43:30 -0400 Subject: [PATCH 26/94] Updated 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 e87da5234..23f8e9fed 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 @@ -1018,7 +1018,7 @@ public final class SlimefunItemSetup { .register(plugin); new ElytraCap(categories.technicalGadgets, SlimefunItems.ELYTRA_CAP, RecipeType.ARMOR_FORGE, - new ItemStack[]{new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.LEATHER_HELMET), new ItemStack(Material.SLIME_BALL)}) + new ItemStack[]{new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.LEATHER_HELMET), new ItemStack(Material.SLIME_BALL)}) .register(plugin); new PickaxeOfContainment(categories.tools, SlimefunItems.PICKAXE_OF_CONTAINMENT, RecipeType.MAGIC_WORKBENCH, From 107125802cc7ea75b1bdd1e242b786d29dff0a1c Mon Sep 17 00:00:00 2001 From: Seggan Date: Sun, 4 Oct 2020 15:02:21 -0400 Subject: [PATCH 27/94] Forgot to change id. Reverted back to setDamage() --- .../slimefun4/implementation/SlimefunItems.java | 2 +- .../slimefun4/implementation/listeners/ElytraCapListener.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java index 0e16a5ce4..461a04ba7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -56,7 +56,7 @@ public final class SlimefunItems { public static final SlimefunItemStack REINFORCED_CLOTH = new SlimefunItemStack("REINFORCED_CLOTH", Material.PAPER, "&bReinforced Cloth", "", "&fThis cloth has been reinforced", "&fwith &bLead &fto protect against", "&fradioactive substances"); public static final SlimefunItemStack TIN_CAN = new SlimefunItemStack("CAN", HeadTexture.TIN_CAN, "&fTin Can"); public static final SlimefunItemStack NIGHT_VISION_GOGGLES = new SlimefunItemStack("NIGHT_VISION_GOGGLES", Material.LEATHER_HELMET, Color.BLACK, "&aNight Vision Goggles", "", "&9+ Night Vision"); - public static final SlimefunItemStack ELYTRA_CAP = new SlimefunItemStack("CRASH_HELMET", Material.LEATHER_HELMET, Color.PURPLE, "&5Crash Helmet", "", "&7This helmet will protect you from", "&7crashing while flying elytra."); + public static final SlimefunItemStack ELYTRA_CAP = new SlimefunItemStack("ELYTRA_CAP", Material.LEATHER_HELMET, Color.PURPLE, "&5Elytra Cap", "", "&7This helmet will protect you from", "&7crashing while flying elytra."); public static final SlimefunItemStack FARMER_SHOES = new SlimefunItemStack("FARMER_SHOES", Material.LEATHER_BOOTS, Color.YELLOW, "&eFarmer Shoes", "", "&6&oPrevents you from trampling your Crops"); public static final SlimefunItemStack INFUSED_MAGNET = new SlimefunItemStack("INFUSED_MAGNET", HeadTexture.MAGNET, "&aInfused Magnet", "", "&fMagical infused Magnets", "&fattract nearby Items", "&fas long as it is somewhere in", "&fyour Inventory", "", "&7Hold &eShift&7 to pick up nearby Items"); public static final SlimefunItemStack RAG = new SlimefunItemStack("RAG", Material.PAPER, "&cRag", "", "&aLevel I - Medical Supply", "", "&fRestores 2 Hearts", "&fExtinguishes Fire", "", LoreBuilder.RIGHT_CLICK_TO_USE); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java index 25b37bffa..76a6f7e1b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java @@ -34,8 +34,8 @@ public class ElytraCapListener implements Listener { ItemStack stack = p.getInventory().getHelmet(); SlimefunItem item = SlimefunItem.getByItem(stack); if (item instanceof ElytraCap) { - e.setCancelled(true); - p.playSound(p.getLocation(), Sound.BLOCK_STONE_HIT, 10, 1); + e.setDamage(0); + p.playSound(p.getLocation(), Sound.BLOCK_STONE_HIT, 20, 1); } } } From 67bf85e5f8bca7d383dd891f2c3ff01ce9321e13 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 4 Oct 2020 21:02:33 +0200 Subject: [PATCH 28/94] [CI skip] Added Wiki schema validation --- .github/configs/wiki-schema.json | 9 +++++++ .../yaml-linter.yml} | 0 .github/workflows/json-validator.yml | 24 +++++++++++++++++++ .github/workflows/yaml-linter.yml | 2 +- 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 .github/configs/wiki-schema.json rename .github/{yaml-linter-config.yml => configs/yaml-linter.yml} (100%) create mode 100644 .github/workflows/json-validator.yml diff --git a/.github/configs/wiki-schema.json b/.github/configs/wiki-schema.json new file mode 100644 index 000000000..e59cef7b6 --- /dev/null +++ b/.github/configs/wiki-schema.json @@ -0,0 +1,9 @@ +{ + "type" : "object", + "additionalProperties" : false, + "patternProperties" : { + "^[A-Z0-9_]+$" : { + "type" : "string" + } + } +} diff --git a/.github/yaml-linter-config.yml b/.github/configs/yaml-linter.yml similarity index 100% rename from .github/yaml-linter-config.yml rename to .github/configs/yaml-linter.yml diff --git a/.github/workflows/json-validator.yml b/.github/workflows/json-validator.yml new file mode 100644 index 000000000..2babf25fa --- /dev/null +++ b/.github/workflows/json-validator.yml @@ -0,0 +1,24 @@ +name: Validate JSON + +on: + push: + paths: + - 'src/main/resources/wiki.json' + pull_request: + paths: + - 'src/main/resources/wiki.json' + +jobs: + validate: + + name: Validate JSON + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + - name: Validate JSON + uses: docker://orrosenblatt/validate-json-action:latest@sha256:02370758b8b199e0477da11ecfdd498c75c561685056b5c31b925a4ab95df7f4 + env: + INPUT_SCHEMA: '.github/configs/wiki-schema.json' + INPUT_JSONS: 'src/main/resources/wiki.json' \ No newline at end of file diff --git a/.github/workflows/yaml-linter.yml b/.github/workflows/yaml-linter.yml index c38813bea..00f94e27c 100644 --- a/.github/workflows/yaml-linter.yml +++ b/.github/workflows/yaml-linter.yml @@ -20,4 +20,4 @@ jobs: - name: YAML Linter uses: ibiqlik/action-yamllint@v1.0.0 with: - config_file: '.github/yaml-linter-config.yml' + config_file: '.github/configs/yaml-linter.yml' From f87a1d3660f03de84949f0787976ccf6e5d7649f Mon Sep 17 00:00:00 2001 From: Seggan Date: Sun, 4 Oct 2020 15:07:11 -0400 Subject: [PATCH 29/94] Added research check --- .../slimefun4/implementation/listeners/ElytraCapListener.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java index 76a6f7e1b..c3e46da33 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java @@ -3,6 +3,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.armor.ElytraCap; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; +import me.mrCookieSlime.Slimefun.api.Slimefun; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -32,6 +33,7 @@ public class ElytraCapListener implements Listener { Player p = (Player) e.getEntity(); if (p.isGliding()) { ItemStack stack = p.getInventory().getHelmet(); + if (!Slimefun.hasUnlocked(p, stack, true)) return; SlimefunItem item = SlimefunItem.getByItem(stack); if (item instanceof ElytraCap) { e.setDamage(0); From 4af38331183885b121183ce8c1387f1bb0e3b704 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 4 Oct 2020 21:11:10 +0200 Subject: [PATCH 30/94] [CI skip] Removed trailing spaces from workflow --- .github/workflows/json-validator.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/json-validator.yml b/.github/workflows/json-validator.yml index 2babf25fa..de56bec67 100644 --- a/.github/workflows/json-validator.yml +++ b/.github/workflows/json-validator.yml @@ -10,10 +10,10 @@ on: jobs: validate: - + name: Validate JSON runs-on: ubuntu-latest - + steps: - name: Checkout Repository uses: actions/checkout@v2 @@ -21,4 +21,4 @@ jobs: uses: docker://orrosenblatt/validate-json-action:latest@sha256:02370758b8b199e0477da11ecfdd498c75c561685056b5c31b925a4ab95df7f4 env: INPUT_SCHEMA: '.github/configs/wiki-schema.json' - INPUT_JSONS: 'src/main/resources/wiki.json' \ No newline at end of file + INPUT_JSONS: 'src/main/resources/wiki.json' From 8bbef4c9110b6c20774d9c53e5d5e7a63166c9a8 Mon Sep 17 00:00:00 2001 From: Seggan Date: Sun, 4 Oct 2020 16:08:42 -0400 Subject: [PATCH 31/94] Did some requested changes --- .../implementation/SlimefunPlugin.java | 73 +++++++++---------- .../implementation/items/armor/ElytraCap.java | 16 ++-- .../listeners/ElytraCapListener.java | 6 ++ .../setup/SlimefunItemSetup.java | 2 +- 4 files changed, 54 insertions(+), 43 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 b8edb1107..e12cdcf3c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java @@ -12,43 +12,6 @@ import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.Nullable; - -import io.github.thebusybiscuit.slimefun4.implementation.listeners.AncientAltarListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.BackpackListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.BeeListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockPhysicsListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.CargoNodeListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.CoolerListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.ElytraCapListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.DeathpointListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.DebugFishListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.DispenserListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.EnhancedFurnaceListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.EntityInteractionListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.ExplosionsListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.FireworksListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.GadgetsListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.GrapplingHookListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.IronGolemListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.ItemPickupListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.MobDropListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.MultiBlockListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.PiglinListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.PlayerProfileListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.SeismicAxeListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunBootsListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunBowListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunGuideListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunItemConsumeListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunItemListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.SoulboundListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.TalismanListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.VampireBladeListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.VanillaMachinesListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.VillagerTradingListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.WitherListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.WorldListener; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.Server; @@ -92,6 +55,42 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors import io.github.thebusybiscuit.slimefun4.implementation.items.tools.GrapplingHook; import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.SeismicAxe; import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.VampireBlade; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.AncientAltarListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.BackpackListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.BeeListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockPhysicsListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.CargoNodeListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.CoolerListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.ElytraCapListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.DeathpointListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.DebugFishListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.DispenserListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.EnhancedFurnaceListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.EntityInteractionListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.ExplosionsListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.FireworksListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.GadgetsListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.GrapplingHookListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.IronGolemListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.ItemPickupListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.MobDropListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.MultiBlockListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.PiglinListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.PlayerProfileListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.SeismicAxeListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunBootsListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunBowListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunGuideListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunItemConsumeListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunItemListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.SoulboundListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.TalismanListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.VampireBladeListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.VanillaMachinesListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.VillagerTradingListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.WitherListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.WorldListener; import io.github.thebusybiscuit.slimefun4.implementation.resources.GEOResourcesSetup; import io.github.thebusybiscuit.slimefun4.implementation.setup.PostSetup; import io.github.thebusybiscuit.slimefun4.implementation.setup.ResearchSetup; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java index 3f95744f3..f81ab0e6f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java @@ -1,19 +1,25 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.armor; +import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; 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 org.bukkit.potion.PotionEffect; /** - * A class for the Elytra Cap. + * The {@link ElytraCap} negates damage taken when crashing into a wall using elytra. * * @author Seggan */ -public class ElytraCap extends SlimefunItem { +public class ElytraCap extends SlimefunArmorPiece implements DamageableItem { - public ElytraCap(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { - super(category, item, recipeType, recipe); + public ElytraCap(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, PotionEffect[] effects) { + super(category, item, recipeType, recipe, effects); + } + + @Override + public boolean isDamageable() { + return true; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java index c3e46da33..656ceaee3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java @@ -1,15 +1,18 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; +import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.armor.ElytraCap; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.api.Slimefun; +import org.bukkit.GameMode; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.Damageable; import javax.annotation.Nonnull; @@ -38,6 +41,9 @@ public class ElytraCapListener implements Listener { if (item instanceof ElytraCap) { e.setDamage(0); p.playSound(p.getLocation(), Sound.BLOCK_STONE_HIT, 20, 1); + if (p.getGameMode() != GameMode.CREATIVE) { + ((ElytraCap) item).damageItem(p, stack); + } } } } 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 23f8e9fed..118f4e2fa 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 @@ -1018,7 +1018,7 @@ public final class SlimefunItemSetup { .register(plugin); new ElytraCap(categories.technicalGadgets, SlimefunItems.ELYTRA_CAP, RecipeType.ARMOR_FORGE, - new ItemStack[]{new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.LEATHER_HELMET), new ItemStack(Material.SLIME_BALL)}) + new ItemStack[]{new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.LEATHER_HELMET), new ItemStack(Material.SLIME_BALL)}, null) .register(plugin); new PickaxeOfContainment(categories.tools, SlimefunItems.PICKAXE_OF_CONTAINMENT, RecipeType.MAGIC_WORKBENCH, From 12038c2c96d17605f528ad70d489cb6b0d9f47c7 Mon Sep 17 00:00:00 2001 From: Om Uparkar Date: Mon, 5 Oct 2020 03:35:03 +0530 Subject: [PATCH 32/94] updated wiki.json --- src/main/resources/wiki.json | 146 ++++++++++++++++++++++++++++++++++- 1 file changed, 145 insertions(+), 1 deletion(-) diff --git a/src/main/resources/wiki.json b/src/main/resources/wiki.json index 3b598bcf9..3817a5082 100644 --- a/src/main/resources/wiki.json +++ b/src/main/resources/wiki.json @@ -99,5 +99,149 @@ "ORE_CRUSHER" : "Ore-Crusher", "PRESSURE_CHAMBER" : "Pressure-Chamber", "GRIND_STONE" : "Grind-Stone", - "MAGIC_WORKBENCH" : "Magic-Workbench" + "MAGIC_WORKBENCH" : "Magic-Workbench", + "PORTABLE_CRAFTER" : "Portable-Crafter", + "PORTABLE_DUSTBIN" : "Portable-Dustbin", + "COOLER" : "Cooler", + "ALUMINUM_BRASS_INGOT" : "Aluminium-Brass-Ingot", + "ALUMINUM_BRONZE_INGOT" : "Aluminum-Bronze-Ingot", + "ALUMINUM_DUST" : "Aluminum-Dust", + "ALUMINUM_INGOT" : "Aluminum-Ingot", + "GLOWSTONE_HELMET" : "Armor", + "GLOWSTONE_CHESTPLATE" : "Armor", + "GLOWSTONE_LEGGINGS" : "Armor", + "GLOWSTONE_BOOTS" : "Armor", + "ENDER_HELMET" : "Armor", + "ENDER_CHESTPLATE" : "Armor", + "ENDER_LEGGINGS" : "Armor", + "ENDER_BOOTS" : "Armor", + "SLIME_HELMET" : "Armor", + "SLIME_CHESTPLATE" : "Armor", + "SLIME_LEGGINGS" : "Armor", + "SLIME_BOOTS" : "Armor", + "CACTUS_HELMET" : "Armor", + "CACTUS_CHESTPLATE" : "Armor", + "CACTUS_LEGGINGS" : "Armor", + "CACTUS_BOOTS" : "Armor", + "DAMASCUS_STEEL_HELMET" : "Armor", + "DAMASCUS_STEEL_CHESTPLATE" : "Armor", + "DAMASCUS_STEEL_LEGGINGS" : "Armor", + "DAMASCUS_STEEL_BOOTS" : "Armor", + "REINFORCED_ALLOY_HELMET" : "Armor", + "REINFORCED_ALLOY_CHESTPLATE" : "Armor", + "REINFORCED_ALLOY_LEGGINGS" : "Armor", + "REINFORCED_ALLOY_BOOTS" : "Armor", + "GILDED_IRON_HELMET" : "Armor", + "GILDED_IRON_CHESTPLATE" : "Armor", + "GILDED_IRON_LEGGINGS" : "Armor", + "GILDED_IRON_BOOTS" : "Armor", + "GOLD_12K_HELMET" : "Armor", + "GOLD_12K_CHESTPLATE" : "Armor", + "GOLD_12K_LEGGINGS" : "Armor", + "GOLD_12K_BOOTS" : "Armor", + "SLIME_STEEL_HELMET" : "Armor", + "SLIME_STEEL_CHESTPLATE" : "Armor", + "SLIME_STEEL_LEGGINGS" : "Armor", + "SLIME_STEEL_BOOTS" : "Armor", + "BILLON_INGOT" : "Billon-Ingot", + "BLOCK_PLACER" : "Block-Placer", + "EXPLOSIVE_BOW" : "Bows", + "ICY_BOW" : "Bows", + "BRASS_INGOT" : "Brass-Ingot", + "BRONZE_INGOT" : "Bronze-Ingot", + "CHRISTMAS_MILK" : "Christmas-Items", + "CHRISTMAS_CHOCOLATE_MILK" : "Christmas-Items", + "CHRISTMAS_EGG_NOG" : "Christmas-Items", + "CHRISTMAS_APPLE_CIDER" : "Christmas-Items", + "CHRISTMAS_COOKIE" : "Christmas-Items", + "CHRISTMAS_FRUIT_CAKE" : "Christmas-Items", + "CHRISTMAS_APPLE_PIE" : "Christmas-Items", + "CHRISTMAS_HOT_CHOCOLATE" : "Christmas-Items", + "CHRISTMAS_CAKE" : "Christmas-Items", + "CHRISTMAS_CARAMEL" : "Christmas-Items", + "CHRISTMAS_CARAMEL_APPLE" : "Christmas-Items", + "CHRISTMAS_CHOCOLATE_APPLE" : "Christmas-Items", + "CHRISTMAS_PRESENT" : "Christmas-Items", + "RAINBOW_WOOL_XMAS" : "Christmas-Seasonal-Category", + "RAINBOW_GLASS_XMAS" : "Christmas-Seasonal-Category", + "RAINBOW_CLAY_XMAS" : "Christmas-Seasonal-Category", + "RAINBOW_GLASS_PANE_XMAS" : "Christmas-Seasonal-Category", + "RAINBOW_CONCRETE_XMAS" : "Christmas-Seasonal-Category", + "RAINBOW_GLAZED_TERRACOTTA_XMAS" : "Christmas-Seasonal-Category", + "COBALT_INGOT" : "Cobalt-Ingot", + "COPPER_DUST" : "Copper-Dust", + "COPPER_INGOT" : "Copper-Ingot", + "CORINTHIAN_BRONZE_INGOT" : "Corinthian-Bronze-Ingot", + "DAMASCUS_STEEL_INGOT" : "Damascus-Steel-Ingot", + "DURALUMIN_INGOT" : "Duralumin-Ingot", + "ELEVATOR_PLATE" : "Elevator-Plate", + "ELYTRA_SCALE" : "Elytras", + "INFUSED_ELYTRA" : "Elytras", + "SOULBOUND_ELYTRA" : "Elytras", + "ENHANCED_FURNACE" : "Enhanced-Furnaces", + "ENHANCED_FURNACE_2" : "Enhanced-Furnaces", + "ENHANCED_FURNACE_3" : "Enhanced-Furnaces", + "ENHANCED_FURNACE_4" : "Enhanced-Furnaces", + "ENHANCED_FURNACE_5" : "Enhanced-Furnaces", + "ENHANCED_FURNACE_6" : "Enhanced-Furnaces", + "ENHANCED_FURNACE_7" : "Enhanced-Furnaces", + "ENHANCED_FURNACE_8" : "Enhanced-Furnaces", + "ENHANCED_FURNACE_9" : "Enhanced-Furnaces", + "ENHANCED_FURNACE_10" : "Enhanced-Furnaces", + "ENHANCED_FURNACE_11" : "Enhanced-Furnaces", + "REINFORCED_FURNACE" : "Enhanced-Furnaces", + "CARBONADO_EDGED_FURNACE" : "Enhanced-Furnaces", + "FERROSILICON" : "Ferrosilicon", + "GEO_MINER" : "GEO-Miner", + "GPS_ACTIVATION_DEVICE_SHARED" : "GPS-Activation-Device", + "GPS_ACTIVATION_DEVICE_PERSONAL" : "GPS-Activation-Device", + "GPS_CONTROL_PANEL" : "GPS-Control-Panel", + "GPS_EMERGENCY_TRANSMITTER" : "GPS-Emergency-Transmitter", + "GPS_GEO_SCANNER" : "GPS-Geo-Scanner", + "GPS_MARKER_TOOL" : "GPS-Marker-Tool", + "GPS_TELEPORTATION_MATRIX" : "GPS-Teleporter-Matrix", + "GPS_TELEPORTER_PYLON" : "GPS-Teleporter-Pylon", + "GPS_TRANSMITTER" : "GPS-Transmitter", + "GILDED_IRON" : "Gilded-Iron", + "HARDENED_METAL_INGOT" : "Hardened-Metal", + "LEAD_DUST" : "Lead-Dust", + "LEAD_INGOT" : "Lead-Ingot", + "MAGNESIUM_DUST" : "Magnesium-Dust", + "MAGNESIUM_INGOT" : "Magnesium-Ingot", + "NICKEL_INGOT" : "Nickel-Ingot", + "OIL_PUMP" : "Oil-Pump", + "PORTABLE_GEO_SCANNER" : "Portable-Geo-Scanner", + "RAINBOW_WOOL" : "Rainbow-Blocks", + "RAINBOW_GLASS" : "Rainbow-Blocks", + "RAINBOW_CLAY" : "Rainbow-Blocks", + "RAINBOW_GLASS_PANE" : "Rainbow-Blocks", + "RAINBOW_CONCRETE" : "Rainbow-Blocks", + "RAINBOW_GLAZED_TERRACOTTA" : "Rainbow-Blocks", + "REDSTONE_ALLOY" : "Redstone-Alloy-Ingot", + "REINFORCED_ALLOY_INGOT" : "Reinforced-Alloy-Ingot", + "SILVER_DUST" : "Silver-Dust", + "SILVER_INGOT" : "Silver-Ingot", + "SOLDER_INGOTNICKEL_INGOT" : "Solder-Ingot", + "SOULBOUND_HELMET" : "Soulbound-Armor", + "SOULBOUND_CHESTPLATE" : "Soulbound-Armor", + "SOULBOUND_LEGGINGS" : "Soulbound-Armor", + "SOULBOUND_BOOTS" : "Soulbound-Armor", + "ANCIENT_RUNE_SOULBOUND" : "Soulbound-Rune", + "SOULBOUND_SWORD" : "Soulbound-Weapons", + "SOULBOUND_BOW" : "Soulbound-Weapons", + "SOULBOUND_PICKAXE" : "Soulbound-Weapons", + "SOULBOUND_AXE" : "Soulbound-Weapons", + "SOULBOUND_SHOVEL" : "Soulbound-Weapons", + "SOULBOUND_HOE" : "Soulbound-Weapons", + "SOULBOUND_TRIDENT" : "Soulbound-Weapons", + "STEEL_INGOT" : "Steel-Ingot", + "SWORD_OF_BEHEADING" : "Sword-of-Beheading", + "COMMON_TALISMAN" : "Talismans", + "ENDER_TALISMAN" : "Talismans", + "TIN_DUST" : "Tin-Dust", + "TIN_INGOT" : "Tin-Ingot", + "GRANDMAS_WALKING_STICK" : "Walking-Sticks", + "GRANDPAS_WALKING_STICK" : "Walking-Sticks", + "ZINC_DUST" : "Zinc-Dust", + "ZINC_INGOT" : "Zinc-Ingot" } From d6df2ea00c9074b5361c60081998e87c1490b24b Mon Sep 17 00:00:00 2001 From: Seggan Date: Sun, 4 Oct 2020 21:59:10 -0400 Subject: [PATCH 33/94] Added crash protection type --- .../core/attributes/ProtectionType.java | 7 +++- .../implementation/items/armor/ElytraCap.java | 34 ++++++++++++++++--- .../listeners/ElytraCapListener.java | 14 +++++--- .../setup/SlimefunItemSetup.java | 2 +- 4 files changed, 46 insertions(+), 11 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectionType.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectionType.java index df48ca2eb..bb2fd0a17 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectionType.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectionType.java @@ -21,6 +21,11 @@ public enum ProtectionType { /** * This damage type represents damage caused by a {@link Bee} */ - BEES; + BEES, + + /** + * This damage type represents damage caused by flying into a wall with an elytra + */ + FLYING_INTO_WALL; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java index f81ab0e6f..025b7a027 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java @@ -1,25 +1,51 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.armor; import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; +import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType; +import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectiveArmor; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; +import org.bukkit.NamespacedKey; import org.bukkit.inventory.ItemStack; -import org.bukkit.potion.PotionEffect; + +import javax.annotation.Nonnull; /** * The {@link ElytraCap} negates damage taken when crashing into a wall using elytra. * * @author Seggan */ -public class ElytraCap extends SlimefunArmorPiece implements DamageableItem { +public class ElytraCap extends SlimefunArmorPiece implements DamageableItem, ProtectiveArmor { - public ElytraCap(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, PotionEffect[] effects) { - super(category, item, recipeType, recipe, effects); + private NamespacedKey key; + + public ElytraCap(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + super(category, item, recipeType, recipe, null); + + key = new NamespacedKey(SlimefunPlugin.instance(), "elytra_armor"); } @Override public boolean isDamageable() { return true; } + + @Nonnull + @Override + public ProtectionType[] getProtectionTypes() { + return new ProtectionType[] {ProtectionType.FLYING_INTO_WALL}; + } + + @Override + public boolean isFullSetRequired() { + return false; + } + + @Nonnull + @Override + public NamespacedKey getArmorSetId() { + return key; + } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java index 656ceaee3..3460ac580 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java @@ -1,6 +1,8 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; +import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType; +import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectiveArmor; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.armor.ElytraCap; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; @@ -12,9 +14,9 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.Damageable; import javax.annotation.Nonnull; +import java.util.Arrays; /** * The {@link Listener} for the {@link ElytraCap}. @@ -36,13 +38,15 @@ public class ElytraCapListener implements Listener { Player p = (Player) e.getEntity(); if (p.isGliding()) { ItemStack stack = p.getInventory().getHelmet(); - if (!Slimefun.hasUnlocked(p, stack, true)) return; SlimefunItem item = SlimefunItem.getByItem(stack); - if (item instanceof ElytraCap) { + if (!Slimefun.hasUnlocked(p, item, true)) return; + if (item instanceof ProtectiveArmor) { + if (!Arrays.asList(((ProtectiveArmor) item).getProtectionTypes()) + .contains(ProtectionType.FLYING_INTO_WALL)) return; e.setDamage(0); p.playSound(p.getLocation(), Sound.BLOCK_STONE_HIT, 20, 1); - if (p.getGameMode() != GameMode.CREATIVE) { - ((ElytraCap) item).damageItem(p, stack); + if (p.getGameMode() != GameMode.CREATIVE && item instanceof DamageableItem) { + ((DamageableItem) item).damageItem(p, stack); } } } 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 118f4e2fa..23f8e9fed 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 @@ -1018,7 +1018,7 @@ public final class SlimefunItemSetup { .register(plugin); new ElytraCap(categories.technicalGadgets, SlimefunItems.ELYTRA_CAP, RecipeType.ARMOR_FORGE, - new ItemStack[]{new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.LEATHER_HELMET), new ItemStack(Material.SLIME_BALL)}, null) + new ItemStack[]{new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.LEATHER_HELMET), new ItemStack(Material.SLIME_BALL)}) .register(plugin); new PickaxeOfContainment(categories.tools, SlimefunItems.PICKAXE_OF_CONTAINMENT, RecipeType.MAGIC_WORKBENCH, From 3dcd5942aaa3be9a75747cdca1d5ce738646f1d0 Mon Sep 17 00:00:00 2001 From: Seggan Date: Sun, 4 Oct 2020 22:03:48 -0400 Subject: [PATCH 34/94] Changed some linguistic things (Biscuit needs to be an English professor) --- .../thebusybiscuit/slimefun4/implementation/SlimefunItems.java | 2 +- .../slimefun4/implementation/items/armor/ElytraCap.java | 2 +- .../slimefun4/implementation/setup/ResearchSetup.java | 2 +- src/main/resources/languages/researches_en.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java index 461a04ba7..c3bcfdf8c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -56,7 +56,7 @@ public final class SlimefunItems { public static final SlimefunItemStack REINFORCED_CLOTH = new SlimefunItemStack("REINFORCED_CLOTH", Material.PAPER, "&bReinforced Cloth", "", "&fThis cloth has been reinforced", "&fwith &bLead &fto protect against", "&fradioactive substances"); public static final SlimefunItemStack TIN_CAN = new SlimefunItemStack("CAN", HeadTexture.TIN_CAN, "&fTin Can"); public static final SlimefunItemStack NIGHT_VISION_GOGGLES = new SlimefunItemStack("NIGHT_VISION_GOGGLES", Material.LEATHER_HELMET, Color.BLACK, "&aNight Vision Goggles", "", "&9+ Night Vision"); - public static final SlimefunItemStack ELYTRA_CAP = new SlimefunItemStack("ELYTRA_CAP", Material.LEATHER_HELMET, Color.PURPLE, "&5Elytra Cap", "", "&7This helmet will protect you from", "&7crashing while flying elytra."); + public static final SlimefunItemStack ELYTRA_CAP = new SlimefunItemStack("ELYTRA_CAP", Material.LEATHER_HELMET, Color.PURPLE, "&5Elytra Cap", "", "&7This helmet will protect you from", "&7crashing while flying with an elytra."); public static final SlimefunItemStack FARMER_SHOES = new SlimefunItemStack("FARMER_SHOES", Material.LEATHER_BOOTS, Color.YELLOW, "&eFarmer Shoes", "", "&6&oPrevents you from trampling your Crops"); public static final SlimefunItemStack INFUSED_MAGNET = new SlimefunItemStack("INFUSED_MAGNET", HeadTexture.MAGNET, "&aInfused Magnet", "", "&fMagical infused Magnets", "&fattract nearby Items", "&fas long as it is somewhere in", "&fyour Inventory", "", "&7Hold &eShift&7 to pick up nearby Items"); public static final SlimefunItemStack RAG = new SlimefunItemStack("RAG", Material.PAPER, "&cRag", "", "&aLevel I - Medical Supply", "", "&fRestores 2 Hearts", "&fExtinguishes Fire", "", LoreBuilder.RIGHT_CLICK_TO_USE); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java index f81ab0e6f..49d765081 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java @@ -8,7 +8,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; /** - * The {@link ElytraCap} negates damage taken when crashing into a wall using elytra. + * The {@link ElytraCap} negates damage taken when crashing into a wall using an elytra. * * @author Seggan */ 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 a83b23872..80c2c2b1d 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 @@ -276,7 +276,7 @@ public final class ResearchSetup { register("climbing_pick", 265, "Block Raider", 20, SlimefunItems.CLIMBING_PICK); 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("crash_helmet", 268, "Crash Gear", 20, SlimefunItems.ELYTRA_CAP); + register("elytra_cap", 268, "Crash Gear", 20, SlimefunItems.ELYTRA_CAP); } private static void register(String key, int id, String name, int defaultCost, ItemStack... items) { diff --git a/src/main/resources/languages/researches_en.yml b/src/main/resources/languages/researches_en.yml index 6fb6c4811..b197c8cd8 100644 --- a/src/main/resources/languages/researches_en.yml +++ b/src/main/resources/languages/researches_en.yml @@ -244,4 +244,4 @@ slimefun: tape_measure: Tape Measure iron_golem_assembler: Automated Iron Golems villager_rune: Reset Villager Trades - crash_helmet: Crash Gear + elytra_cap: Crash Gear From bf625c3371e5a1a434a2be6773baec918ee5056f Mon Sep 17 00:00:00 2001 From: Om Uparkar Date: Mon, 5 Oct 2020 11:55:53 +0530 Subject: [PATCH 35/94] corrected spelling mistakes and stuff in wiki.json --- src/main/resources/wiki.json | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/resources/wiki.json b/src/main/resources/wiki.json index 3817a5082..7de89de83 100644 --- a/src/main/resources/wiki.json +++ b/src/main/resources/wiki.json @@ -103,22 +103,22 @@ "PORTABLE_CRAFTER" : "Portable-Crafter", "PORTABLE_DUSTBIN" : "Portable-Dustbin", "COOLER" : "Cooler", - "ALUMINUM_BRASS_INGOT" : "Aluminium-Brass-Ingot", + "ALUMINUM_BRASS_INGOT" : "Aluminum-Brass-Ingot", "ALUMINUM_BRONZE_INGOT" : "Aluminum-Bronze-Ingot", "ALUMINUM_DUST" : "Aluminum-Dust", "ALUMINUM_INGOT" : "Aluminum-Ingot", - "GLOWSTONE_HELMET" : "Armor", - "GLOWSTONE_CHESTPLATE" : "Armor", - "GLOWSTONE_LEGGINGS" : "Armor", - "GLOWSTONE_BOOTS" : "Armor", - "ENDER_HELMET" : "Armor", - "ENDER_CHESTPLATE" : "Armor", - "ENDER_LEGGINGS" : "Armor", - "ENDER_BOOTS" : "Armor", - "SLIME_HELMET" : "Armor", - "SLIME_CHESTPLATE" : "Armor", - "SLIME_LEGGINGS" : "Armor", - "SLIME_BOOTS" : "Armor", + "GLOWSTONE_HELMET" : "Magical-Armor", + "GLOWSTONE_CHESTPLATE" : "Magical-Armor", + "GLOWSTONE_LEGGINGS" : "Magical-Armor", + "GLOWSTONE_BOOTS" : "Magical-Armor", + "ENDER_HELMET" : "Magical-Armor", + "ENDER_CHESTPLATE" : "Magical-Armor", + "ENDER_LEGGINGS" : "Magical-Armor", + "ENDER_BOOTS" : "Magical-Armor", + "SLIME_HELMET" : "Magical-Armor", + "SLIME_CHESTPLATE" : "Magical-Armor", + "SLIME_LEGGINGS" : "Magical-Armor", + "SLIME_BOOTS" : "Magical-Armor", "CACTUS_HELMET" : "Armor", "CACTUS_CHESTPLATE" : "Armor", "CACTUS_LEGGINGS" : "Armor", @@ -139,10 +139,10 @@ "GOLD_12K_CHESTPLATE" : "Armor", "GOLD_12K_LEGGINGS" : "Armor", "GOLD_12K_BOOTS" : "Armor", - "SLIME_STEEL_HELMET" : "Armor", - "SLIME_STEEL_CHESTPLATE" : "Armor", - "SLIME_STEEL_LEGGINGS" : "Armor", - "SLIME_STEEL_BOOTS" : "Armor", + "SLIME_STEEL_HELMET" : "Magical-Armor", + "SLIME_STEEL_CHESTPLATE" : "Magical-Armor", + "SLIME_STEEL_LEGGINGS" : "Magical-Armor", + "SLIME_STEEL_BOOTS" : "Magical-Armor", "BILLON_INGOT" : "Billon-Ingot", "BLOCK_PLACER" : "Block-Placer", "EXPLOSIVE_BOW" : "Bows", @@ -221,7 +221,7 @@ "REINFORCED_ALLOY_INGOT" : "Reinforced-Alloy-Ingot", "SILVER_DUST" : "Silver-Dust", "SILVER_INGOT" : "Silver-Ingot", - "SOLDER_INGOTNICKEL_INGOT" : "Solder-Ingot", + "SOLDER_INGOT" : "Solder-Ingot", "SOULBOUND_HELMET" : "Soulbound-Armor", "SOULBOUND_CHESTPLATE" : "Soulbound-Armor", "SOULBOUND_LEGGINGS" : "Soulbound-Armor", From 904a9b1ef05b0a2ce84be441f955385736aff190 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 5 Oct 2020 10:01:46 +0200 Subject: [PATCH 36/94] [CI skip] Updated to MockBukit 0.10.0 --- .github/workflows/auto-approve.yml | 2 +- pom.xml | 2 +- .../slimefun4/testing/TestUtilities.java | 93 ++++--------------- .../testing/tests/items/TestItemSetup.java | 5 +- .../tools/TestClimbingPick.java | 1 - .../listeners/TestMultiblockListener.java | 1 - .../tests/multiblocks/TestMultiBlocks.java | 4 +- 7 files changed, 22 insertions(+), 86 deletions(-) diff --git a/.github/workflows/auto-approve.yml b/.github/workflows/auto-approve.yml index 0ae2f9d90..fd145561e 100644 --- a/.github/workflows/auto-approve.yml +++ b/.github/workflows/auto-approve.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Approve via actions uses: hmarr/auto-approve-action@v2.0.0 - if: github.actor == 'gitlocalize-app[bot]' || github.actor == 'renovate[bot]' + if: github.actor == 'gitlocalize-app[bot]' with: github-token: "${{ secrets.GITHUB_TOKEN }}" - name: Approve via TheBusyBot diff --git a/pom.xml b/pom.xml index e84354765..5633690dc 100644 --- a/pom.xml +++ b/pom.xml @@ -310,7 +310,7 @@ com.github.seeseemelk MockBukkit-v1.16 - 0.7.0 + 0.10.0 test 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 b6625ce90..2d6abff05 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java @@ -1,14 +1,13 @@ package io.github.thebusybiscuit.slimefun4.testing; -import be.seeseemelk.mockbukkit.ServerMock; -import io.github.thebusybiscuit.cscorelib2.item.CustomItem; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; -import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; -import io.github.thebusybiscuit.slimefun4.testing.mocks.MockSlimefunItem; -import me.mrCookieSlime.Slimefun.Lists.RecipeType; -import me.mrCookieSlime.Slimefun.Objects.Category; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; +import static org.mockito.Mockito.when; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; + +import javax.annotation.Nonnull; + import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.OfflinePlayer; @@ -19,11 +18,14 @@ import org.bukkit.plugin.Plugin; import org.junit.jupiter.api.Assertions; import org.mockito.Mockito; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; - -import static org.mockito.Mockito.when; +import io.github.thebusybiscuit.cscorelib2.item.CustomItem; +import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; +import io.github.thebusybiscuit.slimefun4.testing.mocks.MockSlimefunItem; +import me.mrCookieSlime.Slimefun.Lists.RecipeType; +import me.mrCookieSlime.Slimefun.Objects.Category; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; public final class TestUtilities { @@ -55,7 +57,8 @@ public final class TestUtilities { return item; } - public static PlayerProfile awaitProfile(OfflinePlayer player) throws InterruptedException { + @Nonnull + public static PlayerProfile awaitProfile(@Nonnull OfflinePlayer player) throws InterruptedException { CountDownLatch latch = new CountDownLatch(1); AtomicReference ref = new AtomicReference<>(); @@ -68,64 +71,4 @@ public final class TestUtilities { latch.await(2, TimeUnit.SECONDS); return ref.get(); } - - public static void registerDefaultTags(ServerMock server) { - // We really don't need these to be accurate, just fill them with some examples - // that approximate the actual content - server.createMaterialTag(NamespacedKey.minecraft("logs"), Material.OAK_LOG, - Material.STRIPPED_OAK_LOG, Material.OAK_WOOD, Material.STRIPPED_OAK_WOOD, - Material.ACACIA_LOG, Material.STRIPPED_ACACIA_LOG, Material.ACACIA_WOOD, Material.STRIPPED_ACACIA_WOOD - ); - server.createMaterialTag(NamespacedKey.minecraft("wooden_trapdoors"), Material.OAK_TRAPDOOR, - Material.BIRCH_TRAPDOOR, Material.SPRUCE_TRAPDOOR, Material.JUNGLE_TRAPDOOR, - Material.ACACIA_TRAPDOOR, Material.DARK_OAK_TRAPDOOR - ); - server.createMaterialTag(NamespacedKey.minecraft("wooden_slabs"), Material.OAK_SLAB, Material.BIRCH_SLAB, - Material.JUNGLE_SLAB, Material.SPRUCE_SLAB, Material.ACACIA_SLAB, Material.DARK_OAK_SLAB - ); - server.createMaterialTag(NamespacedKey.minecraft("wooden_fences"), Material.OAK_FENCE, Material.BIRCH_FENCE, - Material.JUNGLE_FENCE, Material.SPRUCE_FENCE, Material.ACACIA_FENCE, Material.DARK_OAK_FENCE - ); - server.createMaterialTag(NamespacedKey.minecraft("planks"), Material.OAK_PLANKS, Material.BIRCH_PLANKS, - Material.SPRUCE_PLANKS, Material.JUNGLE_PLANKS, Material.ACACIA_PLANKS, Material.DARK_OAK_PLANKS - ); - server.createMaterialTag(NamespacedKey.minecraft("small_flowers"), Material.POPPY, Material.DANDELION, - Material.AZURE_BLUET, Material.LILY_OF_THE_VALLEY - ); - server.createMaterialTag(NamespacedKey.minecraft("leaves"), Material.OAK_LEAVES, Material.BIRCH_LEAVES, - Material.SPRUCE_LEAVES, Material.JUNGLE_LEAVES, Material.ACACIA_LEAVES, Material.DARK_OAK_LEAVES - ); - server.createMaterialTag(NamespacedKey.minecraft("saplings"), Material.OAK_SAPLING, Material.BIRCH_SAPLING, - Material.SPRUCE_SAPLING, Material.JUNGLE_SAPLING, Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING - ); - server.createMaterialTag(NamespacedKey.minecraft("coral_blocks"), Material.BRAIN_CORAL_BLOCK, - Material.BUBBLE_CORAL_BLOCK, Material.FIRE_CORAL_BLOCK, Material.HORN_CORAL_BLOCK, Material.TUBE_CORAL_BLOCK - ); - server.createMaterialTag(NamespacedKey.minecraft("corals"), Material.BRAIN_CORAL, Material.BUBBLE_CORAL, - Material.FIRE_CORAL, Material.HORN_CORAL, Material.TUBE_CORAL - ); - server.createMaterialTag(NamespacedKey.minecraft("ice"), Material.ICE, Material.PACKED_ICE, - Material.FROSTED_ICE, Material.BLUE_ICE - ); - server.createMaterialTag(NamespacedKey.minecraft("fire"), Material.FIRE, Material.SOUL_FIRE); - - server.createMaterialTag(NamespacedKey.minecraft("boats"), Material.BIRCH_BOAT, Material.ACACIA_BOAT, - Material.DARK_OAK_BOAT, Material.JUNGLE_BOAT, Material.OAK_BOAT, Material.SPRUCE_BOAT - ); - server.createMaterialTag(NamespacedKey.minecraft("wooden_buttons"), Material.BIRCH_BUTTON, - Material.ACACIA_BUTTON, Material.SPRUCE_BUTTON, Material.DARK_OAK_BUTTON, - Material.JUNGLE_BOAT, Material.OAK_BUTTON - ); - server.createMaterialTag(NamespacedKey.minecraft("signs"), Material.SPRUCE_SIGN, Material.ACACIA_SIGN, - Material.OAK_SIGN, Material.JUNGLE_SIGN, Material.DARK_OAK_SIGN, Material.BIRCH_SIGN - ); - server.createMaterialTag(NamespacedKey.minecraft("wooden_doors"), Material.SPRUCE_DOOR, Material.ACACIA_DOOR, - Material.OAK_DOOR, Material.JUNGLE_DOOR, Material.DARK_OAK_DOOR, Material.BIRCH_DOOR - ); - server.createMaterialTag(NamespacedKey.minecraft("wooden_pressure_plates"), Material.SPRUCE_PRESSURE_PLATE, - Material.ACACIA_PRESSURE_PLATE, Material.OAK_PRESSURE_PLATE, Material.JUNGLE_PRESSURE_PLATE, - Material.DARK_OAK_PRESSURE_PLATE, Material.BIRCH_PRESSURE_PLATE - ); - - } } \ No newline at end of file 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/items/TestItemSetup.java index 0f1f17e92..86462ab4c 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestItemSetup.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestItemSetup.java @@ -17,11 +17,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.setup.PostSetup; import io.github.thebusybiscuit.slimefun4.implementation.setup.SlimefunItemSetup; -import io.github.thebusybiscuit.slimefun4.testing.TestUtilities; import me.mrCookieSlime.Slimefun.Objects.Category; @TestMethodOrder(value = OrderAnnotation.class) @@ -31,9 +29,8 @@ class TestItemSetup { @BeforeAll public static void load() { - ServerMock server = MockBukkit.mock(); + MockBukkit.mock(); plugin = MockBukkit.load(SlimefunPlugin.class); - TestUtilities.registerDefaultTags(server); } @AfterAll 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..f8711a9bb 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 @@ -32,7 +32,6 @@ class TestClimbingPick implements SlimefunItemTest { public static void load() { server = MockBukkit.mock(); plugin = MockBukkit.load(SlimefunPlugin.class); - TestUtilities.registerDefaultTags(server); } @AfterAll diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestMultiblockListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestMultiblockListener.java index a56f3efe7..005f249e9 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestMultiblockListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestMultiblockListener.java @@ -35,7 +35,6 @@ class TestMultiblockListener { @BeforeAll public static void load() { server = MockBukkit.mock(); - TestUtilities.registerDefaultTags(server); plugin = MockBukkit.load(SlimefunPlugin.class); listener = new MultiBlockListener(plugin); SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_LISTENER_TEST", new CustomItem(Material.DIAMOND, "&9Some multiblock item")); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/multiblocks/TestMultiBlocks.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/multiblocks/TestMultiBlocks.java index b226d5c0a..a6c41be2a 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/multiblocks/TestMultiBlocks.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/multiblocks/TestMultiBlocks.java @@ -9,7 +9,6 @@ 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.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; @@ -22,8 +21,7 @@ class TestMultiBlocks { @BeforeAll public static void load() { - ServerMock server = MockBukkit.mock(); - TestUtilities.registerDefaultTags(server); + MockBukkit.mock(); plugin = MockBukkit.load(SlimefunPlugin.class); } From 1dc9aee48819b317cebd336700ddb428b4d7df00 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 5 Oct 2020 13:02:05 +0200 Subject: [PATCH 37/94] [CI skip] Updated MockBukkit to 0.10.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5633690dc..d597ad3b1 100644 --- a/pom.xml +++ b/pom.xml @@ -310,7 +310,7 @@ com.github.seeseemelk MockBukkit-v1.16 - 0.10.0 + 0.10.1 test From 5ec63f632f0480d70e61d5774bca51e7934419bf Mon Sep 17 00:00:00 2001 From: svr333 Date: Mon, 5 Oct 2020 14:20:44 +0200 Subject: [PATCH 38/94] Update 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 254a3f511..a33a279d7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -63,7 +63,7 @@ public final class SlimefunItems { public static final SlimefunItemStack SPLINT = new SlimefunItemStack("SPLINT", Material.STICK, "&cSplint", "", "&aLevel I - Medical Supply", "", "&fRestores 2 Hearts", "", LoreBuilder.RIGHT_CLICK_TO_USE); public static final SlimefunItemStack VITAMINS = new SlimefunItemStack("VITAMINS", Material.NETHER_WART, "&cVitamins", "", "&aLevel III - Medical Supply", "", "&fRestores 4 Hearts", "&fExtinguishes Fire", "&fCures Poison/Wither/Radiation", "", LoreBuilder.RIGHT_CLICK_TO_USE); public static final SlimefunItemStack MEDICINE = new SlimefunItemStack("MEDICINE", Material.POTION, Color.RED, "&cMedicine", "", "&aLevel III - Medical Supply", "", "&fRestores 4 Hearts", "&fExtinguishes Fire", "&fCures Poison/Wither/Radiation"); - public static final SlimefunItemStack MAGICAL_ZOMBIE_PILLS = new SlimefunItemStack("MAGICAL_ZOMBIE_PILLS", Material.NETHER_WART, "&6Magical Zombie Pills", "", "&eRight Click &7a Zombified Villager to", "&7instantly cure it from its curse"); + public static final SlimefunItemStack MAGICAL_ZOMBIE_PILLS = new SlimefunItemStack("MAGICAL_ZOMBIE_PILLS", Material.NETHER_WART, "&6Magical Zombie Pills", "", "&eRight Click &7a Zombified Villager", "&eor &7a Zombified Piglin to", "&7instantly cure it from its curse"); public static final SlimefunItemStack FLASK_OF_KNOWLEDGE = new SlimefunItemStack("FLASK_OF_KNOWLEDGE", Material.GLASS_BOTTLE, "&cFlask of Knowledge", "", "&fAllows you to store some of", "&fyour Experience in a Bottle", "&7Cost: &a1 Level"); public static final SlimefunItemStack FILLED_FLASK_OF_KNOWLEDGE = new SlimefunItemStack("FILLED_FLASK_OF_KNOWLEDGE", Material.EXPERIENCE_BOTTLE, "&aFlask of Knowledge"); From e1488c0811997a083f01cd51bdcf94e258e27d90 Mon Sep 17 00:00:00 2001 From: svr333 Date: Mon, 5 Oct 2020 14:56:40 +0200 Subject: [PATCH 39/94] Add Zombified piglin conversion --- .../items/magical/MagicalZombiePills.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 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 775a970bd..34ab39174 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java @@ -1,12 +1,10 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.magical; +import org.bukkit.Bukkit; import org.bukkit.GameMode; +import org.bukkit.Location; import org.bukkit.Sound; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.entity.Villager; -import org.bukkit.entity.ZombieVillager; +import org.bukkit.entity.*; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; @@ -63,6 +61,21 @@ public class MagicalZombiePills extends SimpleSlimefunItem Date: Mon, 5 Oct 2020 14:58:53 +0200 Subject: [PATCH 40/94] Fix imports --- .../implementation/items/magical/MagicalZombiePills.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 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 34ab39174..58d4f058a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java @@ -1,10 +1,13 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.magical; -import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Sound; -import org.bukkit.entity.*; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.entity.Villager; +import org.bukkit.entity.ZombieVillager; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; From 21bf7cf60704eee6da3dfaf9ebaae223f305e48f Mon Sep 17 00:00:00 2001 From: svr333 Date: Mon, 5 Oct 2020 15:00:21 +0200 Subject: [PATCH 41/94] Refactor slightly --- .../implementation/items/magical/MagicalZombiePills.java | 3 +-- 1 file changed, 1 insertion(+), 2 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 58d4f058a..f30bdc669 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 @@ -72,9 +72,8 @@ public class MagicalZombiePills extends SimpleSlimefunItem Date: Mon, 5 Oct 2020 15:07:04 +0200 Subject: [PATCH 42/94] [CI skip] Updated MockBukkit to 0.10.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d597ad3b1..eba85470d 100644 --- a/pom.xml +++ b/pom.xml @@ -310,7 +310,7 @@ com.github.seeseemelk MockBukkit-v1.16 - 0.10.1 + 0.10.2 test From a01d33fea317b73611fa29092bfc3e2f88709204 Mon Sep 17 00:00:00 2001 From: svr333 Date: Mon, 5 Oct 2020 15:25:11 +0200 Subject: [PATCH 43/94] Refactor --- .../items/magical/MagicalZombiePills.java | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 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 f30bdc669..134de0d6e 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 @@ -48,7 +48,7 @@ public class MagicalZombiePills extends SimpleSlimefunItem { Entity entity = e.getRightClicked(); - if (entity.getType() == EntityType.ZOMBIE_VILLAGER) { + if (entity.getType() == EntityType.ZOMBIE_VILLAGER || entity.getType() == EntityType.ZOMBIFIED_PIGLIN) { Player p = e.getPlayer(); if (p.getGameMode() != GameMode.CREATIVE) { @@ -57,26 +57,20 @@ public class MagicalZombiePills extends SimpleSlimefunItem Date: Mon, 5 Oct 2020 15:28:43 +0200 Subject: [PATCH 44/94] Extra code to separate methods --- .../items/magical/MagicalZombiePills.java | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 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 134de0d6e..976b080b0 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 @@ -58,18 +58,11 @@ public class MagicalZombiePills extends SimpleSlimefunItem Date: Mon, 5 Oct 2020 15:29:02 +0200 Subject: [PATCH 45/94] Add newline --- .../implementation/items/magical/MagicalZombiePills.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java index 976b080b0..141ed39df 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 @@ -91,4 +91,4 @@ public class MagicalZombiePills extends SimpleSlimefunItem Date: Mon, 5 Oct 2020 15:30:23 +0200 Subject: [PATCH 46/94] Fix compile error --- .../implementation/items/magical/MagicalZombiePills.java | 4 ++-- 1 file changed, 2 insertions(+), 2 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 141ed39df..89ef16aec 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 @@ -58,7 +58,7 @@ public class MagicalZombiePills extends SimpleSlimefunItem Date: Mon, 5 Oct 2020 15:33:48 +0200 Subject: [PATCH 47/94] Add @nonnull --- .../implementation/items/magical/MagicalZombiePills.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 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 89ef16aec..1b336c640 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 @@ -23,6 +23,8 @@ 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} allows you to convert any {@link ZombieVillager} to * their {@link Villager} variant. It is also one of the very few utilisations of {@link EntityInteractHandler}. @@ -77,7 +79,7 @@ public class MagicalZombiePills extends SimpleSlimefunItem Date: Mon, 5 Oct 2020 15:37:45 +0200 Subject: [PATCH 48/94] Use instanceof --- .../items/magical/MagicalZombiePills.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 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 1b336c640..61d0282d2 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 @@ -3,11 +3,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.magical; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Sound; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.entity.Villager; -import org.bukkit.entity.ZombieVillager; +import org.bukkit.entity.*; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; @@ -50,7 +46,7 @@ public class MagicalZombiePills extends SimpleSlimefunItem { Entity entity = e.getRightClicked(); - if (entity.getType() == EntityType.ZOMBIE_VILLAGER || entity.getType() == EntityType.ZOMBIFIED_PIGLIN) { + if (entity instanceof ZombieVillager || entity instanceof PigZombie) { Player p = e.getPlayer(); if (p.getGameMode() != GameMode.CREATIVE) { @@ -59,11 +55,11 @@ public class MagicalZombiePills extends SimpleSlimefunItem Date: Mon, 5 Oct 2020 15:38:21 +0200 Subject: [PATCH 49/94] Fix imports --- .../implementation/items/magical/MagicalZombiePills.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java index 61d0282d2..9513705e4 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 @@ -3,7 +3,11 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.magical; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Sound; -import org.bukkit.entity.*; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.entity.Villager; +import org.bukkit.entity.ZombieVillager; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; From b8c2c97766abc475e12ea9aa8fc7b010acdffcec Mon Sep 17 00:00:00 2001 From: svr333 Date: Mon, 5 Oct 2020 15:43:24 +0200 Subject: [PATCH 50/94] Add missing import --- .../implementation/items/magical/MagicalZombiePills.java | 1 + 1 file changed, 1 insertion(+) 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 9513705e4..bb9c5ce7b 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 @@ -8,6 +8,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.entity.Villager; import org.bukkit.entity.ZombieVillager; +import org.bukkit.entity.PigZombie; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; From 0a19f767872159d6cb963230c81da0bfa403e89c Mon Sep 17 00:00:00 2001 From: svr333 Date: Mon, 5 Oct 2020 15:56:54 +0200 Subject: [PATCH 51/94] Use PigZombie over Entity --- .../implementation/items/magical/MagicalZombiePills.java | 4 ++-- 1 file changed, 2 insertions(+), 2 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 bb9c5ce7b..61b3f0b47 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java @@ -65,7 +65,7 @@ public class MagicalZombiePills extends SimpleSlimefunItem Date: Mon, 5 Oct 2020 10:01:38 -0400 Subject: [PATCH 52/94] Moved elytra cap to magical gadgets --- .../slimefun4/implementation/setup/SlimefunItemSetup.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 23f8e9fed..653df9d6f 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 @@ -1017,10 +1017,6 @@ public final class SlimefunItemSetup { new PotionEffect[] {new PotionEffect(PotionEffectType.NIGHT_VISION, 600, 20)}) .register(plugin); - new ElytraCap(categories.technicalGadgets, SlimefunItems.ELYTRA_CAP, RecipeType.ARMOR_FORGE, - new ItemStack[]{new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.LEATHER_HELMET), new ItemStack(Material.SLIME_BALL)}) - .register(plugin); - new PickaxeOfContainment(categories.tools, SlimefunItems.PICKAXE_OF_CONTAINMENT, RecipeType.MAGIC_WORKBENCH, new ItemStack[] {SlimefunItems.FERROSILICON, SlimefunItems.FERROSILICON, SlimefunItems.FERROSILICON, null, SlimefunItems.GILDED_IRON, null, null, SlimefunItems.GILDED_IRON, null}) .register(plugin); @@ -1122,6 +1118,10 @@ public final class SlimefunItemSetup { new ItemStack[] {SlimefunItems.NICKEL_INGOT, SlimefunItems.ALUMINUM_DUST, SlimefunItems.IRON_DUST, SlimefunItems.COBALT_INGOT, null, null, null, null, null}) .register(plugin); + new ElytraCap(categories.magicalGadgets, SlimefunItems.ELYTRA_CAP, RecipeType.ARMOR_FORGE, + new ItemStack[]{new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.LEATHER_HELMET), new ItemStack(Material.SLIME_BALL)}) + .register(plugin); + new InfusedMagnet(categories.magicalGadgets, SlimefunItems.INFUSED_MAGNET, RecipeType.MAGIC_WORKBENCH, new ItemStack[] {SlimefunItems.MAGIC_LUMP_3, null, SlimefunItems.MAGIC_LUMP_3, SlimefunItems.ENDER_LUMP_2, SlimefunItems.MAGNET, SlimefunItems.ENDER_LUMP_2, SlimefunItems.MAGIC_LUMP_3, null, SlimefunItems.MAGIC_LUMP_3}) .register(plugin); From b3ca362df2f766b88dbd8e6faa3efb38d2173a12 Mon Sep 17 00:00:00 2001 From: svr333 Date: Mon, 5 Oct 2020 16:06:19 +0200 Subject: [PATCH 53/94] Add DisplayRecipes --- .../slimefun4/implementation/items/multiblocks/TableSaw.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java index 22caf32c7..817170746 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java @@ -46,6 +46,11 @@ public class TableSaw extends MultiBlockMachine { displayedRecipes.add(new ItemStack(planks.get(), 8)); } } + + for (Material plank: Tag.PLANKS.getValues()) { + displayedRecipes.add(new ItemStack(plank)); + displayedRecipes.add(new ItemStack(Material.STICK, 4)); + } } @Override From 0e57d94d61d4249fbfad78ff2d439466a46fa374 Mon Sep 17 00:00:00 2001 From: svr333 Date: Mon, 5 Oct 2020 16:28:23 +0200 Subject: [PATCH 54/94] Add Sticks recipe to Table Saw --- .../items/multiblocks/TableSaw.java | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java index 817170746..3d32e075c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java @@ -60,16 +60,32 @@ public class TableSaw extends MultiBlockMachine { @Override public void onInteract(Player p, Block b) { - ItemStack log = p.getInventory().getItemInMainHand(); + ItemStack item = p.getInventory().getItemInMainHand(); - Optional planks = MaterialConverter.getPlanksFromLog(log.getType()); + boolean itemIsAPlank = false; + Optional planks = MaterialConverter.getPlanksFromLog(item.getType()); + + for (Material plank: Tag.PLANKS.getValues()) { + if (item.getType() == plank) { + itemIsAPlank = true; + break; + } + } + + if (planks.isPresent() || itemIsAPlank) { + ItemStack output = null; - if (planks.isPresent()) { if (p.getGameMode() != GameMode.CREATIVE) { - ItemUtils.consumeItem(log, true); + ItemUtils.consumeItem(item, true); + } + + if (planks.isPresent()) { + output = new ItemStack(planks.get(), 8); + } + else if (itemIsAPlank) { + output = new ItemStack(Material.STICK, 4); } - ItemStack output = new ItemStack(planks.get(), 8); Inventory outputChest = findOutputChest(b, output); if (outputChest != null) { @@ -79,7 +95,7 @@ public class TableSaw extends MultiBlockMachine { b.getWorld().dropItemNaturally(b.getLocation(), output); } - b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, log.getType()); + b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, item.getType()); } } From 58e2b9ab3b694f1e750fafc911ab6ea5e4ff33c4 Mon Sep 17 00:00:00 2001 From: Seggan Date: Mon, 5 Oct 2020 11:01:58 -0400 Subject: [PATCH 55/94] Added default annonation --- .../slimefun4/implementation/items/armor/ElytraCap.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java index ef4cc2b1c..a3457bef6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java @@ -11,6 +11,7 @@ import org.bukkit.NamespacedKey; import org.bukkit.inventory.ItemStack; import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; /** * The {@link ElytraCap} negates damage taken when crashing into a wall using an elytra. @@ -21,6 +22,7 @@ public class ElytraCap extends SlimefunArmorPiece implements DamageableItem, Pro private NamespacedKey key; + @ParametersAreNonnullByDefault public ElytraCap(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe, null); From 8675e96e75811a0eac025ab530095016dd5f16e6 Mon Sep 17 00:00:00 2001 From: Senne Van Rompaey Date: Mon, 5 Oct 2020 17:11:56 +0200 Subject: [PATCH 56/94] Add space Co-authored-by: LinoxGH <54643600+LinoxGH@users.noreply.github.com> --- .../slimefun4/implementation/items/multiblocks/TableSaw.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java index 3d32e075c..feb3d94f7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java @@ -47,7 +47,7 @@ public class TableSaw extends MultiBlockMachine { } } - for (Material plank: Tag.PLANKS.getValues()) { + for (Material plank : Tag.PLANKS.getValues()) { displayedRecipes.add(new ItemStack(plank)); displayedRecipes.add(new ItemStack(Material.STICK, 4)); } From cff403a7b975e16910cf9d79d034792f5c2c53bd Mon Sep 17 00:00:00 2001 From: Sfiguz7 Date: Mon, 5 Oct 2020 17:15:53 +0200 Subject: [PATCH 57/94] Added blackstone and basalt to crucible's recipes --- .../slimefun4/implementation/items/blocks/Crucible.java | 6 ++++++ .../items/electric/machines/ElectrifiedCrucible.java | 2 ++ 2 files changed, 8 insertions(+) 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 4ed2e7e3d..690df1e74 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 @@ -50,6 +50,12 @@ public class Crucible extends SimpleSlimefunItem implements Rec items.add(new ItemStack(Material.COBBLESTONE, 16)); items.add(new ItemStack(Material.LAVA_BUCKET)); + items.add(new ItemStack(Material.BLACKSTONE, 16)); + items.add(new ItemStack(Material.LAVA_BUCKET)); + + items.add(new ItemStack(Material.BASALT, 16)); + items.add(new ItemStack(Material.LAVA_BUCKET)); + items.add(new ItemStack(Material.NETHERRACK, 16)); items.add(new ItemStack(Material.LAVA_BUCKET)); 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..6a020e0ee 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 @@ -19,6 +19,8 @@ public abstract class ElectrifiedCrucible extends AContainer { @Override protected void registerDefaultRecipes() { registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.COBBLESTONE, 16) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); + registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.BASALT, 16) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); + registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.BLACKSTONE, 16) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); 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) }); From 87dedf34925848c269159e11cdb706c0b839190a Mon Sep 17 00:00:00 2001 From: Sfiguz7 Date: Mon, 5 Oct 2020 17:17:16 +0200 Subject: [PATCH 58/94] Swapped order as it makes more sense + consistency --- .../items/electric/machines/ElectrifiedCrucible.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6a020e0ee..40501ab19 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 @@ -19,8 +19,8 @@ public abstract class ElectrifiedCrucible extends AContainer { @Override protected void registerDefaultRecipes() { registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.COBBLESTONE, 16) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); - registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.BASALT, 16) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.BLACKSTONE, 16) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); + registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.BASALT, 16) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); 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) }); From 62aa2dd0d86247565f4332f5a48691c5acbeb773 Mon Sep 17 00:00:00 2001 From: svr333 Date: Mon, 5 Oct 2020 17:23:40 +0200 Subject: [PATCH 59/94] Simplify displayrecipes and use planks.isTagged() --- .../items/multiblocks/TableSaw.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java index feb3d94f7..2fe0a351d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; +import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import org.bukkit.Effect; import org.bukkit.GameMode; import org.bukkit.Material; @@ -47,10 +48,10 @@ public class TableSaw extends MultiBlockMachine { } } - for (Material plank : Tag.PLANKS.getValues()) { - displayedRecipes.add(new ItemStack(plank)); - displayedRecipes.add(new ItemStack(Material.STICK, 4)); - } + CustomItem ci = new CustomItem(Material.OAK_PLANKS, "Any Wooden Plank"); + + displayedRecipes.add(new ItemStack(ci)); + displayedRecipes.add(new ItemStack(Material.STICK, 4)); } @Override @@ -62,16 +63,9 @@ public class TableSaw extends MultiBlockMachine { public void onInteract(Player p, Block b) { ItemStack item = p.getInventory().getItemInMainHand(); - boolean itemIsAPlank = false; + boolean itemIsAPlank = Tag.PLANKS.isTagged(item.getType()); Optional planks = MaterialConverter.getPlanksFromLog(item.getType()); - for (Material plank: Tag.PLANKS.getValues()) { - if (item.getType() == plank) { - itemIsAPlank = true; - break; - } - } - if (planks.isPresent() || itemIsAPlank) { ItemStack output = null; From 1d1adf9b3ee5b176236e58c2732dfad2c85c2516 Mon Sep 17 00:00:00 2001 From: Sfiguz7 Date: Mon, 5 Oct 2020 17:25:57 +0200 Subject: [PATCH 60/94] Added mc version check --- .../implementation/items/blocks/Crucible.java | 15 +++++++++------ .../electric/machines/ElectrifiedCrucible.java | 9 +++++++-- 2 files changed, 16 insertions(+), 8 deletions(-) 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 690df1e74..e34c1a48e 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 @@ -7,6 +7,7 @@ import java.util.Optional; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.Tag; @@ -50,12 +51,6 @@ public class Crucible extends SimpleSlimefunItem implements Rec items.add(new ItemStack(Material.COBBLESTONE, 16)); items.add(new ItemStack(Material.LAVA_BUCKET)); - items.add(new ItemStack(Material.BLACKSTONE, 16)); - items.add(new ItemStack(Material.LAVA_BUCKET)); - - items.add(new ItemStack(Material.BASALT, 16)); - items.add(new ItemStack(Material.LAVA_BUCKET)); - items.add(new ItemStack(Material.NETHERRACK, 16)); items.add(new ItemStack(Material.LAVA_BUCKET)); @@ -78,6 +73,14 @@ public class Crucible extends SimpleSlimefunItem implements Rec items.add(new ItemStack(Material.LAVA_BUCKET)); } + if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) { + items.add(new ItemStack(Material.BLACKSTONE, 16)); + items.add(new ItemStack(Material.LAVA_BUCKET)); + + items.add(new ItemStack(Material.BASALT, 16)); + items.add(new ItemStack(Material.LAVA_BUCKET)); + } + return items; } 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 40501ab19..d3e70e86f 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 @@ -1,5 +1,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.inventory.ItemStack; @@ -19,8 +21,6 @@ public abstract class ElectrifiedCrucible extends AContainer { @Override protected void registerDefaultRecipes() { registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.COBBLESTONE, 16) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); - registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.BLACKSTONE, 16) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); - registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.BASALT, 16) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); 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) }); @@ -31,6 +31,11 @@ public abstract class ElectrifiedCrucible extends AContainer { for (Material leaves : Tag.LEAVES.getValues()) { registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(leaves, 16) }, new ItemStack[] { new ItemStack(Material.WATER_BUCKET) }); } + + if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) { + registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.BLACKSTONE, 16) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); + registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.BASALT, 16) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); + } } @Override From fe50d962700c5093a9534d2a6fac092e150f1e2f Mon Sep 17 00:00:00 2001 From: svr333 Date: Mon, 5 Oct 2020 18:38:58 +0200 Subject: [PATCH 61/94] Remove empty line --- .../implementation/items/magical/MagicalZombiePills.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java index 61b3f0b47..e3ff5b1e0 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 @@ -63,7 +63,6 @@ public class MagicalZombiePills extends SimpleSlimefunItem Date: Mon, 5 Oct 2020 18:43:11 +0200 Subject: [PATCH 62/94] Refactor --- .../implementation/items/multiblocks/TableSaw.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java index 2fe0a351d..14c273c12 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java @@ -64,16 +64,17 @@ public class TableSaw extends MultiBlockMachine { ItemStack item = p.getInventory().getItemInMainHand(); boolean itemIsAPlank = Tag.PLANKS.isTagged(item.getType()); - Optional planks = MaterialConverter.getPlanksFromLog(item.getType()); + boolean itemIsALog = Tag.LOGS.isTagged(item.getType()); - if (planks.isPresent() || itemIsAPlank) { + if (itemIsALog || itemIsAPlank) { ItemStack output = null; if (p.getGameMode() != GameMode.CREATIVE) { ItemUtils.consumeItem(item, true); } - if (planks.isPresent()) { + if (itemIsALog) { + Optional planks = MaterialConverter.getPlanksFromLog(item.getType()); output = new ItemStack(planks.get(), 8); } else if (itemIsAPlank) { From b237d076bffb17ac319027563c717a79982490a1 Mon Sep 17 00:00:00 2001 From: svr333 Date: Mon, 5 Oct 2020 19:34:00 +0200 Subject: [PATCH 63/94] Add version check --- .../implementation/items/magical/MagicalZombiePills.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java index e3ff5b1e0..65a116426 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 @@ -51,7 +51,8 @@ public class MagicalZombiePills extends SimpleSlimefunItem { Entity entity = e.getRightClicked(); - if (entity instanceof ZombieVillager || entity instanceof PigZombie) { + if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16) && entity instanceof PigZombie + || entity instanceof ZombieVillager) { Player p = e.getPlayer(); if (p.getGameMode() != GameMode.CREATIVE) { From 868a7e566b0be9358354343e32638b1ccb7337ee Mon Sep 17 00:00:00 2001 From: svr333 Date: Mon, 5 Oct 2020 19:34:26 +0200 Subject: [PATCH 64/94] Change else if to else --- .../implementation/items/magical/MagicalZombiePills.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java index 65a116426..86125782c 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 @@ -64,7 +64,7 @@ public class MagicalZombiePills extends SimpleSlimefunItem Date: Mon, 5 Oct 2020 19:37:12 +0200 Subject: [PATCH 65/94] Change else if to else --- .../slimefun4/implementation/items/multiblocks/TableSaw.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java index 14c273c12..a0d8e0f77 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java @@ -77,7 +77,7 @@ public class TableSaw extends MultiBlockMachine { Optional planks = MaterialConverter.getPlanksFromLog(item.getType()); output = new ItemStack(planks.get(), 8); } - else if (itemIsAPlank) { + else { output = new ItemStack(Material.STICK, 4); } From 9242978a96b4c622a43722a94bfdb109c7ccfad7 Mon Sep 17 00:00:00 2001 From: svr333 Date: Mon, 5 Oct 2020 19:57:50 +0200 Subject: [PATCH 66/94] Remove redundant if-else && Consume item after output --- .../items/multiblocks/TableSaw.java | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java index a0d8e0f77..9d55867d1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java @@ -66,32 +66,33 @@ public class TableSaw extends MultiBlockMachine { boolean itemIsAPlank = Tag.PLANKS.isTagged(item.getType()); boolean itemIsALog = Tag.LOGS.isTagged(item.getType()); - if (itemIsALog || itemIsAPlank) { - ItemStack output = null; + ItemStack output = null; - if (p.getGameMode() != GameMode.CREATIVE) { - ItemUtils.consumeItem(item, true); - } - - if (itemIsALog) { - Optional planks = MaterialConverter.getPlanksFromLog(item.getType()); - output = new ItemStack(planks.get(), 8); - } - else { - output = new ItemStack(Material.STICK, 4); - } - - Inventory outputChest = findOutputChest(b, output); - - if (outputChest != null) { - outputChest.addItem(output); - } - else { - b.getWorld().dropItemNaturally(b.getLocation(), output); - } - - b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, item.getType()); + if (itemIsALog) { + Optional planks = MaterialConverter.getPlanksFromLog(item.getType()); + output = new ItemStack(planks.get(), 8); } + else if (itemIsAPlank){ + output = new ItemStack(Material.STICK, 4); + } + else { + return; + } + + if (p.getGameMode() != GameMode.CREATIVE) { + ItemUtils.consumeItem(item, true); + } + + Inventory outputChest = findOutputChest(b, output); + + if (outputChest != null) { + outputChest.addItem(output); + } + else { + b.getWorld().dropItemNaturally(b.getLocation(), output); + } + + b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, item.getType()); } } From 3ef0a67db61ee781086808cb41c2a0fbc0fddb79 Mon Sep 17 00:00:00 2001 From: svr333 Date: Mon, 5 Oct 2020 19:59:55 +0200 Subject: [PATCH 67/94] Add @Nonnull --- .../slimefun4/implementation/items/multiblocks/TableSaw.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java index 9d55867d1..baaf9bee0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java @@ -21,6 +21,8 @@ import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; +import javax.annotation.Nonnull; + /** * The {@link TableSaw} is an implementation of a {@link MultiBlockMachine} that allows * you to turn Logs into Wooden Planks. @@ -60,7 +62,7 @@ public class TableSaw extends MultiBlockMachine { } @Override - public void onInteract(Player p, Block b) { + public void onInteract(@Nonnull Player p, @Nonnull Block b) { ItemStack item = p.getInventory().getItemInMainHand(); boolean itemIsAPlank = Tag.PLANKS.isTagged(item.getType()); From 038efb83917293aeba23756ed8e3fc61ac4aa2ea Mon Sep 17 00:00:00 2001 From: svr333 Date: Mon, 5 Oct 2020 20:00:31 +0200 Subject: [PATCH 68/94] Add myself @author --- .../slimefun4/implementation/items/multiblocks/TableSaw.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java index baaf9bee0..b1695c59e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java @@ -30,6 +30,7 @@ import javax.annotation.Nonnull; * It also replaced the old "Saw Mill" from earlier versions. * * @author dniym + * @author svr333 * * @see MultiBlockMachine * From 94c5068cc2dffa47b0111a96da36cd5bc0f75d51 Mon Sep 17 00:00:00 2001 From: Senne Van Rompaey Date: Mon, 5 Oct 2020 20:03:50 +0200 Subject: [PATCH 69/94] Move version check Co-authored-by: TheBusyBiscuit --- .../implementation/items/magical/MagicalZombiePills.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java index 86125782c..c19334ea2 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 @@ -64,7 +64,7 @@ public class MagicalZombiePills extends SimpleSlimefunItem Date: Mon, 5 Oct 2020 20:07:56 +0200 Subject: [PATCH 70/94] Extract to method && remove redundant if statement --- .../items/magical/MagicalZombiePills.java | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 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 c19334ea2..7baf9f181 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 @@ -9,6 +9,7 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Villager; import org.bukkit.entity.ZombieVillager; import org.bukkit.entity.PigZombie; +import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; @@ -50,23 +51,15 @@ public class MagicalZombiePills extends SimpleSlimefunItem { Entity entity = e.getRightClicked(); + Player p = e.getPlayer(); - if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16) && entity instanceof PigZombie - || entity instanceof ZombieVillager) { - Player p = e.getPlayer(); - - if (p.getGameMode() != GameMode.CREATIVE) { - ItemUtils.consumeItem(item, false); - } - - p.playSound(p.getLocation(), Sound.ENTITY_ZOMBIE_VILLAGER_CONVERTED, 1, 1); - - if (entity instanceof ZombieVillager) { - healZombieVillager((ZombieVillager) entity, p); - } - else if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16) && entity instanceof PigZombie) { - healZombifiedPiglin((PigZombie) entity); - } + if (entity instanceof ZombieVillager) { + useItem(p); + healZombieVillager((ZombieVillager) entity, p); + } + else if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16) && entity instanceof PigZombie) { + useItem(p); + healZombifiedPiglin((PigZombie) entity); } }; } @@ -80,6 +73,14 @@ public class MagicalZombiePills extends SimpleSlimefunItem Date: Mon, 5 Oct 2020 22:50:32 +0200 Subject: [PATCH 71/94] [CI skip] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99252737f..b5a3670d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ * Added a config option for Grappling Hooks to not be consumed on use * Added Talisman of the Caveman * You can now convert any gold ingot into gold dust with slightly less returns +* Magical Zombie Pills now also work on Zombified Piglins * (API) Added SlimefunGuideOpenEvent #### Changes From 4b3e31a8c7b03c91cbd984143841779d269bd2af Mon Sep 17 00:00:00 2001 From: Seggan Date: Mon, 5 Oct 2020 16:56:25 -0400 Subject: [PATCH 72/94] Renamed listener --- .../slimefun4/implementation/SlimefunPlugin.java | 4 ++-- .../{ElytraCapListener.java => ElytraCrashListener.java} | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/{ElytraCapListener.java => ElytraCrashListener.java} (94%) 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 e12cdcf3c..2944e4621 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java @@ -62,7 +62,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockListener import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockPhysicsListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.CargoNodeListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.CoolerListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.ElytraCapListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.ElytraCrashListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.DeathpointListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.DebugFishListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.DispenserListener; @@ -453,7 +453,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { new EntityInteractionListener(this); new MobDropListener(this); new VillagerTradingListener(this); - new ElytraCapListener(this); + new ElytraCrashListener(this); if (minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_15)) { new BeeListener(this); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java similarity index 94% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java index 3460ac580..8f43a7b28 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java @@ -23,9 +23,9 @@ import java.util.Arrays; * * @author Seggan */ -public class ElytraCapListener implements Listener { +public class ElytraCrashListener implements Listener { - public ElytraCapListener(@Nonnull SlimefunPlugin plugin) { + public ElytraCrashListener(@Nonnull SlimefunPlugin plugin) { plugin.getServer().getPluginManager().registerEvents(this, plugin); } From 6e17cd2cc582090c7a864a2b2b5956b1f3a18bd7 Mon Sep 17 00:00:00 2001 From: svr333 Date: Mon, 5 Oct 2020 23:00:44 +0200 Subject: [PATCH 73/94] Extract to method --- .../items/multiblocks/TableSaw.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java index b1695c59e..11f06b551 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java @@ -65,10 +65,23 @@ public class TableSaw extends MultiBlockMachine { @Override public void onInteract(@Nonnull Player p, @Nonnull Block b) { ItemStack item = p.getInventory().getItemInMainHand(); + ItemStack output = getItemsToOutput(item); + if (output == null) { + return; + } + + if (p.getGameMode() != GameMode.CREATIVE) { + ItemUtils.consumeItem(item, true); + } + + outputItems(b, output); + b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, item.getType()); + } + + private ItemStack getItemsToOutput(@Nonnull ItemStack item) { boolean itemIsAPlank = Tag.PLANKS.isTagged(item.getType()); boolean itemIsALog = Tag.LOGS.isTagged(item.getType()); - ItemStack output = null; if (itemIsALog) { @@ -78,14 +91,11 @@ public class TableSaw extends MultiBlockMachine { else if (itemIsAPlank){ output = new ItemStack(Material.STICK, 4); } - else { - return; - } - if (p.getGameMode() != GameMode.CREATIVE) { - ItemUtils.consumeItem(item, true); - } + return output; + } + private void outputItems(@Nonnull Block b, @Nonnull ItemStack output) { Inventory outputChest = findOutputChest(b, output); if (outputChest != null) { @@ -94,8 +104,5 @@ public class TableSaw extends MultiBlockMachine { else { b.getWorld().dropItemNaturally(b.getLocation(), output); } - - b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, item.getType()); } - } From 8c44c583cff4cea288d07214f244e150003a1bda Mon Sep 17 00:00:00 2001 From: svr333 Date: Mon, 5 Oct 2020 23:01:30 +0200 Subject: [PATCH 74/94] Add nullable tag --- .../slimefun4/implementation/items/multiblocks/TableSaw.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java index 11f06b551..191ce446f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java @@ -22,6 +22,7 @@ import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import javax.annotation.Nonnull; +import javax.annotation.Nullable; /** * The {@link TableSaw} is an implementation of a {@link MultiBlockMachine} that allows @@ -79,6 +80,7 @@ public class TableSaw extends MultiBlockMachine { b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, item.getType()); } + @Nullable private ItemStack getItemsToOutput(@Nonnull ItemStack item) { boolean itemIsAPlank = Tag.PLANKS.isTagged(item.getType()); boolean itemIsALog = Tag.LOGS.isTagged(item.getType()); From a4dc1428bc5bc52362c95ac3049079cbe12d977d Mon Sep 17 00:00:00 2001 From: Seggan Date: Mon, 5 Oct 2020 17:02:09 -0400 Subject: [PATCH 75/94] Changed protection check (untested) --- .../listeners/ElytraCrashListener.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java index 8f43a7b28..f26d569b6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java @@ -1,5 +1,6 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; +import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType; import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectiveArmor; @@ -17,6 +18,7 @@ import org.bukkit.inventory.ItemStack; import javax.annotation.Nonnull; import java.util.Arrays; +import java.util.Optional; /** * The {@link Listener} for the {@link ElytraCap}. @@ -41,12 +43,19 @@ public class ElytraCrashListener implements Listener { SlimefunItem item = SlimefunItem.getByItem(stack); if (!Slimefun.hasUnlocked(p, item, true)) return; if (item instanceof ProtectiveArmor) { - if (!Arrays.asList(((ProtectiveArmor) item).getProtectionTypes()) - .contains(ProtectionType.FLYING_INTO_WALL)) return; - e.setDamage(0); - p.playSound(p.getLocation(), Sound.BLOCK_STONE_HIT, 20, 1); - if (p.getGameMode() != GameMode.CREATIVE && item instanceof DamageableItem) { - ((DamageableItem) item).damageItem(p, stack); + Optional optional = PlayerProfile.find(p); + if (!optional.isPresent()) { + PlayerProfile.request(p); + return; + } + PlayerProfile profile = optional.get(); + + if (profile.hasFullProtectionAgainst(ProtectionType.FLYING_INTO_WALL)) { + e.setDamage(0); + p.playSound(p.getLocation(), Sound.BLOCK_STONE_HIT, 20, 1); + if (p.getGameMode() != GameMode.CREATIVE && item instanceof DamageableItem) { + ((DamageableItem) item).damageItem(p, stack); + } } } } From db6295616e9e7ef3ed891c41ea0b2b9d57765ed5 Mon Sep 17 00:00:00 2001 From: Seggan Date: Mon, 5 Oct 2020 17:05:05 -0400 Subject: [PATCH 76/94] Did more requested changes --- .../slimefun4/implementation/SlimefunPlugin.java | 1 + .../slimefun4/implementation/items/armor/ElytraCap.java | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) 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 2944e4621..0a237ef2a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java @@ -12,6 +12,7 @@ import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.Nullable; + import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.Server; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java index a3457bef6..3028015ad 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java @@ -17,10 +17,12 @@ import javax.annotation.ParametersAreNonnullByDefault; * The {@link ElytraCap} negates damage taken when crashing into a wall using an elytra. * * @author Seggan + * + * @see io.github.thebusybiscuit.slimefun4.implementation.listeners.ElytraCrashListener */ public class ElytraCap extends SlimefunArmorPiece implements DamageableItem, ProtectiveArmor { - private NamespacedKey key; + private final NamespacedKey key; @ParametersAreNonnullByDefault public ElytraCap(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { From 37242fe64afd40715a5a3d74f6d57c6b2cf8e4df Mon Sep 17 00:00:00 2001 From: svr333 Date: Tue, 6 Oct 2020 01:26:23 +0200 Subject: [PATCH 77/94] Throw out variables --- .../items/multiblocks/TableSaw.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java index 191ce446f..f9adbecd7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java @@ -82,19 +82,16 @@ public class TableSaw extends MultiBlockMachine { @Nullable private ItemStack getItemsToOutput(@Nonnull ItemStack item) { - boolean itemIsAPlank = Tag.PLANKS.isTagged(item.getType()); - boolean itemIsALog = Tag.LOGS.isTagged(item.getType()); - ItemStack output = null; - - if (itemIsALog) { + if (Tag.LOGS.isTagged(item.getType())) { Optional planks = MaterialConverter.getPlanksFromLog(item.getType()); - output = new ItemStack(planks.get(), 8); + return new ItemStack(planks.get(), 8); } - else if (itemIsAPlank){ - output = new ItemStack(Material.STICK, 4); + else if (Tag.PLANKS.isTagged(item.getType())) { + return new ItemStack(Material.STICK, 4); + } + else { + return null; } - - return output; } private void outputItems(@Nonnull Block b, @Nonnull ItemStack output) { From e6ed632dd0848dbb367a7285bcb1d65b2ac974de Mon Sep 17 00:00:00 2001 From: svr333 Date: Tue, 6 Oct 2020 11:53:51 +0200 Subject: [PATCH 78/94] Refactor + undo placeholder item in displayrecipes --- .../items/multiblocks/TableSaw.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java index f9adbecd7..ba5298088 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import org.bukkit.Effect; import org.bukkit.GameMode; import org.bukkit.Material; @@ -52,10 +51,10 @@ public class TableSaw extends MultiBlockMachine { } } - CustomItem ci = new CustomItem(Material.OAK_PLANKS, "Any Wooden Plank"); - - displayedRecipes.add(new ItemStack(ci)); - displayedRecipes.add(new ItemStack(Material.STICK, 4)); + for (Material plank : Tag.PLANKS.getValues()) { + displayedRecipes.add(new ItemStack(plank)); + displayedRecipes.add(new ItemStack(Material.STICK, 4)); + } } @Override @@ -66,7 +65,7 @@ public class TableSaw extends MultiBlockMachine { @Override public void onInteract(@Nonnull Player p, @Nonnull Block b) { ItemStack item = p.getInventory().getItemInMainHand(); - ItemStack output = getItemsToOutput(item); + ItemStack output = getItemsToOutput(item.getType()); if (output == null) { return; @@ -81,12 +80,12 @@ public class TableSaw extends MultiBlockMachine { } @Nullable - private ItemStack getItemsToOutput(@Nonnull ItemStack item) { - if (Tag.LOGS.isTagged(item.getType())) { - Optional planks = MaterialConverter.getPlanksFromLog(item.getType()); + private ItemStack getItemsToOutput(@Nonnull Material item) { + if (Tag.LOGS.isTagged(item)) { + Optional planks = MaterialConverter.getPlanksFromLog(item); return new ItemStack(planks.get(), 8); } - else if (Tag.PLANKS.isTagged(item.getType())) { + else if (Tag.PLANKS.isTagged(item)) { return new ItemStack(Material.STICK, 4); } else { From fa394b4d447347c06d904ca470fd87f658ba14d5 Mon Sep 17 00:00:00 2001 From: svr333 Date: Tue, 6 Oct 2020 19:50:57 +0200 Subject: [PATCH 79/94] Call planks.isPresent() --- .../implementation/items/multiblocks/TableSaw.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java index ba5298088..0a272a911 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java @@ -83,7 +83,12 @@ public class TableSaw extends MultiBlockMachine { private ItemStack getItemsToOutput(@Nonnull Material item) { if (Tag.LOGS.isTagged(item)) { Optional planks = MaterialConverter.getPlanksFromLog(item); - return new ItemStack(planks.get(), 8); + if (planks.isPresent()) { + return new ItemStack(planks.get(), 8); + } + else { + return null; + } } else if (Tag.PLANKS.isTagged(item)) { return new ItemStack(Material.STICK, 4); From f98d048b557a3b55e7f992e4ebc06c3a83a9f6ff Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Tue, 6 Oct 2020 20:20:02 +0200 Subject: [PATCH 80/94] [CI skip] Reduced technical debt --- .../core/commands/SlimefunCommand.java | 5 +++- .../items/magical/MagicalZombiePills.java | 7 ++--- .../items/tools/GrapplingHook.java | 28 ++++++++++++++----- .../items/tools/TapeMeasure.java | 1 - .../listeners/GrapplingHookEntity.java | 10 +++---- 5 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunCommand.java index 8fd253456..5bbc09820 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunCommand.java @@ -83,7 +83,10 @@ public class SlimefunCommand implements CommandExecutor, Listener { sendHelp(sender); - return true; + // We could just return true here, but if there's no subcommands, then + // something went horribly wrong anyway. This will also stop sonarcloud + // from nagging about this always returning true... + return !commands.isEmpty(); } public void sendHelp(@Nonnull CommandSender sender) { 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 7baf9f181..5d114ee63 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java @@ -1,15 +1,16 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.magical; +import javax.annotation.Nonnull; + import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; +import org.bukkit.entity.PigZombie; import org.bukkit.entity.Player; import org.bukkit.entity.Villager; import org.bukkit.entity.ZombieVillager; -import org.bukkit.entity.PigZombie; -import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; @@ -25,8 +26,6 @@ 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} allows you to convert any {@link ZombieVillager} to * their {@link Villager} variant. It is also one of the very few utilisations of {@link EntityInteractHandler}. 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 0a9b9cb8f..8b521ecdd 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 @@ -2,6 +2,8 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.tools; import java.util.UUID; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.Material; import org.bukkit.entity.Arrow; import org.bukkit.entity.Bat; @@ -12,19 +14,33 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; 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.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.GrapplingHookListener; 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; +/** + * The {@link GrapplingHook} is a simple {@link SlimefunItem} which allows a {@link Player} + * to launch towards a target destination via right click. + * It also has a cool visual effect where it shows a leash following a fired {@link Arrow}. + * + * @author TheBusyBiscuit + * + * @see GrapplingHookListener + * + */ public class GrapplingHook extends SimpleSlimefunItem { private final ItemSetting consumeOnUse = new ItemSetting<>("consume-on-use", true); private final ItemSetting despawnTicks = new ItemSetting<>("despawn-seconds", 60); + @ParametersAreNonnullByDefault public GrapplingHook(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); @@ -37,7 +53,7 @@ public class GrapplingHook extends SimpleSlimefunItem { return e -> { Player p = e.getPlayer(); UUID uuid = p.getUniqueId(); - boolean consumeOnUseValue = consumeOnUse.getValue(); + boolean isConsumed = consumeOnUse.getValue(); if (!e.getClickedBlock().isPresent() && !SlimefunPlugin.getGrapplingHookListener().isGrappling(uuid)) { e.cancel(); @@ -49,11 +65,9 @@ public class GrapplingHook extends SimpleSlimefunItem { ItemStack item = e.getItem(); - if (item.getType() == Material.LEAD) { - //If consume on use is enabled, the if statement below will take 1 grappling hook out of player's hand - if (consumeOnUseValue) { - item.setAmount(item.getAmount() - 1); - } + if (item.getType() == Material.LEAD && isConsumed) { + // If consume on use is enabled, consume one item + ItemUtils.consumeItem(item, false); } Vector direction = p.getEyeLocation().getDirection().multiply(2.0); @@ -69,7 +83,7 @@ public class GrapplingHook extends SimpleSlimefunItem { bat.setLeashHolder(arrow); boolean state = item.getType() != Material.SHEARS; - SlimefunPlugin.getGrapplingHookListener().addGrapplingHook(p, arrow, bat, state, despawnTicks.getValue(), consumeOnUseValue); + SlimefunPlugin.getGrapplingHookListener().addGrapplingHook(p, arrow, bat, state, despawnTicks.getValue(), isConsumed); } }; } 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 c9fb3cd54..d4a6bb326 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 @@ -76,7 +76,6 @@ public class TapeMeasure extends SimpleSlimefunItem implements N SlimefunPlugin.getLocalization().sendMessage(p, "messages.tape-measure.anchor-set", msg -> msg.replace("%anchor%", anchor)); item.setItemMeta(meta); - } @Nonnull diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookEntity.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookEntity.java index 57cfa4c9b..f4572f3a4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookEntity.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookEntity.java @@ -33,12 +33,10 @@ final class GrapplingHookEntity { } public void drop(@Nonnull Location l) { - if (dropItem) { - //If a grappling hook was consumed, then the below if statement will be executed and will drop one grappling hook on the floor - if (wasConsumed) { - Item item = l.getWorld().dropItem(l, SlimefunItems.GRAPPLING_HOOK.clone()); - item.setPickupDelay(16); - } + // If a grappling hook was consumed, drop one grappling hook on the floor + if (dropItem && wasConsumed) { + Item item = l.getWorld().dropItem(l, SlimefunItems.GRAPPLING_HOOK.clone()); + item.setPickupDelay(16); } } From 07c84af3b56d2373efab00ac940ef14922b18649 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Tue, 6 Oct 2020 21:01:18 +0200 Subject: [PATCH 81/94] Added NotConfigurable attribute --- CHANGELOG.md | 2 + .../core/attributes/NotConfigurable.java | 14 +++ .../Objects/SlimefunItem/SlimefunItem.java | 103 +++++++++++++----- 3 files changed, 91 insertions(+), 28 deletions(-) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotConfigurable.java diff --git a/CHANGELOG.md b/CHANGELOG.md index b5a3670d8..032d02aeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ * You can now convert any gold ingot into gold dust with slightly less returns * Magical Zombie Pills now also work on Zombified Piglins * (API) Added SlimefunGuideOpenEvent +* (API) Added "NotConfigurable" attribute to disable configurability #### Changes * Improved Auto-Updater (Multi-Threading and more) @@ -59,6 +60,7 @@ * Fixed #2357 * Fixed Auto Enchanters being unaffected by speed modifications from addons * Fixed Auto Disenchanters being unaffected by speed modifications from addons +* Fixed radioactive items still being radioactive when disabled ## Release Candidate 16 (07 Sep 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotConfigurable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotConfigurable.java new file mode 100644 index 000000000..8d52d32c7 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotConfigurable.java @@ -0,0 +1,14 @@ +package io.github.thebusybiscuit.slimefun4.core.attributes; + +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; + +/** + * Implement this interface for any {@link SlimefunItem} to prevent + * that {@link SlimefunItem} from showing up in the {@code Items.yml} config file. + * + * @author TheBusyBiscuit + * + */ +public interface NotConfigurable { + +} diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java index 1800613fa..ca4f39e17 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java @@ -8,6 +8,7 @@ import java.util.Optional; import java.util.Set; import java.util.function.Consumer; import java.util.logging.Level; +import java.util.logging.Logger; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -30,6 +31,7 @@ import io.github.thebusybiscuit.slimefun4.api.exceptions.UnregisteredItemExcepti import io.github.thebusybiscuit.slimefun4.api.exceptions.WrongItemStackException; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; import io.github.thebusybiscuit.slimefun4.api.items.ItemState; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotConfigurable; import io.github.thebusybiscuit.slimefun4.core.attributes.Placeable; import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive; import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; @@ -360,15 +362,18 @@ public class SlimefunItem implements Placeable { SlimefunPlugin.getRegistry().getAllSlimefunItems().add(this); SlimefunPlugin.getRegistry().getSlimefunItemIds().put(id, this); - SlimefunPlugin.getItemCfg().setDefaultValue(id + ".enabled", true); - SlimefunPlugin.getItemCfg().setDefaultValue(id + ".can-be-used-in-workbenches", useableInWorkbench); - SlimefunPlugin.getItemCfg().setDefaultValue(id + ".hide-in-guide", hidden); - SlimefunPlugin.getItemCfg().setDefaultValue(id + ".allow-enchanting", enchantable); - SlimefunPlugin.getItemCfg().setDefaultValue(id + ".allow-disenchanting", disenchantable); + // Items that are "not-configurable" cannot be configured. + if (!(this instanceof NotConfigurable)) { + SlimefunPlugin.getItemCfg().setDefaultValue(id + ".enabled", true); + SlimefunPlugin.getItemCfg().setDefaultValue(id + ".can-be-used-in-workbenches", useableInWorkbench); + SlimefunPlugin.getItemCfg().setDefaultValue(id + ".hide-in-guide", hidden); + SlimefunPlugin.getItemCfg().setDefaultValue(id + ".allow-enchanting", enchantable); + SlimefunPlugin.getItemCfg().setDefaultValue(id + ".allow-disenchanting", disenchantable); - // Load all item settings - for (ItemSetting setting : itemSettings) { - setting.load(this); + // Load all item settings + for (ItemSetting setting : itemSettings) { + setting.load(this); + } } if (ticking && !SlimefunPlugin.getCfg().getBoolean("URID.enable-tickers")) { @@ -376,26 +381,17 @@ public class SlimefunItem implements Placeable { return; } - if (this instanceof Radioactive) { - SlimefunPlugin.getRegistry().getRadioactiveItems().add(this); - } - - if (SlimefunPlugin.getItemCfg().getBoolean(id + ".enabled")) { - - if (!category.isRegistered()) { - category.register(); - } - + if (this instanceof NotConfigurable) { + // Not-configurable items will be enabled. + // Any other settings will remain as default. + state = ItemState.ENABLED; + } + else if (SlimefunPlugin.getItemCfg().getBoolean(id + ".enabled")) { state = ItemState.ENABLED; - checkForDeprecations(getClass()); - useableInWorkbench = SlimefunPlugin.getItemCfg().getBoolean(id + ".can-be-used-in-workbenches"); hidden = SlimefunPlugin.getItemCfg().getBoolean(id + ".hide-in-guide"); enchantable = SlimefunPlugin.getItemCfg().getBoolean(id + ".allow-enchanting"); disenchantable = SlimefunPlugin.getItemCfg().getBoolean(id + ".allow-disenchanting"); - - SlimefunPlugin.getRegistry().getEnabledSlimefunItems().add(this); - loadItemHandlers(); } else if (this instanceof VanillaItem) { state = ItemState.VANILLA_FALLBACK; @@ -404,19 +400,43 @@ public class SlimefunItem implements Placeable { state = ItemState.DISABLED; } + // Now we can be certain this item should be enabled + if (state == ItemState.ENABLED) { + // Register the Category too if it hasn't been registered yet + if (!category.isRegistered()) { + category.register(); + } + + // Send out deprecation warnings for any classes or intefaces + checkForDeprecations(getClass()); + + // Add it to the list of enabled items + SlimefunPlugin.getRegistry().getEnabledSlimefunItems().add(this); + + // Load our Item Handlers + loadItemHandlers(); + + // Properly mark this Item as radioactive + if (this instanceof Radioactive) { + SlimefunPlugin.getRegistry().getRadioactiveItems().add(this); + } + } + + // Lock the SlimefunItemStack from any accidental manipulations if (item instanceof SlimefunItemStack && isItemStackImmutable()) { ((SlimefunItemStack) item).lock(); } postRegister(); + // handle runtime-registrations / auto-loading if (SlimefunPlugin.getRegistry().isAutoLoadingEnabled() && state == ItemState.ENABLED) { info("Item was registered during runtime."); load(); } } catch (Exception x) { - error("Registering " + toString() + " has failed", x); + error("Registering " + toString() + " has failed!", x); } } @@ -464,7 +484,7 @@ public class SlimefunItem implements Placeable { * @param c * The {@link Class} from which to start this operation. */ - private void checkForDeprecations(Class c) { + private void checkForDeprecations(@Nullable Class c) { if (SlimefunPlugin.getUpdater().getBranch() == SlimefunBranch.DEVELOPMENT) { // This method is currently way too spammy with all the restructuring going on... // Since DEV builds are anyway under "development", things may be relocated. @@ -526,6 +546,12 @@ public class SlimefunItem implements Placeable { this.recipeType = type; } + /** + * This sets the {@link Category} in which this {@link SlimefunItem} will be displayed. + * + * @param category + * The new {@link Category} + */ public void setCategory(@Nonnull Category category) { Validate.notNull(category, "The Category is not allowed to be null!"); @@ -590,6 +616,7 @@ public class SlimefunItem implements Placeable { return false; } + // If the given item is a SlimefunitemStack, simply compare the id if (item instanceof SlimefunItemStack) { return getID().equals(((SlimefunItemStack) item).getItemId()); } @@ -670,6 +697,10 @@ public class SlimefunItem implements Placeable { throw new UnsupportedOperationException("You cannot add an ItemSetting after the SlimefunItem was registered."); } + if (this instanceof NotConfigurable) { + throw new UnsupportedOperationException("This Item has been marked as NotConfigurable and cannot accept Item Settings!"); + } + for (ItemSetting setting : settings) { if (setting != null) { // Prevent two Item Settings with the same key @@ -817,12 +848,28 @@ public class SlimefunItem implements Placeable { return getDrops(); } - public void info(String message) { + /** + * This will send an info message to the console and signal that this message came + * from this {@link SlimefunItem}, the message will be sent using the {@link Logger} + * of the {@link SlimefunAddon} which registered this {@link SlimefunItem}. + * + * @param message + * The message to send + */ + public void info(@Nonnull String message) { String msg = toString() + ": " + message; addon.getLogger().log(Level.INFO, msg); } - public void warn(String message) { + /** + * This will send a warning to the console and signal that this warning came from + * this {@link SlimefunItem}, the warning will be sent using the {@link Logger} + * of the {@link SlimefunAddon} which registered this {@link SlimefunItem}. + * + * @param message + * The message to send + */ + public void warn(@Nonnull String message) { String msg = toString() + ": " + message; addon.getLogger().log(Level.WARNING, msg); @@ -841,7 +888,7 @@ public class SlimefunItem implements Placeable { * @param throwable * The {@link Throwable} to throw as a stacktrace. */ - public void error(String message, Throwable throwable) { + public void error(@Nonnull String message, @Nonnull Throwable throwable) { addon.getLogger().log(Level.SEVERE, "Item \"{0}\" from {1} v{2} has caused an Error!", new Object[] { id, addon.getName(), addon.getPluginVersion() }); if (addon.getBugTrackerURL() != null) { From d09a7e0f93c9617337832bf50cd3cfbe4e14d79c Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Tue, 6 Oct 2020 21:05:39 +0200 Subject: [PATCH 82/94] Fixes #2391 --- CHANGELOG.md | 1 + .../me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 032d02aeb..681bb6b07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,7 @@ * Fixed Auto Enchanters being unaffected by speed modifications from addons * Fixed Auto Disenchanters being unaffected by speed modifications from addons * Fixed radioactive items still being radioactive when disabled +* Fixed #2391 ## Release Candidate 16 (07 Sep 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java index 20fda5505..066e5d40f 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java @@ -127,6 +127,7 @@ public class DirtyChestMenu extends ChestMenu { if (ItemUtils.canStack(wrapper, stack)) { amount -= (stack.getMaxStackSize() - stack.getAmount()); + item.setAmount(amount); stack.setAmount(Math.min(stack.getAmount() + item.getAmount(), stack.getMaxStackSize())); } } From d1ede58f85ad6d51d2229418f859c432eaf90fa4 Mon Sep 17 00:00:00 2001 From: Seggan Date: Tue, 6 Oct 2020 15:12:35 -0400 Subject: [PATCH 83/94] More requested changes... --- .../implementation/items/armor/ElytraCap.java | 3 +- .../listeners/ElytraCrashListener.java | 38 +++++++++++-------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java index 3028015ad..cdeef8ca3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java @@ -4,6 +4,7 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType; import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectiveArmor; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.ElytraCrashListener; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; @@ -18,7 +19,7 @@ import javax.annotation.ParametersAreNonnullByDefault; * * @author Seggan * - * @see io.github.thebusybiscuit.slimefun4.implementation.listeners.ElytraCrashListener + * @see ElytraCrashListener */ public class ElytraCap extends SlimefunArmorPiece implements DamageableItem, ProtectiveArmor { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java index f26d569b6..a79edaa73 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java @@ -1,5 +1,6 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; +import io.github.thebusybiscuit.slimefun4.api.items.HashedArmorpiece; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType; @@ -39,22 +40,27 @@ public class ElytraCrashListener implements Listener { Player p = (Player) e.getEntity(); if (p.isGliding()) { - ItemStack stack = p.getInventory().getHelmet(); - SlimefunItem item = SlimefunItem.getByItem(stack); - if (!Slimefun.hasUnlocked(p, item, true)) return; - if (item instanceof ProtectiveArmor) { - Optional optional = PlayerProfile.find(p); - if (!optional.isPresent()) { - PlayerProfile.request(p); - return; - } - PlayerProfile profile = optional.get(); - - if (profile.hasFullProtectionAgainst(ProtectionType.FLYING_INTO_WALL)) { - e.setDamage(0); - p.playSound(p.getLocation(), Sound.BLOCK_STONE_HIT, 20, 1); - if (p.getGameMode() != GameMode.CREATIVE && item instanceof DamageableItem) { - ((DamageableItem) item).damageItem(p, stack); + Optional optional = PlayerProfile.find(p); + if (!optional.isPresent()) { + PlayerProfile.request(p); + return; + } + PlayerProfile profile = optional.get(); + HashedArmorpiece helmet = profile.getArmor()[0]; + SlimefunItem item; + if (helmet.getItem().isPresent()) { + item = helmet.getItem().get(); + } else { + return; + } + if (Slimefun.hasUnlocked(p, item, true)) { + if (item instanceof ProtectiveArmor) { + if (profile.hasFullProtectionAgainst(ProtectionType.FLYING_INTO_WALL)) { + e.setDamage(0); + p.playSound(p.getLocation(), Sound.BLOCK_STONE_HIT, 20, 1); + if (p.getGameMode() != GameMode.CREATIVE && item instanceof DamageableItem) { + ((DamageableItem) item).damageItem(p, p.getInventory().getHelmet()); + } } } } From 20aa5d49dc327745f65c5db9a3079a830f522b76 Mon Sep 17 00:00:00 2001 From: Seggan Date: Tue, 6 Oct 2020 15:34:37 -0400 Subject: [PATCH 84/94] Merged ifs --- .../listeners/ElytraCrashListener.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java index a79edaa73..9de71294d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java @@ -50,17 +50,12 @@ public class ElytraCrashListener implements Listener { SlimefunItem item; if (helmet.getItem().isPresent()) { item = helmet.getItem().get(); - } else { - return; - } - if (Slimefun.hasUnlocked(p, item, true)) { - if (item instanceof ProtectiveArmor) { - if (profile.hasFullProtectionAgainst(ProtectionType.FLYING_INTO_WALL)) { - e.setDamage(0); - p.playSound(p.getLocation(), Sound.BLOCK_STONE_HIT, 20, 1); - if (p.getGameMode() != GameMode.CREATIVE && item instanceof DamageableItem) { - ((DamageableItem) item).damageItem(p, p.getInventory().getHelmet()); - } + if (Slimefun.hasUnlocked(p, item, true) + && profile.hasFullProtectionAgainst(ProtectionType.FLYING_INTO_WALL)) { + e.setDamage(0); + p.playSound(p.getLocation(), Sound.BLOCK_STONE_HIT, 20, 1); + if (p.getGameMode() != GameMode.CREATIVE && item instanceof DamageableItem) { + ((DamageableItem) item).damageItem(p, p.getInventory().getHelmet()); } } } From 960d53840a8b4f3b30f654cd71931627b5cde6e1 Mon Sep 17 00:00:00 2001 From: Seggan Date: Tue, 6 Oct 2020 15:39:15 -0400 Subject: [PATCH 85/94] Moved import --- .../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 653df9d6f..891c0728a 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 @@ -5,7 +5,6 @@ import java.util.List; import javax.annotation.Nonnull; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.ElytraCap; import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.inventory.ItemStack; @@ -39,6 +38,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.armor.HazmatArmor import io.github.thebusybiscuit.slimefun4.implementation.items.armor.Parachute; import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece; import io.github.thebusybiscuit.slimefun4.implementation.items.armor.StomperBoots; +import io.github.thebusybiscuit.slimefun4.implementation.items.armor.ElytraCap; import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.Cooler; import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.EnderBackpack; import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.RestoredBackpack; From 1ccd4c14ac0dd6b4c9e2d87e92f3c14ae0911c0f Mon Sep 17 00:00:00 2001 From: Seggan Date: Tue, 6 Oct 2020 15:41:14 -0400 Subject: [PATCH 86/94] More changes... --- .../implementation/listeners/ElytraCrashListener.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java index 9de71294d..d01992c45 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java @@ -47,9 +47,8 @@ public class ElytraCrashListener implements Listener { } PlayerProfile profile = optional.get(); HashedArmorpiece helmet = profile.getArmor()[0]; - SlimefunItem item; if (helmet.getItem().isPresent()) { - item = helmet.getItem().get(); + SlimefunItem item = helmet.getItem().get(); if (Slimefun.hasUnlocked(p, item, true) && profile.hasFullProtectionAgainst(ProtectionType.FLYING_INTO_WALL)) { e.setDamage(0); From 85091516dbeb58823ab604b2bb9ec2674be7416e Mon Sep 17 00:00:00 2001 From: svr333 Date: Wed, 7 Oct 2020 12:12:02 +0200 Subject: [PATCH 87/94] Add generic fail message --- .../slimefun4/implementation/items/multiblocks/TableSaw.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java index 0a272a911..f9b9e7346 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java @@ -17,6 +17,7 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; import io.github.thebusybiscuit.cscorelib2.materials.MaterialConverter; import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; @@ -68,6 +69,7 @@ public class TableSaw extends MultiBlockMachine { ItemStack output = getItemsToOutput(item.getType()); if (output == null) { + SlimefunPlugin.getLocalization().sendMessage(p, "machines.wrong-item", true); return; } From f8be44782199f1b2a03a3f9260665dc344b9ec27 Mon Sep 17 00:00:00 2001 From: Sfiguz7 Date: Wed, 7 Oct 2020 13:32:10 +0200 Subject: [PATCH 88/94] Fixes #2403 --- .../me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java index 066e5d40f..86696d817 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java @@ -127,8 +127,8 @@ public class DirtyChestMenu extends ChestMenu { if (ItemUtils.canStack(wrapper, stack)) { amount -= (stack.getMaxStackSize() - stack.getAmount()); - item.setAmount(amount); stack.setAmount(Math.min(stack.getAmount() + item.getAmount(), stack.getMaxStackSize())); + item.setAmount(amount); } } } From 46dca73e04469a400f355018e58ccbe7b5beb71e Mon Sep 17 00:00:00 2001 From: Sfiguz7 Date: Wed, 7 Oct 2020 13:36:11 +0200 Subject: [PATCH 89/94] Forgot to clean crucible changes off --- .../implementation/items/blocks/Crucible.java | 41 +++++++------------ .../machines/ElectrifiedCrucible.java | 14 ++----- 2 files changed, 18 insertions(+), 37 deletions(-) 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 e34c1a48e..c5a5a04bc 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 @@ -1,23 +1,5 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.blocks; -import java.util.LinkedList; -import java.util.List; -import java.util.Optional; - -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; - -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.Tag; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.data.Levelled; -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; @@ -29,6 +11,21 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.Tag; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.Levelled; +import org.bukkit.block.data.Waterlogged; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; +import java.util.LinkedList; +import java.util.List; +import java.util.Optional; public class Crucible extends SimpleSlimefunItem implements RecipeDisplayItem { @@ -73,14 +70,6 @@ public class Crucible extends SimpleSlimefunItem implements Rec items.add(new ItemStack(Material.LAVA_BUCKET)); } - if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) { - items.add(new ItemStack(Material.BLACKSTONE, 16)); - items.add(new ItemStack(Material.LAVA_BUCKET)); - - items.add(new ItemStack(Material.BASALT, 16)); - items.add(new ItemStack(Material.LAVA_BUCKET)); - } - return items; } 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 d3e70e86f..031d5ce8b 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 @@ -1,16 +1,13 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; -import org.bukkit.Material; -import org.bukkit.Tag; -import org.bukkit.inventory.ItemStack; - import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; +import org.bukkit.Material; +import org.bukkit.Tag; +import org.bukkit.inventory.ItemStack; public abstract class ElectrifiedCrucible extends AContainer { @@ -31,11 +28,6 @@ public abstract class ElectrifiedCrucible extends AContainer { for (Material leaves : Tag.LEAVES.getValues()) { registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(leaves, 16) }, new ItemStack[] { new ItemStack(Material.WATER_BUCKET) }); } - - if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) { - registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.BLACKSTONE, 16) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); - registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.BASALT, 16) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); - } } @Override From 91a7d9eacd27b2e20de4fec6d1ac2ed53930da71 Mon Sep 17 00:00:00 2001 From: Sfiguz7 Date: Wed, 7 Oct 2020 13:37:32 +0200 Subject: [PATCH 90/94] Why u do dis IntelliJ >:( --- .../implementation/items/blocks/Crucible.java | 32 ++++++++++--------- .../machines/ElectrifiedCrucible.java | 7 ++-- 2 files changed, 21 insertions(+), 18 deletions(-) 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 c5a5a04bc..4ed2e7e3d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java @@ -1,5 +1,22 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.blocks; +import java.util.LinkedList; +import java.util.List; +import java.util.Optional; + +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.Tag; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.Levelled; +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; @@ -11,21 +28,6 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.Tag; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.data.Levelled; -import org.bukkit.block.data.Waterlogged; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; -import java.util.LinkedList; -import java.util.List; -import java.util.Optional; public class Crucible extends SimpleSlimefunItem implements RecipeDisplayItem { 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 031d5ce8b..8bd212d00 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 @@ -1,13 +1,14 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +import org.bukkit.Material; +import org.bukkit.Tag; +import org.bukkit.inventory.ItemStack; + import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; -import org.bukkit.Material; -import org.bukkit.Tag; -import org.bukkit.inventory.ItemStack; public abstract class ElectrifiedCrucible extends AContainer { From c33f73d2feaf23d7bfaf8d32ef801f9c7b749771 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 7 Oct 2020 14:30:01 +0200 Subject: [PATCH 91/94] [CI skip] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 681bb6b07..ae84aca7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -62,6 +62,7 @@ * Fixed Auto Disenchanters being unaffected by speed modifications from addons * Fixed radioactive items still being radioactive when disabled * Fixed #2391 +* Fixed #2403 ## Release Candidate 16 (07 Sep 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 From 7b179239e41b6e356b5c6e0ceba25b2886a71494 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 7 Oct 2020 16:01:19 +0200 Subject: [PATCH 92/94] [CI skip] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae84aca7e..20b3c4609 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ * Magical Zombie Pills now also work on Zombified Piglins * (API) Added SlimefunGuideOpenEvent * (API) Added "NotConfigurable" attribute to disable configurability +* Added Elytra Cap #### Changes * Improved Auto-Updater (Multi-Threading and more) From 20a9c642fe776771b0c78648ebfcdd8d50f9df4e Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 7 Oct 2020 16:24:14 +0200 Subject: [PATCH 93/94] Some code cleanup --- .github/workflows/auto-approve.yml | 7 ++ .../implementation/SlimefunPlugin.java | 2 +- .../implementation/items/armor/ElytraCap.java | 22 ++++-- .../listeners/ElytraCrashListener.java | 77 +++++++++++-------- .../setup/SlimefunItemSetup.java | 12 +-- .../Objects/SlimefunItem/SlimefunItem.java | 49 +++++++----- 6 files changed, 103 insertions(+), 66 deletions(-) diff --git a/.github/workflows/auto-approve.yml b/.github/workflows/auto-approve.yml index fd145561e..44a48b4df 100644 --- a/.github/workflows/auto-approve.yml +++ b/.github/workflows/auto-approve.yml @@ -20,3 +20,10 @@ jobs: if: github.actor == 'gitlocalize-app[bot]' || github.actor == 'renovate[bot]' with: github-token: "${{ secrets.ACCESS_TOKEN }}" + - name: Add Translations label + uses: maxkomarychev/octions/octions/issues/add-labels@master + if: github.actor == 'gitlocalize-app[bot]' + with: + token: ${{ secrets.ACCESS_TOKEN }} + issue_number: ${{ github.event.pull_request.number }} + labels: 'Translations Update' 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 0a237ef2a..055a3b6ba 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java @@ -63,10 +63,10 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockListener import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockPhysicsListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.CargoNodeListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.CoolerListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.ElytraCrashListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.DeathpointListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.DebugFishListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.DispenserListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.ElytraCrashListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.EnhancedFurnaceListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.EntityInteractionListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.ExplosionsListener; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java index cdeef8ca3..384289e8e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java @@ -1,5 +1,13 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.armor; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + +import org.bukkit.GameMode; +import org.bukkit.NamespacedKey; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType; import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectiveArmor; @@ -8,11 +16,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.ElytraCrashLi import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; -import org.bukkit.NamespacedKey; -import org.bukkit.inventory.ItemStack; - -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; /** * The {@link ElytraCap} negates damage taken when crashing into a wall using an elytra. @@ -37,10 +40,17 @@ public class ElytraCap extends SlimefunArmorPiece implements DamageableItem, Pro return true; } + @Override + public void damageItem(Player p, ItemStack item) { + if (p.getGameMode() != GameMode.CREATIVE) { + DamageableItem.super.damageItem(p, item); + } + } + @Nonnull @Override public ProtectionType[] getProtectionTypes() { - return new ProtectionType[] {ProtectionType.FLYING_INTO_WALL}; + return new ProtectionType[] { ProtectionType.FLYING_INTO_WALL }; } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java index d01992c45..ad5f25c6c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java @@ -1,30 +1,31 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; -import io.github.thebusybiscuit.slimefun4.api.items.HashedArmorpiece; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; -import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType; -import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectiveArmor; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.ElytraCap; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; -import me.mrCookieSlime.Slimefun.api.Slimefun; -import org.bukkit.GameMode; +import java.util.Optional; + +import javax.annotation.Nonnull; + import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.inventory.ItemStack; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import javax.annotation.Nonnull; -import java.util.Arrays; -import java.util.Optional; +import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; +import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.implementation.items.armor.ElytraCap; +import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; +import me.mrCookieSlime.Slimefun.api.Slimefun; /** * The {@link Listener} for the {@link ElytraCap}. * * @author Seggan + * + * @see ElytraCap */ public class ElytraCrashListener implements Listener { @@ -34,27 +35,35 @@ public class ElytraCrashListener implements Listener { @EventHandler public void onPlayerCrash(EntityDamageEvent e) { - if (!(e.getEntity() instanceof Player)) return; - if (!(e.getCause() == EntityDamageEvent.DamageCause.FALL || - e.getCause() == EntityDamageEvent.DamageCause.FLY_INTO_WALL)) return; + if (!(e.getEntity() instanceof Player)) { + // We only wanna handle damaged Players + return; + } - Player p = (Player) e.getEntity(); - if (p.isGliding()) { - Optional optional = PlayerProfile.find(p); - if (!optional.isPresent()) { - PlayerProfile.request(p); - return; - } - PlayerProfile profile = optional.get(); - HashedArmorpiece helmet = profile.getArmor()[0]; - if (helmet.getItem().isPresent()) { - SlimefunItem item = helmet.getItem().get(); - if (Slimefun.hasUnlocked(p, item, true) - && profile.hasFullProtectionAgainst(ProtectionType.FLYING_INTO_WALL)) { - e.setDamage(0); - p.playSound(p.getLocation(), Sound.BLOCK_STONE_HIT, 20, 1); - if (p.getGameMode() != GameMode.CREATIVE && item instanceof DamageableItem) { - ((DamageableItem) item).damageItem(p, p.getInventory().getHelmet()); + if (e.getCause() == DamageCause.FALL || e.getCause() == DamageCause.FLY_INTO_WALL) { + Player p = (Player) e.getEntity(); + + if (p.isGliding()) { + Optional optional = PlayerProfile.find(p); + + if (!optional.isPresent()) { + PlayerProfile.request(p); + return; + } + + PlayerProfile profile = optional.get(); + Optional helmet = profile.getArmor()[0].getItem(); + + if (helmet.isPresent()) { + SlimefunItem item = helmet.get(); + + if (Slimefun.hasUnlocked(p, item, true) && profile.hasFullProtectionAgainst(ProtectionType.FLYING_INTO_WALL)) { + e.setDamage(0); + p.playSound(p.getLocation(), Sound.BLOCK_STONE_HIT, 20, 1); + + if (item instanceof DamageableItem) { + ((DamageableItem) item).damageItem(p, p.getInventory().getHelmet()); + } } } } 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 891c0728a..d6eb244be 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 @@ -33,12 +33,12 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.androids.FisherAn import io.github.thebusybiscuit.slimefun4.implementation.items.androids.MinerAndroid; import io.github.thebusybiscuit.slimefun4.implementation.items.androids.ProgrammableAndroid; import io.github.thebusybiscuit.slimefun4.implementation.items.androids.WoodcutterAndroid; +import io.github.thebusybiscuit.slimefun4.implementation.items.armor.ElytraCap; import io.github.thebusybiscuit.slimefun4.implementation.items.armor.FarmerShoes; import io.github.thebusybiscuit.slimefun4.implementation.items.armor.HazmatArmorPiece; import io.github.thebusybiscuit.slimefun4.implementation.items.armor.Parachute; import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece; import io.github.thebusybiscuit.slimefun4.implementation.items.armor.StomperBoots; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.ElytraCap; import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.Cooler; import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.EnderBackpack; import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.RestoredBackpack; @@ -133,11 +133,11 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.magical.Knowledge import io.github.thebusybiscuit.slimefun4.implementation.items.magical.KnowledgeTome; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.MagicEyeOfEnder; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.MagicalZombiePills; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.VillagerRune; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.SoulboundItem; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.SoulboundRune; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.StormStaff; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.TelepositionScroll; +import io.github.thebusybiscuit.slimefun4.implementation.items.magical.VillagerRune; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.WaterStaff; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.WindStaff; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans.MagicianTalisman; @@ -1118,10 +1118,6 @@ public final class SlimefunItemSetup { new ItemStack[] {SlimefunItems.NICKEL_INGOT, SlimefunItems.ALUMINUM_DUST, SlimefunItems.IRON_DUST, SlimefunItems.COBALT_INGOT, null, null, null, null, null}) .register(plugin); - new ElytraCap(categories.magicalGadgets, SlimefunItems.ELYTRA_CAP, RecipeType.ARMOR_FORGE, - new ItemStack[]{new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.LEATHER_HELMET), new ItemStack(Material.SLIME_BALL)}) - .register(plugin); - new InfusedMagnet(categories.magicalGadgets, SlimefunItems.INFUSED_MAGNET, RecipeType.MAGIC_WORKBENCH, new ItemStack[] {SlimefunItems.MAGIC_LUMP_3, null, SlimefunItems.MAGIC_LUMP_3, SlimefunItems.ENDER_LUMP_2, SlimefunItems.MAGNET, SlimefunItems.ENDER_LUMP_2, SlimefunItems.MAGIC_LUMP_3, null, SlimefunItems.MAGIC_LUMP_3}) .register(plugin); @@ -3078,6 +3074,10 @@ public final class SlimefunItemSetup { new SlimefunItemStack(SlimefunItems.VILLAGER_RUNE, 3)) .register(plugin); } + + new ElytraCap(categories.magicalArmor, SlimefunItems.ELYTRA_CAP, RecipeType.ARMOR_FORGE, + new ItemStack[]{new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.LEATHER_HELMET), new ItemStack(Material.SLIME_BALL)}) + .register(plugin); } private static void registerArmorSet(Category category, ItemStack baseComponent, ItemStack[] items, String idSyntax, boolean vanilla, PotionEffect[][] effects, SlimefunAddon addon) { diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java index ca4f39e17..786f3f137 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java @@ -402,24 +402,7 @@ public class SlimefunItem implements Placeable { // Now we can be certain this item should be enabled if (state == ItemState.ENABLED) { - // Register the Category too if it hasn't been registered yet - if (!category.isRegistered()) { - category.register(); - } - - // Send out deprecation warnings for any classes or intefaces - checkForDeprecations(getClass()); - - // Add it to the list of enabled items - SlimefunPlugin.getRegistry().getEnabledSlimefunItems().add(this); - - // Load our Item Handlers - loadItemHandlers(); - - // Properly mark this Item as radioactive - if (this instanceof Radioactive) { - SlimefunPlugin.getRegistry().getRadioactiveItems().add(this); - } + onEnable(); } // Lock the SlimefunItemStack from any accidental manipulations @@ -440,6 +423,33 @@ public class SlimefunItem implements Placeable { } } + /** + * This method is called when this {@link SlimefunItem} is currently being registered + * and we are certain that it will be enabled. + * + * This method is for internal purposes, like {@link Category} registration only + */ + private final void onEnable() { + // Register the Category too if it hasn't been registered yet + if (!category.isRegistered()) { + category.register(); + } + + // Send out deprecation warnings for any classes or intefaces + checkForDeprecations(getClass()); + + // Add it to the list of enabled items + SlimefunPlugin.getRegistry().getEnabledSlimefunItems().add(this); + + // Load our Item Handlers + loadItemHandlers(); + + // Properly mark this Item as radioactive + if (this instanceof Radioactive) { + SlimefunPlugin.getRegistry().getRadioactiveItems().add(this); + } + } + private void loadItemHandlers() { for (ItemHandler handler : itemhandlers.values()) { Optional exception = handler.validate(this); @@ -451,9 +461,10 @@ public class SlimefunItem implements Placeable { // Make developers or at least Server admins aware that // an Item is using a deprecated ItemHandler checkForDeprecations(handler.getClass()); - // A bit too spammy atm, will enable it again later } + // If this ItemHandler is "public" (not bound to this SlimefunItem), + // we add it to the list of public Item handlers if (!handler.isPrivate()) { Set handlerset = getPublicItemHandlers(handler.getIdentifier()); handlerset.add(handler); From 354cb201c5cd496198e557096f42e134412120e9 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 7 Oct 2020 16:31:33 +0200 Subject: [PATCH 94/94] [CI skip] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20b3c4609..6575e9199 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ * (API) Added SlimefunGuideOpenEvent * (API) Added "NotConfigurable" attribute to disable configurability * Added Elytra Cap +* Added Planks to Sticks recipe to the Table Saw #### Changes * Improved Auto-Updater (Multi-Threading and more)