1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 11:45:51 +00:00

Reduced technical debt

This commit is contained in:
TheBusyBiscuit 2019-09-04 19:51:03 +02:00
parent 38b2112aaf
commit b4dff80dcc
2 changed files with 19 additions and 27 deletions

View File

@ -1,38 +1,25 @@
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem; package me.mrCookieSlime.Slimefun.Objects.SlimefunItem;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import me.mrCookieSlime.Slimefun.Lists.Categories; import me.mrCookieSlime.Slimefun.Lists.Categories;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems; import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.Slimefun;
/** /**
* @since 4.0 * @since 4.0
*/ */
public class EnderTalisman extends SlimefunItem { public class EnderTalisman extends Talisman {
private String suffix;
private boolean consumable;
private boolean cancel;
private PotionEffect[] effects;
private int chance;
public EnderTalisman(Talisman parent) { public EnderTalisman(Talisman parent) {
super(Categories.TALISMANS_2, parent.upgrade(), "ENDER_" + parent.getID(), RecipeType.MAGIC_WORKBENCH, new ItemStack[] {SlimefunItems.ENDER_LUMP_3, null, SlimefunItems.ENDER_LUMP_3, null, parent.getItem(), null, SlimefunItems.ENDER_LUMP_3, null, SlimefunItems.ENDER_LUMP_3}, parent.upgrade()); super(Categories.TALISMANS_2, parent.upgrade(), "ENDER_" + parent.getID(), new ItemStack[] {SlimefunItems.ENDER_LUMP_3, null, SlimefunItems.ENDER_LUMP_3, null, parent.getItem(), null, SlimefunItems.ENDER_LUMP_3, null, SlimefunItems.ENDER_LUMP_3});
this.consumable = parent.isConsumable();
this.cancel = parent.isEventCancelled(); consumable = parent.isConsumable();
this.suffix = parent.getSuffix(); cancel = parent.isEventCancelled();
this.effects = parent.getEffects(); suffix = parent.getSuffix();
this.chance = parent.getChance(); effects = parent.getEffects();
chance = parent.getChance();
Slimefun.addHint("ENDER_" + parent.getID(), "&eEnder Talismans have the advantage", "&eof still working while they", "&eare in your Ender Chest"); Slimefun.addHint("ENDER_" + parent.getID(), "&eEnder Talismans have the advantage", "&eof still working while they", "&eare in your Ender Chest");
} }
public String getSuffix() { return this.suffix; }
public boolean isConsumable() { return this.consumable; }
public boolean isEventCancelled() { return this.cancel; }
public PotionEffect[] getEffects() { return this.effects; }
public int getChance() { return this.chance; }
} }

View File

@ -19,6 +19,7 @@ import org.bukkit.potion.PotionEffect;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
import me.mrCookieSlime.Slimefun.Lists.Categories; import me.mrCookieSlime.Slimefun.Lists.Categories;
import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.Research; import me.mrCookieSlime.Slimefun.Objects.Research;
import me.mrCookieSlime.Slimefun.Setup.Messages; import me.mrCookieSlime.Slimefun.Setup.Messages;
import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.Slimefun;
@ -28,11 +29,11 @@ import me.mrCookieSlime.Slimefun.api.Slimefun;
*/ */
public class Talisman extends SlimefunItem { public class Talisman extends SlimefunItem {
private String suffix; protected String suffix;
private boolean consumable = true; protected boolean consumable = true;
private boolean cancel = true; protected boolean cancel = true;
private PotionEffect[] effects; protected PotionEffect[] effects;
private int chance = 100; protected int chance = 100;
public Talisman(ItemStack item, String id, ItemStack[] recipe, boolean consumable, boolean cancelEvent, String messageSuffix, PotionEffect... effects) { public Talisman(ItemStack item, String id, ItemStack[] recipe, boolean consumable, boolean cancelEvent, String messageSuffix, PotionEffect... effects) {
super(Categories.TALISMANS_1, item, id, RecipeType.MAGIC_WORKBENCH, recipe, new CustomItem(item, consumable ? 4 : 1)); super(Categories.TALISMANS_1, item, id, RecipeType.MAGIC_WORKBENCH, recipe, new CustomItem(item, consumable ? 4 : 1));
@ -52,12 +53,16 @@ public class Talisman extends SlimefunItem {
} }
public Talisman(ItemStack item, String id, ItemStack[] recipe, String messageSuffix, int chance, PotionEffect... effects) { public Talisman(ItemStack item, String id, ItemStack[] recipe, String messageSuffix, int chance, PotionEffect... effects) {
super(Categories.TALISMANS_1, item, id, RecipeType.MAGIC_WORKBENCH, recipe, item); super(Categories.TALISMANS_1, item, id, RecipeType.MAGIC_WORKBENCH, recipe);
this.suffix = messageSuffix; this.suffix = messageSuffix;
this.effects = effects; this.effects = effects;
this.chance = chance; this.chance = chance;
} }
protected Talisman(Category category, ItemStack item, String id, ItemStack[] recipe) {
super(category, item, id, RecipeType.MAGIC_WORKBENCH, recipe);
}
public String getSuffix() { public String getSuffix() {
return this.suffix; return this.suffix;
} }