From f0f134ea72bec2d74e3db9475660a1bc6f8c29c9 Mon Sep 17 00:00:00 2001 From: beSnow Date: Thu, 14 May 2020 22:50:15 +0200 Subject: [PATCH 01/21] Added Bee Armor (and all the things to make it function) --- .../listeners/BeeWingListener.java | 48 +++++++++++++++++++ .../listeners/SlimefunBootsListener.java | 14 ++++-- .../implementation/setup/ResearchSetup.java | 1 + .../setup/SlimefunItemSetup.java | 17 +++++++ .../Slimefun/Lists/SlimefunItems.java | 17 ++++++- .../Slimefun/SlimefunPlugin.java | 33 +------------ 6 files changed, 93 insertions(+), 37 deletions(-) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java new file mode 100644 index 000000000..4b5f6068b --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java @@ -0,0 +1,48 @@ +package io.github.thebusybiscuit.slimefun4.implementation.listeners; + +import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import me.mrCookieSlime.Slimefun.Lists.SlimefunItems; +import me.mrCookieSlime.Slimefun.SlimefunPlugin; +import me.mrCookieSlime.Slimefun.api.Slimefun; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +public class BeeWingListener implements Listener { + + public BeeWingListener(SlimefunPlugin plugin) { + plugin.getServer().getPluginManager().registerEvents(this, plugin); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onApproachGround(PlayerMoveEvent e) { + Player player = e.getPlayer(); + ItemStack helmet = e.getPlayer().getInventory().getChestplate(); + if (!SlimefunUtils.isItemSimilar(helmet, SlimefunItems.BEE_WINGS, true) && !Slimefun.hasUnlocked(e.getPlayer(), helmet, true)) return; + if (!player.isGliding()) return; + if (getDistanceToGround(player) == 0) return; //More accurate than Entity#isOnGround() + + if (getDistanceToGround(player) <= 6) + player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 30, 0)); + } + + private static int getDistanceToGround(Entity e) { + Location loc = e.getLocation().clone(); + double y = loc.getBlockY(); + int distance = 0; + for (double i = y; i >= 0; i--) { + loc.setY(i); + if (loc.getBlock().getType().isSolid()) break; + distance++; + } + return distance; + } +} + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java index 0fdb1e059..b446e5edf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java @@ -4,10 +4,7 @@ import java.util.HashMap; import java.util.Map; import java.util.function.Predicate; -import org.bukkit.Bukkit; -import org.bukkit.Effect; -import org.bukkit.Material; -import org.bukkit.Sound; +import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.EnderPearl; @@ -64,6 +61,15 @@ public class SlimefunBootsListener implements Listener { cancelledEvents.put("SLIME_BOOTS", e -> e.getCause() == DamageCause.FALL); cancelledEvents.put("SLIME_STEEL_BOOTS", e -> e.getCause() == DamageCause.FALL); + + cancelledEvents.put("BEE_BOOTS", e -> { + if (e.getCause() == DamageCause.FALL) { + e.getEntity().getWorld().playSound(e.getEntity().getLocation(), Sound.BLOCK_HONEY_BLOCK_FALL, 1f, 2f); + return true; + } + + return false; + }); } private void stomp(EntityDamageEvent e) { 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 175037c30..3daa66a2f 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 @@ -257,6 +257,7 @@ public final class ResearchSetup { register("kelp_cookie", 254, "Tasty Kelp", 4, SlimefunItems.KELP_COOKIE); register("makeshift_smeltery", 255, "Improvised Smeltery", 6, SlimefunItems.MAKESHIFT_SMELTERY); register("tree_growth_accelerator", 256, "Faster Trees", 18, SlimefunItems.TREE_GROWTH_ACCELERATOR); + register("bee_armor", 257, "Bee Armor", 24, SlimefunItems.BEE_HELMET, SlimefunItems.BEE_WINGS, SlimefunItems.BEE_LEGGINGS, SlimefunItems.BEE_BOOTS); } 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 7a54bcf36..776810b0c 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 @@ -3352,6 +3352,23 @@ public final class SlimefunItemSetup { new WitherAssembler(categories.electricity, SlimefunItems.WITHER_ASSEMBLER, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] {SlimefunItems.BLISTERING_INGOT_3, new ItemStack(Material.NETHER_STAR), SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.ANDROID_MEMORY_CORE, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.REINFORCED_ALLOY_INGOT, SlimefunItems.CARBONADO_EDGED_CAPACITOR}) .register(plugin); + + new SlimefunItem(categories.magicalArmor, SlimefunItems.BEE_HELMET, RecipeType.ARMOR_FORGE, + new ItemStack[]{SlimefunItems.GOLD_8K, new ItemStack(Material.HONEY_BLOCK), SlimefunItems.GOLD_8K, new ItemStack(Material.HONEYCOMB_BLOCK), null, new ItemStack(Material.HONEYCOMB_BLOCK), null, null, null}) + .register(plugin); + + new SlimefunItem(categories.magicalArmor, SlimefunItems.BEE_WINGS, RecipeType.ARMOR_FORGE, + new ItemStack[]{SlimefunItems.GOLD_8K, null, SlimefunItems.GOLD_8K, new ItemStack(Material.HONEYCOMB_BLOCK), new ItemStack(Material.ELYTRA), new ItemStack(Material.HONEYCOMB_BLOCK), new ItemStack(Material.HONEY_BLOCK), SlimefunItems.GOLD_8K, new ItemStack(Material.HONEY_BLOCK)}) + .register(plugin); + + new SlimefunItem(categories.magicalArmor, SlimefunItems.BEE_LEGGINGS, RecipeType.ARMOR_FORGE, + new ItemStack[]{SlimefunItems.GOLD_8K, new ItemStack(Material.HONEY_BLOCK), SlimefunItems.GOLD_8K, new ItemStack(Material.HONEYCOMB_BLOCK), null, new ItemStack(Material.HONEYCOMB_BLOCK), new ItemStack(Material.HONEYCOMB_BLOCK), null, new ItemStack(Material.HONEYCOMB_BLOCK)}) + .register(plugin); + + new SlimefunArmorPiece(categories.magicalArmor, SlimefunItems.BEE_BOOTS, RecipeType.ARMOR_FORGE, + new ItemStack[]{null, null, null, SlimefunItems.GOLD_8K, null, SlimefunItems.GOLD_8K, new ItemStack(Material.HONEY_BLOCK), null, new ItemStack(Material.HONEY_BLOCK)}, + new PotionEffect[]{new PotionEffect(PotionEffectType.JUMP, 300, 2)}) + .register(plugin); } private static void registerArmorSet(Category category, ItemStack baseComponent, ItemStack[] items, String idSyntax, boolean vanilla, SlimefunAddon addon) { diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Lists/SlimefunItems.java b/src/main/java/me/mrCookieSlime/Slimefun/Lists/SlimefunItems.java index 077109586..93780fd07 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Lists/SlimefunItems.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Lists/SlimefunItems.java @@ -26,9 +26,8 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; /** * This class holds a static references to every {@link SlimefunItemStack} * found in Slimefun. - * - * @author TheBusyBiscuit * + * @author TheBusyBiscuit */ public final class SlimefunItems { @@ -267,6 +266,11 @@ public final class SlimefunItems { public static final SlimefunItemStack BOOTS_OF_THE_STOMPER = new SlimefunItemStack("BOOTS_OF_THE_STOMPER", Material.LEATHER_BOOTS, Color.AQUA, "&bBoots of the Stomper", "", "&9All Fall Damage you receive", "&9will be applied to nearby Mobs/Players", "", "&9+ No Fall Damage"); + public static final SlimefunItemStack BEE_HELMET = new SlimefunItemStack("BEE_HELMET", Material.GOLDEN_HELMET, "&e&lBee Helmet", " ", "&e&oNOT THE BEES"); + public static final SlimefunItemStack BEE_WINGS = new SlimefunItemStack("BEE_WINGS", Material.ELYTRA, "&e&lBee Wings", " ", "&e&oFly Like a Bee", " ", "&9Activates Slow falling", "&9When approaching the ground", " "); + public static final SlimefunItemStack BEE_LEGGINGS = new SlimefunItemStack("BEE_LEGGINGS", Material.GOLDEN_LEGGINGS, "&e&lBee Leggings", " ", "&e&oBee like a Bee"); + public static final SlimefunItemStack BEE_BOOTS = new SlimefunItemStack("BEE_BOOTS", Material.GOLDEN_BOOTS, "&e&lBee Boots", "", "&e&oNever have trouble taking off again", "", "&9+ Jump Boost", "&9+ No Fall Damage"); + static { Map cactus = new HashMap<>(); cactus.put(Enchantment.THORNS, 3); @@ -317,6 +321,15 @@ public final class SlimefunItems { SLIME_CHESTPLATE_STEEL.addUnsafeEnchantments(slime); SLIME_LEGGINGS_STEEL.addUnsafeEnchantments(slime); SLIME_BOOTS_STEEL.addUnsafeEnchantments(slime); + + Map bee = new HashMap<>(); + bee.put(Enchantment.DURABILITY, 4); + bee.put(Enchantment.PROTECTION_ENVIRONMENTAL, 2); + + BEE_HELMET.addUnsafeEnchantments(bee); + BEE_WINGS.addUnsafeEnchantments(bee); + BEE_LEGGINGS.addUnsafeEnchantments(bee); + BEE_BOOTS.addUnsafeEnchantments(bee); } /* Misc */ diff --git a/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java b/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java index a93d354ec..d8c3a7f67 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java @@ -9,6 +9,7 @@ import java.util.Set; import java.util.logging.Level; import java.util.stream.Collectors; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.*; import org.bukkit.Bukkit; import org.bukkit.Server; import org.bukkit.World; @@ -48,37 +49,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.food.Cooler; 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.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.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.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.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; @@ -237,6 +207,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { new FireworksListener(this); new WitherListener(this); new IronGolemListener(this); + new BeeWingListener(this); // Item-specific Listeners new VampireBladeListener(this, (VampireBlade) SlimefunItems.BLADE_OF_VAMPIRES.getItem()); From 0d0a4aa578892417efeda3aa1e62597dee8763d8 Mon Sep 17 00:00:00 2001 From: beSnow Date: Thu, 14 May 2020 23:14:27 +0200 Subject: [PATCH 02/21] Fixed some Wildcards (Auto formater messed with it) --- .../listeners/SlimefunBootsListener.java | 5 ++- .../Slimefun/SlimefunPlugin.java | 33 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java index b446e5edf..a0a988ab4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java @@ -4,7 +4,10 @@ import java.util.HashMap; import java.util.Map; import java.util.function.Predicate; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.Effect; +import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.EnderPearl; diff --git a/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java b/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java index d8c3a7f67..ce60476e0 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java @@ -9,7 +9,38 @@ import java.util.Set; import java.util.logging.Level; import java.util.stream.Collectors; -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.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.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.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.WitherListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.WorldListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.BeeWingListener; import org.bukkit.Bukkit; import org.bukkit.Server; import org.bukkit.World; From 865f97d1ba782fff427a6a5ac213210f7bf6f296 Mon Sep 17 00:00:00 2001 From: beSnow Date: Thu, 14 May 2020 23:35:21 +0200 Subject: [PATCH 03/21] Added some documentation --- .../slimefun4/implementation/listeners/BeeWingListener.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java index 4b5f6068b..e89165bf6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java @@ -15,6 +15,12 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +/** + * This {@link Listener} is responsible for the slow falling effect given to the player + * When Nearing the ground. + * + * @author beSnow + */ public class BeeWingListener implements Listener { public BeeWingListener(SlimefunPlugin plugin) { From d88c81500525bf4f146a5d1723bd15b4fae3d28b Mon Sep 17 00:00:00 2001 From: beSnow Date: Fri, 15 May 2020 11:22:22 +0200 Subject: [PATCH 04/21] Fixed Mincraft Version Compatibility and some IDE weirdness --- .../setup/SlimefunItemSetup.java | 28 +++++---- .../Slimefun/Lists/SlimefunItems.java | 41 ++++++++---- .../Slimefun/SlimefunPlugin.java | 62 +++++-------------- 3 files changed, 60 insertions(+), 71 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 776810b0c..498444e5c 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 @@ -3353,22 +3353,24 @@ public final class SlimefunItemSetup { new ItemStack[] {SlimefunItems.BLISTERING_INGOT_3, new ItemStack(Material.NETHER_STAR), SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.ANDROID_MEMORY_CORE, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.REINFORCED_ALLOY_INGOT, SlimefunItems.CARBONADO_EDGED_CAPACITOR}) .register(plugin); - new SlimefunItem(categories.magicalArmor, SlimefunItems.BEE_HELMET, RecipeType.ARMOR_FORGE, - new ItemStack[]{SlimefunItems.GOLD_8K, new ItemStack(Material.HONEY_BLOCK), SlimefunItems.GOLD_8K, new ItemStack(Material.HONEYCOMB_BLOCK), null, new ItemStack(Material.HONEYCOMB_BLOCK), null, null, null}) - .register(plugin); + if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_15)) { + new SlimefunItem(categories.magicalArmor, SlimefunItems.BEE_HELMET, RecipeType.ARMOR_FORGE, + new ItemStack[]{SlimefunItems.GOLD_8K, new ItemStack(Material.HONEY_BLOCK), SlimefunItems.GOLD_8K, new ItemStack(Material.HONEYCOMB_BLOCK), null, new ItemStack(Material.HONEYCOMB_BLOCK), null, null, null}) + .register(plugin); - new SlimefunItem(categories.magicalArmor, SlimefunItems.BEE_WINGS, RecipeType.ARMOR_FORGE, - new ItemStack[]{SlimefunItems.GOLD_8K, null, SlimefunItems.GOLD_8K, new ItemStack(Material.HONEYCOMB_BLOCK), new ItemStack(Material.ELYTRA), new ItemStack(Material.HONEYCOMB_BLOCK), new ItemStack(Material.HONEY_BLOCK), SlimefunItems.GOLD_8K, new ItemStack(Material.HONEY_BLOCK)}) - .register(plugin); + new SlimefunItem(categories.magicalArmor, SlimefunItems.BEE_WINGS, RecipeType.ARMOR_FORGE, + new ItemStack[]{SlimefunItems.GOLD_8K, null, SlimefunItems.GOLD_8K, new ItemStack(Material.HONEYCOMB_BLOCK), new ItemStack(Material.ELYTRA), new ItemStack(Material.HONEYCOMB_BLOCK), new ItemStack(Material.HONEY_BLOCK), SlimefunItems.GOLD_8K, new ItemStack(Material.HONEY_BLOCK)}) + .register(plugin); - new SlimefunItem(categories.magicalArmor, SlimefunItems.BEE_LEGGINGS, RecipeType.ARMOR_FORGE, - new ItemStack[]{SlimefunItems.GOLD_8K, new ItemStack(Material.HONEY_BLOCK), SlimefunItems.GOLD_8K, new ItemStack(Material.HONEYCOMB_BLOCK), null, new ItemStack(Material.HONEYCOMB_BLOCK), new ItemStack(Material.HONEYCOMB_BLOCK), null, new ItemStack(Material.HONEYCOMB_BLOCK)}) - .register(plugin); + new SlimefunItem(categories.magicalArmor, SlimefunItems.BEE_LEGGINGS, RecipeType.ARMOR_FORGE, + new ItemStack[]{SlimefunItems.GOLD_8K, new ItemStack(Material.HONEY_BLOCK), SlimefunItems.GOLD_8K, new ItemStack(Material.HONEYCOMB_BLOCK), null, new ItemStack(Material.HONEYCOMB_BLOCK), new ItemStack(Material.HONEYCOMB_BLOCK), null, new ItemStack(Material.HONEYCOMB_BLOCK)}) + .register(plugin); - new SlimefunArmorPiece(categories.magicalArmor, SlimefunItems.BEE_BOOTS, RecipeType.ARMOR_FORGE, - new ItemStack[]{null, null, null, SlimefunItems.GOLD_8K, null, SlimefunItems.GOLD_8K, new ItemStack(Material.HONEY_BLOCK), null, new ItemStack(Material.HONEY_BLOCK)}, - new PotionEffect[]{new PotionEffect(PotionEffectType.JUMP, 300, 2)}) - .register(plugin); + new SlimefunArmorPiece(categories.magicalArmor, SlimefunItems.BEE_BOOTS, RecipeType.ARMOR_FORGE, + new ItemStack[]{null, null, null, SlimefunItems.GOLD_8K, null, SlimefunItems.GOLD_8K, new ItemStack(Material.HONEY_BLOCK), null, new ItemStack(Material.HONEY_BLOCK)}, + new PotionEffect[]{new PotionEffect(PotionEffectType.JUMP, 300, 2)}) + .register(plugin); + } } private static void registerArmorSet(Category category, ItemStack baseComponent, ItemStack[] items, String idSyntax, boolean vanilla, SlimefunAddon addon) { diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Lists/SlimefunItems.java b/src/main/java/me/mrCookieSlime/Slimefun/Lists/SlimefunItems.java index 93780fd07..970f396cc 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Lists/SlimefunItems.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Lists/SlimefunItems.java @@ -266,11 +266,35 @@ public final class SlimefunItems { public static final SlimefunItemStack BOOTS_OF_THE_STOMPER = new SlimefunItemStack("BOOTS_OF_THE_STOMPER", Material.LEATHER_BOOTS, Color.AQUA, "&bBoots of the Stomper", "", "&9All Fall Damage you receive", "&9will be applied to nearby Mobs/Players", "", "&9+ No Fall Damage"); - public static final SlimefunItemStack BEE_HELMET = new SlimefunItemStack("BEE_HELMET", Material.GOLDEN_HELMET, "&e&lBee Helmet", " ", "&e&oNOT THE BEES"); - public static final SlimefunItemStack BEE_WINGS = new SlimefunItemStack("BEE_WINGS", Material.ELYTRA, "&e&lBee Wings", " ", "&e&oFly Like a Bee", " ", "&9Activates Slow falling", "&9When approaching the ground", " "); - public static final SlimefunItemStack BEE_LEGGINGS = new SlimefunItemStack("BEE_LEGGINGS", Material.GOLDEN_LEGGINGS, "&e&lBee Leggings", " ", "&e&oBee like a Bee"); - public static final SlimefunItemStack BEE_BOOTS = new SlimefunItemStack("BEE_BOOTS", Material.GOLDEN_BOOTS, "&e&lBee Boots", "", "&e&oNever have trouble taking off again", "", "&9+ Jump Boost", "&9+ No Fall Damage"); + public static final SlimefunItemStack BEE_HELMET; + public static final SlimefunItemStack BEE_WINGS; + public static final SlimefunItemStack BEE_LEGGINGS; + public static final SlimefunItemStack BEE_BOOTS; +static { + + if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_15)) { + BEE_HELMET = new SlimefunItemStack("BEE_HELMET", Material.GOLDEN_HELMET, "&e&lBee Helmet", " ", "&e&oNOT THE BEES"); + BEE_WINGS = new SlimefunItemStack("BEE_WINGS", Material.ELYTRA, "&e&lBee Wings", " ", "&e&oFly Like a Bee", " ", "&9Activates Slow falling", "&9When approaching the ground", " "); + BEE_LEGGINGS = new SlimefunItemStack("BEE_LEGGINGS", Material.GOLDEN_LEGGINGS, "&e&lBee Leggings", " ", "&e&oBee like a Bee"); + BEE_BOOTS = new SlimefunItemStack("BEE_BOOTS", Material.GOLDEN_BOOTS, "&e&lBee Boots", "", "&e&oNever have trouble taking off again", "", "&9+ Jump Boost", "&9+ No Fall Damage"); + + Map bee = new HashMap<>(); + bee.put(Enchantment.DURABILITY, 4); + bee.put(Enchantment.PROTECTION_ENVIRONMENTAL, 2); + + BEE_HELMET.addUnsafeEnchantments(bee); + BEE_WINGS.addUnsafeEnchantments(bee); + BEE_LEGGINGS.addUnsafeEnchantments(bee); + BEE_BOOTS.addUnsafeEnchantments(bee); + } + else { + BEE_HELMET = null; + BEE_WINGS = null; + BEE_LEGGINGS = null; + BEE_BOOTS = null; + } +} static { Map cactus = new HashMap<>(); cactus.put(Enchantment.THORNS, 3); @@ -321,15 +345,6 @@ public final class SlimefunItems { SLIME_CHESTPLATE_STEEL.addUnsafeEnchantments(slime); SLIME_LEGGINGS_STEEL.addUnsafeEnchantments(slime); SLIME_BOOTS_STEEL.addUnsafeEnchantments(slime); - - Map bee = new HashMap<>(); - bee.put(Enchantment.DURABILITY, 4); - bee.put(Enchantment.PROTECTION_ENVIRONMENTAL, 2); - - BEE_HELMET.addUnsafeEnchantments(bee); - BEE_WINGS.addUnsafeEnchantments(bee); - BEE_LEGGINGS.addUnsafeEnchantments(bee); - BEE_BOOTS.addUnsafeEnchantments(bee); } /* Misc */ diff --git a/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java b/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java index ce60476e0..ca456eff8 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java @@ -9,38 +9,7 @@ import java.util.Set; import java.util.logging.Level; import java.util.stream.Collectors; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.AncientAltarListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.BackpackListener; -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.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.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.WitherListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.WorldListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.BeeWingListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.*; import org.bukkit.Bukkit; import org.bukkit.Server; import org.bukkit.World; @@ -100,7 +69,7 @@ import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu; * This is the main class of Slimefun. * This is where all the magic starts, take a look around. * Feel like home. - * + * * @author TheBusyBiscuit * */ @@ -200,8 +169,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { if (config.getBoolean("options.auto-update")) { getLogger().log(Level.INFO, "Starting Auto-Updater..."); updaterService.start(); - } - else { + } else { updaterService.disable(); } @@ -238,7 +206,6 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { new FireworksListener(this); new WitherListener(this); new IronGolemListener(this); - new BeeWingListener(this); // Item-specific Listeners new VampireBladeListener(this, (VampireBlade) SlimefunItems.BLADE_OF_VAMPIRES.getItem()); @@ -271,6 +238,11 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { // Clear the Slimefun Guide History upon Player Leaving new PlayerProfileListener(this); + // Listeners that only need to function in at least Minecraft version 1.15.X + if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_15)) { + new BeeWingListener(this); + } + // Initiating various Stuff and all Items with a slightly delay (0ms after the Server finished loading) Slimefun.runSync(new SlimefunStartupTask(this, () -> { protections = new ProtectionManager(getServer()); @@ -325,7 +297,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { /** * This method checks for the {@link MinecraftVersion} of the {@link Server}. * If the version is unsupported, a warning will be printed to the console. - * + * * @return Whether the {@link MinecraftVersion} is unsupported */ private boolean isVersionUnsupported() { @@ -488,7 +460,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { /** * This returns the version of Slimefun that is currently installed. - * + * * @return The currently installed version of Slimefun */ public static String getVersion() { @@ -501,7 +473,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { /** * This returns the {@link LocalizationService} of Slimefun. - * + * * @return The {@link LocalizationService} of Slimefun */ public static LocalizationService getLocal() { @@ -539,7 +511,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { /** * This method returns the {@link UpdaterService} of Slimefun. * It is used to handle automatic updates. - * + * * @return The {@link UpdaterService} for Slimefun */ public static UpdaterService getUpdater() { @@ -549,7 +521,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { /** * This method returns the {@link GitHubService} of Slimefun. * It is used to retrieve data from GitHub repositories. - * + * * @return The {@link GitHubService} for Slimefun */ public static GitHubService getGitHubService() { @@ -583,9 +555,9 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { /** * This method returns a {@link Set} of every {@link Plugin} that lists Slimefun * as a required or optional dependency. - * + * * We will just assume this to be a list of our addons. - * + * * @return A {@link Set} of every {@link Plugin} that is dependent on Slimefun */ public static Set getInstalledAddons() { @@ -594,7 +566,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { /** * The {@link Command} that was added by Slimefun. - * + * * @return Slimefun's command */ public static SlimefunCommand getCommand() { @@ -603,7 +575,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { /** * This returns the currently installed version of Minecraft. - * + * * @return The current version of Minecraft */ public static MinecraftVersion getMinecraftVersion() { From f0dbe746c6caf476401f2b657f70789dc1dfb0b7 Mon Sep 17 00:00:00 2001 From: beSnow Date: Fri, 15 May 2020 17:51:08 +0200 Subject: [PATCH 05/21] Fixed the Wildcard --- .../Slimefun/SlimefunPlugin.java | 39 ++++++++++++++++--- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java b/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java index ca456eff8..b42c6e246 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java @@ -9,7 +9,6 @@ import java.util.Set; import java.util.logging.Level; import java.util.stream.Collectors; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.*; import org.bukkit.Bukkit; import org.bukkit.Server; import org.bukkit.World; @@ -49,6 +48,38 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.food.Cooler; 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.BeeWingListener; +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.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.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.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; @@ -206,6 +237,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { new FireworksListener(this); new WitherListener(this); new IronGolemListener(this); + new BeeWingListener(this); // Item-specific Listeners new VampireBladeListener(this, (VampireBlade) SlimefunItems.BLADE_OF_VAMPIRES.getItem()); @@ -238,11 +270,6 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { // Clear the Slimefun Guide History upon Player Leaving new PlayerProfileListener(this); - // Listeners that only need to function in at least Minecraft version 1.15.X - if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_15)) { - new BeeWingListener(this); - } - // Initiating various Stuff and all Items with a slightly delay (0ms after the Server finished loading) Slimefun.runSync(new SlimefunStartupTask(this, () -> { protections = new ProtectionManager(getServer()); From ba886d275d9ff3ed964e1e2a3e0dcde197fba5dc Mon Sep 17 00:00:00 2001 From: beSnow Date: Fri, 15 May 2020 18:01:40 +0200 Subject: [PATCH 06/21] Added the research text to the researches_en Language file --- src/main/resources/languages/researches_en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/languages/researches_en.yml b/src/main/resources/languages/researches_en.yml index 47c20ddcf..c535bb6a9 100644 --- a/src/main/resources/languages/researches_en.yml +++ b/src/main/resources/languages/researches_en.yml @@ -230,4 +230,4 @@ slimefun: magnesium_generator: Power from Magnesium kelp_cookie: Tasty Kelp makeshift_smeltery: Improvised Smeltery - tree_growth_accelerator: Faster Trees + tree_growth_accelerator: Faster Trees \ No newline at end of file From 6311f6ec2e4975d9583f8697db763ca819836020 Mon Sep 17 00:00:00 2001 From: beSnow Date: Fri, 15 May 2020 18:18:07 +0200 Subject: [PATCH 07/21] Fixed some redundancies --- .../Slimefun/Lists/SlimefunItems.java | 41 ++++++------------- .../Slimefun/SlimefunPlugin.java | 6 ++- 2 files changed, 18 insertions(+), 29 deletions(-) diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Lists/SlimefunItems.java b/src/main/java/me/mrCookieSlime/Slimefun/Lists/SlimefunItems.java index 970f396cc..93780fd07 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Lists/SlimefunItems.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Lists/SlimefunItems.java @@ -266,35 +266,11 @@ public final class SlimefunItems { public static final SlimefunItemStack BOOTS_OF_THE_STOMPER = new SlimefunItemStack("BOOTS_OF_THE_STOMPER", Material.LEATHER_BOOTS, Color.AQUA, "&bBoots of the Stomper", "", "&9All Fall Damage you receive", "&9will be applied to nearby Mobs/Players", "", "&9+ No Fall Damage"); - public static final SlimefunItemStack BEE_HELMET; - public static final SlimefunItemStack BEE_WINGS; - public static final SlimefunItemStack BEE_LEGGINGS; - public static final SlimefunItemStack BEE_BOOTS; + public static final SlimefunItemStack BEE_HELMET = new SlimefunItemStack("BEE_HELMET", Material.GOLDEN_HELMET, "&e&lBee Helmet", " ", "&e&oNOT THE BEES"); + public static final SlimefunItemStack BEE_WINGS = new SlimefunItemStack("BEE_WINGS", Material.ELYTRA, "&e&lBee Wings", " ", "&e&oFly Like a Bee", " ", "&9Activates Slow falling", "&9When approaching the ground", " "); + public static final SlimefunItemStack BEE_LEGGINGS = new SlimefunItemStack("BEE_LEGGINGS", Material.GOLDEN_LEGGINGS, "&e&lBee Leggings", " ", "&e&oBee like a Bee"); + public static final SlimefunItemStack BEE_BOOTS = new SlimefunItemStack("BEE_BOOTS", Material.GOLDEN_BOOTS, "&e&lBee Boots", "", "&e&oNever have trouble taking off again", "", "&9+ Jump Boost", "&9+ No Fall Damage"); -static { - - if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_15)) { - BEE_HELMET = new SlimefunItemStack("BEE_HELMET", Material.GOLDEN_HELMET, "&e&lBee Helmet", " ", "&e&oNOT THE BEES"); - BEE_WINGS = new SlimefunItemStack("BEE_WINGS", Material.ELYTRA, "&e&lBee Wings", " ", "&e&oFly Like a Bee", " ", "&9Activates Slow falling", "&9When approaching the ground", " "); - BEE_LEGGINGS = new SlimefunItemStack("BEE_LEGGINGS", Material.GOLDEN_LEGGINGS, "&e&lBee Leggings", " ", "&e&oBee like a Bee"); - BEE_BOOTS = new SlimefunItemStack("BEE_BOOTS", Material.GOLDEN_BOOTS, "&e&lBee Boots", "", "&e&oNever have trouble taking off again", "", "&9+ Jump Boost", "&9+ No Fall Damage"); - - Map bee = new HashMap<>(); - bee.put(Enchantment.DURABILITY, 4); - bee.put(Enchantment.PROTECTION_ENVIRONMENTAL, 2); - - BEE_HELMET.addUnsafeEnchantments(bee); - BEE_WINGS.addUnsafeEnchantments(bee); - BEE_LEGGINGS.addUnsafeEnchantments(bee); - BEE_BOOTS.addUnsafeEnchantments(bee); - } - else { - BEE_HELMET = null; - BEE_WINGS = null; - BEE_LEGGINGS = null; - BEE_BOOTS = null; - } -} static { Map cactus = new HashMap<>(); cactus.put(Enchantment.THORNS, 3); @@ -345,6 +321,15 @@ static { SLIME_CHESTPLATE_STEEL.addUnsafeEnchantments(slime); SLIME_LEGGINGS_STEEL.addUnsafeEnchantments(slime); SLIME_BOOTS_STEEL.addUnsafeEnchantments(slime); + + Map bee = new HashMap<>(); + bee.put(Enchantment.DURABILITY, 4); + bee.put(Enchantment.PROTECTION_ENVIRONMENTAL, 2); + + BEE_HELMET.addUnsafeEnchantments(bee); + BEE_WINGS.addUnsafeEnchantments(bee); + BEE_LEGGINGS.addUnsafeEnchantments(bee); + BEE_BOOTS.addUnsafeEnchantments(bee); } /* Misc */ diff --git a/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java b/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java index b42c6e246..624b5f564 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java @@ -237,7 +237,6 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { new FireworksListener(this); new WitherListener(this); new IronGolemListener(this); - new BeeWingListener(this); // Item-specific Listeners new VampireBladeListener(this, (VampireBlade) SlimefunItems.BLADE_OF_VAMPIRES.getItem()); @@ -270,6 +269,11 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { // Clear the Slimefun Guide History upon Player Leaving new PlayerProfileListener(this); + // Listeners that only need to function in at least Minecraft version 1.15.X + if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_15)) { + new BeeWingListener(this); + } + // Initiating various Stuff and all Items with a slightly delay (0ms after the Server finished loading) Slimefun.runSync(new SlimefunStartupTask(this, () -> { protections = new ProtectionManager(getServer()); From 84bce963b9b8480d0657fd8e75fad93c0d3eedbc Mon Sep 17 00:00:00 2001 From: beSnow Date: Fri, 15 May 2020 23:49:59 +0200 Subject: [PATCH 08/21] Added Bee Armor to researches_en. --- src/main/resources/languages/researches_en.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/resources/languages/researches_en.yml b/src/main/resources/languages/researches_en.yml index c535bb6a9..5c5ea9cc4 100644 --- a/src/main/resources/languages/researches_en.yml +++ b/src/main/resources/languages/researches_en.yml @@ -230,4 +230,5 @@ slimefun: magnesium_generator: Power from Magnesium kelp_cookie: Tasty Kelp makeshift_smeltery: Improvised Smeltery - tree_growth_accelerator: Faster Trees \ No newline at end of file + tree_growth_accelerator: Faster Trees + bee_armor: Bee Armor \ No newline at end of file From 733599691a29c5dab8bbb6bfff582d8099c05fe4 Mon Sep 17 00:00:00 2001 From: beSnow Date: Fri, 15 May 2020 23:50:41 +0200 Subject: [PATCH 09/21] Changed some stuff in BeeWingListener, Should be more performance friendly now. --- .../listeners/BeeWingListener.java | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java index e89165bf6..7f1e014ad 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java @@ -4,6 +4,7 @@ import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import me.mrCookieSlime.Slimefun.Lists.SlimefunItems; import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.api.Slimefun; +import org.bukkit.HeightMap; import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -17,7 +18,7 @@ import org.bukkit.potion.PotionEffectType; /** * This {@link Listener} is responsible for the slow falling effect given to the player - * When Nearing the ground. + * When Nearing the ground when using the Bee Wings. * * @author beSnow */ @@ -27,16 +28,27 @@ public class BeeWingListener implements Listener { plugin.getServer().getPluginManager().registerEvents(this, plugin); } - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + @EventHandler(priority = EventPriority.LOWEST) public void onApproachGround(PlayerMoveEvent e) { Player player = e.getPlayer(); - ItemStack helmet = e.getPlayer().getInventory().getChestplate(); - if (!SlimefunUtils.isItemSimilar(helmet, SlimefunItems.BEE_WINGS, true) && !Slimefun.hasUnlocked(e.getPlayer(), helmet, true)) return; if (!player.isGliding()) return; - if (getDistanceToGround(player) == 0) return; //More accurate than Entity#isOnGround() + if (player.isOnGround()) return; + ItemStack helmet = player.getInventory().getChestplate(); + if (!SlimefunUtils.isItemSimilar(helmet, SlimefunItems.BEE_WINGS, true) && !Slimefun.hasUnlocked(player, helmet, true)) + return; - if (getDistanceToGround(player) <= 6) - player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 30, 0)); + double playerDistanceToHighestBlock = (player.getLocation().getY() - player.getWorld().getHighestBlockYAt(player.getLocation(), HeightMap.WORLD_SURFACE)); + + // getDistanceToGround will only fire when playerDistanceToHighestBlock is negative (which happens when a player is flying under an existing structure) + if (playerDistanceToHighestBlock < 0) { + if (getDistanceToGround(player) > 6) return; + player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 40, 0)); + return; + } + + if (playerDistanceToHighestBlock <= 6) { + player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 40, 0)); + } } private static int getDistanceToGround(Entity e) { @@ -50,5 +62,4 @@ public class BeeWingListener implements Listener { } return distance; } -} - +} \ No newline at end of file From 5112fd25fa2d2fcfade69178de9152573c5aadc1 Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Sat, 12 Sep 2020 13:02:12 +0200 Subject: [PATCH 10/21] Fixed merge conflicts --- .../slimefun4/implementation/SlimefunItems.java | 14 ++++++++++++++ .../implementation/listeners/BeeWingListener.java | 4 ++-- .../listeners/SlimefunBootsListener.java | 11 ++++++----- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java index 9ddcea567..433346fde 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -300,6 +300,11 @@ public final class SlimefunItems { public static final SlimefunItemStack BOOTS_OF_THE_STOMPER = new SlimefunItemStack("BOOTS_OF_THE_STOMPER", Material.LEATHER_BOOTS, Color.AQUA, "&bBoots of the Stomper", "", "&9All Fall Damage you receive", "&9will be applied to nearby Mobs/Players", "", "&9+ No Fall Damage"); + public static final SlimefunItemStack BEE_HELMET = new SlimefunItemStack("BEE_HELMET", Material.GOLDEN_HELMET, "&e&lBee Helmet", " ", "&e&oNOT THE BEES"); + public static final SlimefunItemStack BEE_WINGS = new SlimefunItemStack("BEE_WINGS", Material.ELYTRA, "&e&lBee Wings", " ", "&e&oFly Like a Bee", " ", "&9Activates Slow falling", "&9When approaching the ground", " "); + public static final SlimefunItemStack BEE_LEGGINGS = new SlimefunItemStack("BEE_LEGGINGS", Material.GOLDEN_LEGGINGS, "&e&lBee Leggings", " ", "&e&oBee like a Bee"); + public static final SlimefunItemStack BEE_BOOTS = new SlimefunItemStack("BEE_BOOTS", Material.GOLDEN_BOOTS, "&e&lBee Boots", "", "&e&oNever have trouble taking off again", "", "&9+ Jump Boost", "&9+ No Fall Damage"); + static { Map cactus = new HashMap<>(); cactus.put(Enchantment.THORNS, 3); @@ -350,6 +355,15 @@ public final class SlimefunItems { SLIME_CHESTPLATE_STEEL.addUnsafeEnchantments(slime); SLIME_LEGGINGS_STEEL.addUnsafeEnchantments(slime); SLIME_BOOTS_STEEL.addUnsafeEnchantments(slime); + + Map bee = new HashMap<>(); + bee.put(Enchantment.DURABILITY, 4); + bee.put(Enchantment.PROTECTION_ENVIRONMENTAL, 2); + + BEE_HELMET.addUnsafeEnchantments(bee); + BEE_WINGS.addUnsafeEnchantments(bee); + BEE_LEGGINGS.addUnsafeEnchantments(bee); + BEE_BOOTS.addUnsafeEnchantments(bee); } /* Magical components */ diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java index 7f1e014ad..2a6afb61f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java @@ -1,8 +1,8 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; -import me.mrCookieSlime.Slimefun.Lists.SlimefunItems; -import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.api.Slimefun; import org.bukkit.HeightMap; import org.bukkit.Location; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java index 2ec7f83b9..95af432e5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java @@ -3,6 +3,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; import javax.annotation.Nonnull; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.entity.EnderPearl; import org.bukkit.entity.Player; @@ -67,11 +68,11 @@ public class SlimefunBootsListener implements Listener { e.setCancelled(true); ((StomperBoots) boots).stomp(e); } - else if (boots.getID().equals("SLIME_BOOTS") || boots.getID().equals("SLIME_STEEL_BOOTS") || boots.getID().equals("BEE_BOOTS")) { - if (boots.getID().equals("BEE_BOOTS")) { - e.getEntity().getWorld().playSound(e.getEntity().getLocation(), Sound.BLOCK_HONEY_BLOCK_FALL, 1f, 2f); - } - + else if (boots.getID().equals("BEE_BOOTS")) { + e.setCancelled(true); + e.getEntity().getWorld().playSound(e.getEntity().getLocation(), Sound.BLOCK_HONEY_BLOCK_FALL, 1f, 2f); + } + else if (boots.getID().equals("SLIME_BOOTS") || boots.getID().equals("SLIME_STEEL_BOOTS")) { e.setCancelled(true); } } From 35e0d44b0b93b1d643c949bd2b42ab9cadeb12ca Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sat, 12 Sep 2020 17:21:03 +0300 Subject: [PATCH 11/21] Some refactoring and added a material check. --- .../listeners/BeeWingListener.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java index 2a6afb61f..be374d3dd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java @@ -1,9 +1,5 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; -import me.mrCookieSlime.Slimefun.api.Slimefun; import org.bukkit.HeightMap; import org.bukkit.Location; import org.bukkit.entity.Entity; @@ -16,11 +12,17 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import me.mrCookieSlime.Slimefun.api.Slimefun; + /** * This {@link Listener} is responsible for the slow falling effect given to the player - * When Nearing the ground when using the Bee Wings. + * when nearing the ground while using the Bee Wings. * * @author beSnow + * */ public class BeeWingListener implements Listener { @@ -31,11 +33,16 @@ public class BeeWingListener implements Listener { @EventHandler(priority = EventPriority.LOWEST) public void onApproachGround(PlayerMoveEvent e) { Player player = e.getPlayer(); + if (!player.isGliding()) return; if (player.isOnGround()) return; - ItemStack helmet = player.getInventory().getChestplate(); - if (!SlimefunUtils.isItemSimilar(helmet, SlimefunItems.BEE_WINGS, true) && !Slimefun.hasUnlocked(player, helmet, true)) + + ItemStack chestplate = player.getInventory().getChestplate(); + if (chestplate.getType() != Material.ELYTRA) return; + + if (!SlimefunUtils.isItemSimilar(chestplate, SlimefunItems.BEE_WINGS, true) && !Slimefun.hasUnlocked(player, chestplate, true)) { return; + } double playerDistanceToHighestBlock = (player.getLocation().getY() - player.getWorld().getHighestBlockYAt(player.getLocation(), HeightMap.WORLD_SURFACE)); @@ -62,4 +69,4 @@ public class BeeWingListener implements Listener { } return distance; } -} \ No newline at end of file +} From cff18a32df5aee7fccf42214ba335aa75b352d06 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sat, 12 Sep 2020 17:34:32 +0300 Subject: [PATCH 12/21] Fixed missing import. --- .../slimefun4/implementation/listeners/BeeWingListener.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java index be374d3dd..a8413ee62 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java @@ -2,6 +2,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; import org.bukkit.HeightMap; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; From 8a91cdbfc2947c3b7a99977fe73326ca2ade59f8 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sun, 13 Sep 2020 23:32:32 +0300 Subject: [PATCH 13/21] Code formatting. --- .../slimefun4/implementation/SlimefunPlugin.java | 3 ++- 1 file changed, 2 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 3d0f53504..44e679c62 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java @@ -220,7 +220,8 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { if (config.getBoolean("options.auto-update")) { getLogger().log(Level.INFO, "Starting Auto-Updater..."); updaterService.start(); - } else { + } + else { updaterService.disable(); } From 4414b3f29b074e7ca4a039e0ccd1450a448e187a Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sun, 13 Sep 2020 23:35:14 +0300 Subject: [PATCH 14/21] Fixed indentation. --- .../setup/SlimefunItemSetup.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 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 56e2096e3..ffce5bffe 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 @@ -3055,23 +3055,23 @@ public final class SlimefunItemSetup { } if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_15)) { - new SlimefunItem(categories.magicalArmor, SlimefunItems.BEE_HELMET, RecipeType.ARMOR_FORGE, - new ItemStack[]{SlimefunItems.GOLD_8K, new ItemStack(Material.HONEY_BLOCK), SlimefunItems.GOLD_8K, new ItemStack(Material.HONEYCOMB_BLOCK), null, new ItemStack(Material.HONEYCOMB_BLOCK), null, null, null}) - .register(plugin); + new SlimefunItem(categories.magicalArmor, SlimefunItems.BEE_HELMET, RecipeType.ARMOR_FORGE, + new ItemStack[]{SlimefunItems.GOLD_8K, new ItemStack(Material.HONEY_BLOCK), SlimefunItems.GOLD_8K, new ItemStack(Material.HONEYCOMB_BLOCK), null, new ItemStack(Material.HONEYCOMB_BLOCK), null, null, null}) + .register(plugin); - new SlimefunItem(categories.magicalArmor, SlimefunItems.BEE_WINGS, RecipeType.ARMOR_FORGE, - new ItemStack[]{SlimefunItems.GOLD_8K, null, SlimefunItems.GOLD_8K, new ItemStack(Material.HONEYCOMB_BLOCK), new ItemStack(Material.ELYTRA), new ItemStack(Material.HONEYCOMB_BLOCK), new ItemStack(Material.HONEY_BLOCK), SlimefunItems.GOLD_8K, new ItemStack(Material.HONEY_BLOCK)}) - .register(plugin); + new SlimefunItem(categories.magicalArmor, SlimefunItems.BEE_WINGS, RecipeType.ARMOR_FORGE, + new ItemStack[]{SlimefunItems.GOLD_8K, null, SlimefunItems.GOLD_8K, new ItemStack(Material.HONEYCOMB_BLOCK), new ItemStack(Material.ELYTRA), new ItemStack(Material.HONEYCOMB_BLOCK), new ItemStack(Material.HONEY_BLOCK), SlimefunItems.GOLD_8K, new ItemStack(Material.HONEY_BLOCK)}) + .register(plugin); - new SlimefunItem(categories.magicalArmor, SlimefunItems.BEE_LEGGINGS, RecipeType.ARMOR_FORGE, - new ItemStack[]{SlimefunItems.GOLD_8K, new ItemStack(Material.HONEY_BLOCK), SlimefunItems.GOLD_8K, new ItemStack(Material.HONEYCOMB_BLOCK), null, new ItemStack(Material.HONEYCOMB_BLOCK), new ItemStack(Material.HONEYCOMB_BLOCK), null, new ItemStack(Material.HONEYCOMB_BLOCK)}) - .register(plugin); + new SlimefunItem(categories.magicalArmor, SlimefunItems.BEE_LEGGINGS, RecipeType.ARMOR_FORGE, + new ItemStack[]{SlimefunItems.GOLD_8K, new ItemStack(Material.HONEY_BLOCK), SlimefunItems.GOLD_8K, new ItemStack(Material.HONEYCOMB_BLOCK), null, new ItemStack(Material.HONEYCOMB_BLOCK), new ItemStack(Material.HONEYCOMB_BLOCK), null, new ItemStack(Material.HONEYCOMB_BLOCK)}) + .register(plugin); - new SlimefunArmorPiece(categories.magicalArmor, SlimefunItems.BEE_BOOTS, RecipeType.ARMOR_FORGE, - new ItemStack[]{null, null, null, SlimefunItems.GOLD_8K, null, SlimefunItems.GOLD_8K, new ItemStack(Material.HONEY_BLOCK), null, new ItemStack(Material.HONEY_BLOCK)}, - new PotionEffect[]{new PotionEffect(PotionEffectType.JUMP, 300, 2)}) - .register(plugin); - } + new SlimefunArmorPiece(categories.magicalArmor, SlimefunItems.BEE_BOOTS, RecipeType.ARMOR_FORGE, + new ItemStack[]{null, null, null, SlimefunItems.GOLD_8K, null, SlimefunItems.GOLD_8K, new ItemStack(Material.HONEY_BLOCK), null, new ItemStack(Material.HONEY_BLOCK)}, + new PotionEffect[]{new PotionEffect(PotionEffectType.JUMP, 300, 2)}) + .register(plugin); + } if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) { new StrangeNetherGoo(categories.magicalResources, SlimefunItems.STRANGE_NETHER_GOO, RecipeType.BARTER_DROP, From 2c0c298dfc0113c75e42daa8eebf88e3f95b52dd Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sun, 13 Sep 2020 23:36:20 +0300 Subject: [PATCH 15/21] Did a requested change. --- .../slimefun4/implementation/listeners/BeeWingListener.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java index a8413ee62..cf36ec47f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java @@ -2,7 +2,6 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; import org.bukkit.HeightMap; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -39,8 +38,6 @@ public class BeeWingListener implements Listener { if (player.isOnGround()) return; ItemStack chestplate = player.getInventory().getChestplate(); - if (chestplate.getType() != Material.ELYTRA) return; - if (!SlimefunUtils.isItemSimilar(chestplate, SlimefunItems.BEE_WINGS, true) && !Slimefun.hasUnlocked(player, chestplate, true)) { return; } From 45da395418e7caa816dffdd468e03196ee6fa8ef Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sun, 13 Sep 2020 23:41:16 +0300 Subject: [PATCH 16/21] Did a requested change. --- .../implementation/SlimefunItems.java | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 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 433346fde..6de88fc10 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -306,64 +306,64 @@ public final class SlimefunItems { public static final SlimefunItemStack BEE_BOOTS = new SlimefunItemStack("BEE_BOOTS", Material.GOLDEN_BOOTS, "&e&lBee Boots", "", "&e&oNever have trouble taking off again", "", "&9+ Jump Boost", "&9+ No Fall Damage"); static { - Map cactus = new HashMap<>(); - cactus.put(Enchantment.THORNS, 3); - cactus.put(Enchantment.DURABILITY, 6); + Map cactusEnchs = new HashMap<>(); + cactusEnchs.put(Enchantment.THORNS, 3); + cactusEnchs.put(Enchantment.DURABILITY, 6); - CACTUS_HELMET.addUnsafeEnchantments(cactus); - CACTUS_CHESTPLATE.addUnsafeEnchantments(cactus); - CACTUS_LEGGINGS.addUnsafeEnchantments(cactus); - CACTUS_BOOTS.addUnsafeEnchantments(cactus); + CACTUS_HELMET.addUnsafeEnchantments(cactusEnchs); + CACTUS_CHESTPLATE.addUnsafeEnchantments(cactusEnchs); + CACTUS_LEGGINGS.addUnsafeEnchantments(cactusEnchs); + CACTUS_BOOTS.addUnsafeEnchantments(cactusEnchs); - Map damascus = new HashMap<>(); - damascus.put(Enchantment.DURABILITY, 5); - damascus.put(Enchantment.PROTECTION_ENVIRONMENTAL, 5); + Map damascusEnchs = new HashMap<>(); + damascusEnchs.put(Enchantment.DURABILITY, 5); + damascusEnchs.put(Enchantment.PROTECTION_ENVIRONMENTAL, 5); - DAMASCUS_STEEL_HELMET.addUnsafeEnchantments(damascus); - DAMASCUS_STEEL_CHESTPLATE.addUnsafeEnchantments(damascus); - DAMASCUS_STEEL_LEGGINGS.addUnsafeEnchantments(damascus); - DAMASCUS_STEEL_BOOTS.addUnsafeEnchantments(damascus); + DAMASCUS_STEEL_HELMET.addUnsafeEnchantments(damascusEnchs); + DAMASCUS_STEEL_CHESTPLATE.addUnsafeEnchantments(damascusEnchs); + DAMASCUS_STEEL_LEGGINGS.addUnsafeEnchantments(damascusEnchs); + DAMASCUS_STEEL_BOOTS.addUnsafeEnchantments(damascusEnchs); - Map reinforced = new HashMap<>(); - reinforced.put(Enchantment.DURABILITY, 9); - reinforced.put(Enchantment.PROTECTION_ENVIRONMENTAL, 9); + Map reinforcedEnchs = new HashMap<>(); + reinforcedEnchs.put(Enchantment.DURABILITY, 9); + reinforcedEnchs.put(Enchantment.PROTECTION_ENVIRONMENTAL, 9); - REINFORCED_ALLOY_HELMET.addUnsafeEnchantments(reinforced); - REINFORCED_ALLOY_CHESTPLATE.addUnsafeEnchantments(reinforced); - REINFORCED_ALLOY_LEGGINGS.addUnsafeEnchantments(reinforced); - REINFORCED_ALLOY_BOOTS.addUnsafeEnchantments(reinforced); + REINFORCED_ALLOY_HELMET.addUnsafeEnchantments(reinforcedEnchs); + REINFORCED_ALLOY_CHESTPLATE.addUnsafeEnchantments(reinforcedEnchs); + REINFORCED_ALLOY_LEGGINGS.addUnsafeEnchantments(reinforcedEnchs); + REINFORCED_ALLOY_BOOTS.addUnsafeEnchantments(reinforcedEnchs); - Map gilded = new HashMap<>(); - gilded.put(Enchantment.DURABILITY, 6); - gilded.put(Enchantment.PROTECTION_ENVIRONMENTAL, 8); + Map gildedEnchs = new HashMap<>(); + gildedEnchs.put(Enchantment.DURABILITY, 6); + gildedEnchs.put(Enchantment.PROTECTION_ENVIRONMENTAL, 8); - GILDED_IRON_HELMET.addUnsafeEnchantments(gilded); - GILDED_IRON_CHESTPLATE.addUnsafeEnchantments(gilded); - GILDED_IRON_LEGGINGS.addUnsafeEnchantments(gilded); - GILDED_IRON_BOOTS.addUnsafeEnchantments(gilded); + GILDED_IRON_HELMET.addUnsafeEnchantments(gildedEnchs); + GILDED_IRON_CHESTPLATE.addUnsafeEnchantments(gildedEnchs); + GILDED_IRON_LEGGINGS.addUnsafeEnchantments(gildedEnchs); + GILDED_IRON_BOOTS.addUnsafeEnchantments(gildedEnchs); GOLDEN_HELMET_12K.addUnsafeEnchantment(Enchantment.DURABILITY, 10); GOLDEN_CHESTPLATE_12K.addUnsafeEnchantment(Enchantment.DURABILITY, 10); GOLDEN_LEGGINGS_12K.addUnsafeEnchantment(Enchantment.DURABILITY, 10); GOLDEN_BOOTS_12K.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - Map slime = new HashMap<>(); - slime.put(Enchantment.DURABILITY, 4); - slime.put(Enchantment.PROTECTION_ENVIRONMENTAL, 2); + Map slimeEnchs = new HashMap<>(); + slimeEnchs.put(Enchantment.DURABILITY, 4); + slimeEnchs.put(Enchantment.PROTECTION_ENVIRONMENTAL, 2); - SLIME_HELMET_STEEL.addUnsafeEnchantments(slime); - SLIME_CHESTPLATE_STEEL.addUnsafeEnchantments(slime); - SLIME_LEGGINGS_STEEL.addUnsafeEnchantments(slime); - SLIME_BOOTS_STEEL.addUnsafeEnchantments(slime); + SLIME_HELMET_STEEL.addUnsafeEnchantments(slimeEnchs); + SLIME_CHESTPLATE_STEEL.addUnsafeEnchantments(slimeEnchs); + SLIME_LEGGINGS_STEEL.addUnsafeEnchantments(slimeEnchs); + SLIME_BOOTS_STEEL.addUnsafeEnchantments(slimeEnchs); - Map bee = new HashMap<>(); - bee.put(Enchantment.DURABILITY, 4); - bee.put(Enchantment.PROTECTION_ENVIRONMENTAL, 2); + Map beeEnchs = new HashMap<>(); + beeEnchs.put(Enchantment.DURABILITY, 4); + beeEnchs.put(Enchantment.PROTECTION_ENVIRONMENTAL, 2); - BEE_HELMET.addUnsafeEnchantments(bee); - BEE_WINGS.addUnsafeEnchantments(bee); - BEE_LEGGINGS.addUnsafeEnchantments(bee); - BEE_BOOTS.addUnsafeEnchantments(bee); + BEE_HELMET.addUnsafeEnchantments(beeEnchs); + BEE_WINGS.addUnsafeEnchantments(beeEnchs); + BEE_LEGGINGS.addUnsafeEnchantments(beeEnchs); + BEE_BOOTS.addUnsafeEnchantments(beeEnchs); } /* Magical components */ From ad1bfc052ca06a247ef671272e1b963cd8782456 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Wed, 16 Sep 2020 21:16:47 +0300 Subject: [PATCH 17/21] Refactoring, requested changes and lots of improvement. --- .../listeners/BeeWingListener.java | 49 +++++++++++++------ 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java index cf36ec47f..6063add5a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java @@ -1,8 +1,10 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; +import java.util.HashMap; +import java.util.UUID; + import org.bukkit.HeightMap; import org.bukkit.Location; -import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -12,6 +14,8 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import javax.annotation.Nonnull; + import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; @@ -22,11 +26,12 @@ import me.mrCookieSlime.Slimefun.api.Slimefun; * when nearing the ground while using the Bee Wings. * * @author beSnow + * @author Linox * */ public class BeeWingListener implements Listener { - public BeeWingListener(SlimefunPlugin plugin) { + public BeeWingListener(@Nonnull SlimefunPlugin plugin) { plugin.getServer().getPluginManager().registerEvents(this, plugin); } @@ -34,37 +39,51 @@ public class BeeWingListener implements Listener { public void onApproachGround(PlayerMoveEvent e) { Player player = e.getPlayer(); + // Checking if the player is even falling. + if (e.getTo().getBlockY() == e.getFrom().getBlockY()) { + return; + } + if (!player.isGliding()) return; if (player.isOnGround()) return; + if (player.hasPotionEffect(PotionEffectType.SLOW_FALLING)) return; + ItemStack chestplate = player.getInventory().getChestplate(); - if (!SlimefunUtils.isItemSimilar(chestplate, SlimefunItems.BEE_WINGS, true) && !Slimefun.hasUnlocked(player, chestplate, true)) { + if (!SlimefunUtils.isItemSimilar(chestplate, SlimefunItems.BEE_WINGS, true) || !Slimefun.hasUnlocked(player, chestplate, true)) { return; } - double playerDistanceToHighestBlock = (player.getLocation().getY() - player.getWorld().getHighestBlockYAt(player.getLocation(), HeightMap.WORLD_SURFACE)); + Location loc = player.getLocation(); + double distanceToHighestBlock = (loc.getBlockY() - player.getWorld().getHighestBlockYAt(loc, HeightMap.WORLD_SURFACE)); // getDistanceToGround will only fire when playerDistanceToHighestBlock is negative (which happens when a player is flying under an existing structure) - if (playerDistanceToHighestBlock < 0) { - if (getDistanceToGround(player) > 6) return; + if (distanceToHighestBlock < 0) { + if (getDistanceToGround(loc) > 6) return; player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 40, 0)); return; } - if (playerDistanceToHighestBlock <= 6) { + if (distanceToHighestBlock <= 6) { player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 40, 0)); } } - private static int getDistanceToGround(Entity e) { - Location loc = e.getLocation().clone(); - double y = loc.getBlockY(); - int distance = 0; - for (double i = y; i >= 0; i--) { + /* + * Calculates the distance of the given {@link Location} from the ground. + * + * @param loc + * The {@link Location} to calculate from. + * + */ + private int getDistanceToGround(@Nonnull Location loc) { + int y = loc.getBlockY(); + for (int i = y; i >= 0; i--) { loc.setY(i); - if (loc.getBlock().getType().isSolid()) break; - distance++; + if (loc.getBlock().getType().isSolid()) { + return y - i; + } } - return distance; + return 0; } } From d40b6199e962e970c1f32d4413080f804b1ed5d6 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Wed, 16 Sep 2020 21:25:04 +0300 Subject: [PATCH 18/21] Shhh noone needs to know about this. --- .../slimefun4/implementation/listeners/BeeWingListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java index 6063add5a..f638e5d5e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java @@ -69,7 +69,7 @@ public class BeeWingListener implements Listener { } } - /* + /** * Calculates the distance of the given {@link Location} from the ground. * * @param loc From 2bad759178f9a2c189055657ac06dc7a1ba74654 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Wed, 16 Sep 2020 21:54:23 +0300 Subject: [PATCH 19/21] Fixed a little issue. --- .../slimefun4/implementation/listeners/BeeWingListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java index f638e5d5e..0e5c0c68b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java @@ -59,7 +59,7 @@ public class BeeWingListener implements Listener { // getDistanceToGround will only fire when playerDistanceToHighestBlock is negative (which happens when a player is flying under an existing structure) if (distanceToHighestBlock < 0) { - if (getDistanceToGround(loc) > 6) return; + if (getDistanceToGround(loc.clone()) > 6) return; player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 40, 0)); return; } From a63f3eb8863d30483747dd4887782f0fb9e8d04f Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Thu, 17 Sep 2020 15:16:24 +0300 Subject: [PATCH 20/21] Some refactoring and optimizations. --- .../listeners/BeeWingListener.java | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java index 0e5c0c68b..307337798 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java @@ -1,8 +1,5 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; -import java.util.HashMap; -import java.util.UUID; - import org.bukkit.HeightMap; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -55,33 +52,35 @@ public class BeeWingListener implements Listener { } Location loc = player.getLocation(); - double distanceToHighestBlock = (loc.getBlockY() - player.getWorld().getHighestBlockYAt(loc, HeightMap.WORLD_SURFACE)); + int distanceToHighestBlock = (loc.getBlockY() - player.getWorld().getHighestBlockYAt(loc, HeightMap.WORLD_SURFACE)); // getDistanceToGround will only fire when playerDistanceToHighestBlock is negative (which happens when a player is flying under an existing structure) if (distanceToHighestBlock < 0) { - if (getDistanceToGround(loc.clone()) > 6) return; + int distanceToGround = getDistanceToGround(loc.getBlock(), 6); + if (distanceToGround < 1) return; + player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 40, 0)); return; } - - if (distanceToHighestBlock <= 6) { + else if (distanceToHighestBlock <= 6) { player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 40, 0)); } } /** - * Calculates the distance of the given {@link Location} from the ground. + * Calculates the distance of the given {@link Block} from the ground. * - * @param loc - * The {@link Location} to calculate from. + * @param b + * The {@link Block} to calculate from. + * @param limit + * The limit of {@link Block blocks} to check under the given {@link Block b}. * */ - private int getDistanceToGround(@Nonnull Location loc) { - int y = loc.getBlockY(); - for (int i = y; i >= 0; i--) { - loc.setY(i); - if (loc.getBlock().getType().isSolid()) { - return y - i; + private int getDistanceToGround(@Nonnull Block b, int limit) { + for (int i = 1; i <= limit; i++) { + Block relative = b.getRelative(0, -i, 0); + if (relative.getType().isSolid()) { + return i; } } return 0; From cf5a6e0cca1b264ede5f48989455b02c45dd8db5 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Thu, 17 Sep 2020 15:17:53 +0300 Subject: [PATCH 21/21] Oops forgot an import. --- .../slimefun4/implementation/listeners/BeeWingListener.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java index 307337798..d95b19909 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java @@ -2,6 +2,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; import org.bukkit.HeightMap; import org.bukkit.Location; +import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority;