1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35: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;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import me.mrCookieSlime.Slimefun.Lists.Categories;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
import me.mrCookieSlime.Slimefun.api.Slimefun;
/**
* @since 4.0
*/
public class EnderTalisman extends SlimefunItem {
private String suffix;
private boolean consumable;
private boolean cancel;
private PotionEffect[] effects;
private int chance;
public class EnderTalisman extends Talisman {
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());
this.consumable = parent.isConsumable();
this.cancel = parent.isEventCancelled();
this.suffix = parent.getSuffix();
this.effects = parent.getEffects();
this.chance = parent.getChance();
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});
consumable = parent.isConsumable();
cancel = parent.isEventCancelled();
suffix = parent.getSuffix();
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");
}
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.Slimefun.Lists.Categories;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.Research;
import me.mrCookieSlime.Slimefun.Setup.Messages;
import me.mrCookieSlime.Slimefun.api.Slimefun;
@ -28,11 +29,11 @@ import me.mrCookieSlime.Slimefun.api.Slimefun;
*/
public class Talisman extends SlimefunItem {
private String suffix;
private boolean consumable = true;
private boolean cancel = true;
private PotionEffect[] effects;
private int chance = 100;
protected String suffix;
protected boolean consumable = true;
protected boolean cancel = true;
protected PotionEffect[] effects;
protected int chance = 100;
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));
@ -52,12 +53,16 @@ public class Talisman extends SlimefunItem {
}
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.effects = effects;
this.chance = chance;
}
protected Talisman(Category category, ItemStack item, String id, ItemStack[] recipe) {
super(category, item, id, RecipeType.MAGIC_WORKBENCH, recipe);
}
public String getSuffix() {
return this.suffix;
}