mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 11:45:51 +00:00
Minor changes in Talisman and EnderTalisman
Renamed consumed field to consumable Added javadoc : since Talisman - Field initialisation inline instead of in constructors Simplified a condition
This commit is contained in:
parent
858f964b82
commit
6cb081cfd3
@ -7,17 +7,20 @@ import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 4.0
|
||||||
|
*/
|
||||||
public class EnderTalisman extends SlimefunItem {
|
public class EnderTalisman extends SlimefunItem {
|
||||||
|
|
||||||
private boolean consumed;
|
private String suffix;
|
||||||
|
private boolean consumable;
|
||||||
private boolean cancel;
|
private boolean cancel;
|
||||||
private PotionEffect[] effects;
|
private PotionEffect[] effects;
|
||||||
private String suffix;
|
|
||||||
private int chance;
|
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[] {SlimefunItem.getItem("ENDER_LUMP_3"), null, SlimefunItem.getItem("ENDER_LUMP_3"), null, parent.getItem(), null, SlimefunItem.getItem("ENDER_LUMP_3"), null, SlimefunItem.getItem("ENDER_LUMP_3")}, parent.upgrade());
|
super(Categories.TALISMANS_2, parent.upgrade(), "ENDER_" + parent.getID(), RecipeType.MAGIC_WORKBENCH, new ItemStack[] {SlimefunItem.getItem("ENDER_LUMP_3"), null, SlimefunItem.getItem("ENDER_LUMP_3"), null, parent.getItem(), null, SlimefunItem.getItem("ENDER_LUMP_3"), null, SlimefunItem.getItem("ENDER_LUMP_3")}, parent.upgrade());
|
||||||
this.consumed = parent.isConsumable();
|
this.consumable = parent.isConsumable();
|
||||||
this.cancel = parent.isEventCancelled();
|
this.cancel = parent.isEventCancelled();
|
||||||
this.suffix = parent.getSuffix();
|
this.suffix = parent.getSuffix();
|
||||||
this.effects = parent.getEffects();
|
this.effects = parent.getEffects();
|
||||||
@ -25,9 +28,9 @@ public class EnderTalisman extends SlimefunItem {
|
|||||||
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 PotionEffect[] getEffects() { return this.effects; }
|
|
||||||
public boolean isConsumable() { return this.consumed; }
|
|
||||||
public boolean isEventCancelled() { return this.cancel; }
|
|
||||||
public String getSuffix() { return this.suffix; }
|
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; }
|
public int getChance() { return this.chance; }
|
||||||
}
|
}
|
||||||
|
@ -23,26 +23,28 @@ import org.bukkit.event.player.PlayerEvent;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 4.0
|
||||||
|
*/
|
||||||
public class Talisman extends SlimefunItem {
|
public class Talisman extends SlimefunItem {
|
||||||
|
|
||||||
private boolean consumed;
|
|
||||||
private boolean cancel;
|
|
||||||
private PotionEffect[] effects;
|
|
||||||
private String suffix;
|
private String suffix;
|
||||||
private int chance;
|
private boolean consumable = true;
|
||||||
|
private boolean cancel = true;
|
||||||
|
private PotionEffect[] effects = new PotionEffect[0];
|
||||||
|
private 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));
|
||||||
this.consumed = consumable;
|
this.consumable = consumable;
|
||||||
this.cancel = cancelEvent;
|
this.cancel = cancelEvent;
|
||||||
this.suffix = messageSuffix;
|
this.suffix = messageSuffix;
|
||||||
this.effects = effects;
|
this.effects = effects;
|
||||||
this.chance = 100;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Talisman(ItemStack item, String id, ItemStack[] recipe, boolean consumable, boolean cancelEvent, String messageSuffix, int chance, PotionEffect... effects) {
|
public Talisman(ItemStack item, String id, ItemStack[] recipe, boolean consumable, boolean cancelEvent, String messageSuffix, int chance, 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));
|
||||||
this.consumed = consumable;
|
this.consumable = consumable;
|
||||||
this.cancel = cancelEvent;
|
this.cancel = cancelEvent;
|
||||||
this.suffix = messageSuffix;
|
this.suffix = messageSuffix;
|
||||||
this.effects = effects;
|
this.effects = effects;
|
||||||
@ -51,23 +53,21 @@ 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, item);
|
||||||
this.consumed = true;
|
|
||||||
this.cancel = true;
|
|
||||||
this.suffix = messageSuffix;
|
this.suffix = messageSuffix;
|
||||||
this.effects = effects;
|
this.effects = effects;
|
||||||
this.chance = chance;
|
this.chance = chance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PotionEffect[] getEffects() { return this.effects; }
|
|
||||||
public boolean isConsumable() { return this.consumed; }
|
|
||||||
public boolean isEventCancelled() { return this.cancel; }
|
|
||||||
public String getSuffix() { return this.suffix; }
|
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; }
|
public int getChance() { return this.chance; }
|
||||||
|
|
||||||
public static boolean checkFor(Event e, SlimefunItem talisman) {
|
public static boolean checkFor(Event e, SlimefunItem talisman) {
|
||||||
if (talisman != null) {
|
if (talisman != null) {
|
||||||
if (talisman instanceof Talisman) {
|
if (talisman instanceof Talisman) {
|
||||||
boolean message = ((Talisman) talisman).getSuffix().equalsIgnoreCase("") ? false: true;
|
boolean message = !((Talisman) talisman).getSuffix().equalsIgnoreCase("");
|
||||||
if (SlimefunStartup.chance(100, ((Talisman) talisman).getChance())) {
|
if (SlimefunStartup.chance(100, ((Talisman) talisman).getChance())) {
|
||||||
Player p = null;
|
Player p = null;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user