From 64fd5a54c3a75600883c1a4e7e399f778ebfda7b Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 19 Nov 2020 12:49:42 +0100 Subject: [PATCH] Added an item setting to configure the Wind Staff velocity --- CHANGELOG.md | 1 + .../items/magical/staves/WindStaff.java | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 395de27b1..707db6db2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ * Added a config option to disable network visualizations * (API) Added CoolerFeedPlayerEvent * Added a config option to delete excess cargo network items +* Added an item setting to configure the Wind Staff velocity #### Changes * Removed 1.13 support diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/WindStaff.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/WindStaff.java index 0db750224..4be752939 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/WindStaff.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/WindStaff.java @@ -8,6 +8,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.inventory.ItemStack; +import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; @@ -15,10 +17,20 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; +/** + * The {@link WindStaff} is a powerful staff which launches the {@link Player} forward when right clicked. + * + * @author TheBusyBiscuit + * + */ public class WindStaff extends SimpleSlimefunItem { + private final ItemSetting multiplier = new IntRangeSetting("power", 1, 4, Integer.MAX_VALUE); + public WindStaff(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); + + addItemSetting(multiplier); } @Override @@ -27,6 +39,7 @@ public class WindStaff extends SimpleSlimefunItem { Player p = e.getPlayer(); if (p.getFoodLevel() >= 2) { + // The isItem() check is here to prevent the MultiTool from consuming hunger if (isItem(e.getItem()) && p.getGameMode() != GameMode.CREATIVE) { FoodLevelChangeEvent event = new FoodLevelChangeEvent(p, p.getFoodLevel() - 2); Bukkit.getPluginManager().callEvent(event); @@ -36,7 +49,7 @@ public class WindStaff extends SimpleSlimefunItem { } } - p.setVelocity(p.getEyeLocation().getDirection().multiply(4)); + p.setVelocity(p.getEyeLocation().getDirection().multiply(multiplier.getValue())); p.getWorld().playSound(p.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1); p.getWorld().playEffect(p.getLocation(), Effect.SMOKE, 1); p.setFallDistance(0F);