mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2024-12-22 04:37:42 +01:00
Fixed <1.20 startup issue
This commit is contained in:
parent
724184b67c
commit
81efe1abcd
@ -1,14 +1,11 @@
|
||||
package net.Indyuce.mmoitems.api.edition;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.edition.input.AnvilGUI;
|
||||
import net.Indyuce.mmoitems.api.edition.input.ChatEdition;
|
||||
import net.Indyuce.mmoitems.gui.ItemBrowser;
|
||||
import net.Indyuce.mmoitems.gui.PluginInventory;
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class NewItemEdition implements Edition {
|
||||
private final ItemBrowser inv;
|
||||
@ -30,15 +27,6 @@ public class NewItemEdition implements Edition {
|
||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Write in the chat, the id of the new item.");
|
||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Type 'cancel' to abort editing.");
|
||||
|
||||
/*
|
||||
* Anvil text input feature. Enables players to use an anvil to input
|
||||
* text if they are having conflicts with their chat management plugins.
|
||||
*/
|
||||
if (MMOItems.plugin.getConfig().getBoolean("anvil-text-input") && MythicLib.plugin.getVersion().isBelowOrEqual(1, 13)) {
|
||||
new AnvilGUI(this);
|
||||
return;
|
||||
}
|
||||
|
||||
// Default chat edition feature
|
||||
new ChatEdition(this);
|
||||
inv.getPlayer().sendTitle(ChatColor.GOLD + "" + ChatColor.BOLD + "Item Creation", "See chat.", 10, 40, 10);
|
||||
|
@ -47,15 +47,6 @@ public class StatEdition implements Edition {
|
||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + ChatColor.translateAlternateColorCodes('&', line));
|
||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Type 'cancel' to abort editing.");
|
||||
|
||||
/*
|
||||
* Anvil text input feature. enables players to use an anvil to input
|
||||
* text if they are having conflicts with their chat management plugins.
|
||||
*
|
||||
if (MMOItems.plugin.getConfig().getBoolean("anvil-text-input") && MythicLib.plugin.getVersion().isBelowOrEqual(1, 13)) {
|
||||
new AnvilGUI(this);
|
||||
return;
|
||||
}*/
|
||||
|
||||
// Default chat edition feature
|
||||
new ChatEdition(this);
|
||||
inv.getPlayer().sendTitle(ChatColor.GOLD + "" + ChatColor.BOLD + "Item Edition", "See chat.", 10, 40, 10);
|
||||
|
@ -0,0 +1,19 @@
|
||||
package net.Indyuce.mmoitems.api.event;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MMOItemsReloadEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -74,13 +74,6 @@ public class Tool extends UseItem {
|
||||
}.runTaskTimer(MMOItems.plugin, 0, 1);
|
||||
}
|
||||
|
||||
/*if (getNBTItem().hasTag("MMOITEMS_BREAK_SIZE")) {
|
||||
int breakSize = getNBTItem().getInteger("MMOITEMS_BREAK_SIZE");
|
||||
if(breakSize % 2 != 0) {
|
||||
BlockFace face = player.getFacing();
|
||||
System.out.println("Debug: Facing - " + face);
|
||||
}
|
||||
}*/
|
||||
return cancel;
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,10 @@ package net.Indyuce.mmoitems.command.mmoitems;
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.command.api.CommandTreeNode;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.event.MMOItemsReloadEvent;
|
||||
import net.Indyuce.mmoitems.api.util.MMOItemReforger;
|
||||
import net.Indyuce.mmoitems.api.util.NumericStatFormula;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@ -53,6 +55,8 @@ public class ReloadCommandTreeNode extends CommandTreeNode {
|
||||
}
|
||||
|
||||
public void reloadMain(CommandSender sender) {
|
||||
Bukkit.getPluginManager().callEvent(new MMOItemsReloadEvent());
|
||||
|
||||
MMOItems.plugin.getLanguage().reload();
|
||||
MMOItems.plugin.getDropTables().reload();
|
||||
MMOItems.plugin.getTypes().reload();
|
||||
|
@ -37,6 +37,7 @@ public class StatManager {
|
||||
* Load default stats using java reflection, get all public static final
|
||||
* fields in the ItemStat and register them as stat instances
|
||||
*/
|
||||
@Deprecated
|
||||
public void load() {
|
||||
for (Field field : ItemStats.class.getFields())
|
||||
try {
|
||||
|
@ -346,7 +346,6 @@ public class TemplateManager implements Reloadable {
|
||||
* be refreshed afterwards.
|
||||
*/
|
||||
public void reload() {
|
||||
System.out.println("RELOADING TEMPLATE MANAGER");
|
||||
templates.clear();
|
||||
modifierNodes.clear();
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||
import net.Indyuce.mmoitems.ItemStats;
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
|
||||
import net.Indyuce.mmoitems.stat.data.BooleanData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
import net.Indyuce.mmoitems.stat.type.BooleanStat;
|
||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||
import net.Indyuce.mmoitems.util.VersionDependant;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -19,16 +19,11 @@ import java.util.ArrayList;
|
||||
* @deprecated Merge with other Hide- stats
|
||||
*/
|
||||
@Deprecated
|
||||
@VersionDependant(minor = 16, patch = 3)
|
||||
public class HideDye extends BooleanStat {
|
||||
public HideDye() {
|
||||
super("HIDE_DYE", Material.CYAN_DYE, "Hide Dyed", new String[] { "Enable to hide the 'Dyed' tag from the item." }, new String[] { "all" },
|
||||
Material.LEATHER_HELMET, Material.LEATHER_CHESTPLATE, Material.LEATHER_LEGGINGS, Material.LEATHER_BOOTS, VersionMaterial.LEATHER_HORSE_ARMOR.toMaterial());
|
||||
|
||||
try {
|
||||
ItemFlag.valueOf("HIDE_DYE");
|
||||
} catch(IllegalArgumentException exception) {
|
||||
disable();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
|
||||
import net.Indyuce.mmoitems.stat.data.BooleanData;
|
||||
import net.Indyuce.mmoitems.stat.type.BooleanStat;
|
||||
import net.Indyuce.mmoitems.util.VersionDependant;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -17,15 +18,10 @@ import java.util.ArrayList;
|
||||
* @deprecated Merge with other Hide- stats
|
||||
*/
|
||||
@Deprecated
|
||||
@VersionDependant(minor = 20)
|
||||
public class HideTrim extends BooleanStat {
|
||||
public HideTrim() {
|
||||
super("HIDE_ARMOR_TRIM", Material.LEATHER_CHESTPLATE, "Hide Armor Trim", new String[]{"Hides armor trim from item lore."}, new String[]{"armor"});
|
||||
|
||||
try {
|
||||
ItemFlag.valueOf("HIDE_ARMOR_TRIM");
|
||||
} catch (IllegalArgumentException exception) {
|
||||
disable();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,12 +1,12 @@
|
||||
package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
|
||||
import net.Indyuce.mmoitems.stat.data.StringData;
|
||||
import net.Indyuce.mmoitems.stat.type.ChooseStat;
|
||||
import net.Indyuce.mmoitems.stat.type.GemStoneStat;
|
||||
import net.Indyuce.mmoitems.util.StatChoice;
|
||||
import net.Indyuce.mmoitems.util.VersionDependant;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Registry;
|
||||
@ -20,14 +20,13 @@ import org.jetbrains.annotations.Nullable;
|
||||
/**
|
||||
* @author Jules
|
||||
*/
|
||||
@VersionDependant(minor = 20)
|
||||
public class TrimMaterialStat extends ChooseStat implements GemStoneStat {
|
||||
public TrimMaterialStat() {
|
||||
super("TRIM_MATERIAL", Material.LEATHER_CHESTPLATE, "Trim Material", new String[]{"Material to trim your armor with."}, new String[]{"armor"});
|
||||
|
||||
if (MythicLib.plugin.getVersion().isBelowOrEqual(1, 19)) {
|
||||
disable();
|
||||
return;
|
||||
}
|
||||
// Version dependency
|
||||
if (!isEnabled()) return;
|
||||
|
||||
for (TrimMaterial mat : Registry.TRIM_MATERIAL)
|
||||
addChoices(new StatChoice(mat.getKey().getKey()));
|
||||
|
@ -1,12 +1,12 @@
|
||||
package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
|
||||
import net.Indyuce.mmoitems.stat.data.StringData;
|
||||
import net.Indyuce.mmoitems.stat.type.ChooseStat;
|
||||
import net.Indyuce.mmoitems.stat.type.GemStoneStat;
|
||||
import net.Indyuce.mmoitems.util.StatChoice;
|
||||
import net.Indyuce.mmoitems.util.VersionDependant;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Registry;
|
||||
@ -20,14 +20,13 @@ import org.jetbrains.annotations.Nullable;
|
||||
/**
|
||||
* @author Jules
|
||||
*/
|
||||
@VersionDependant(minor = 20)
|
||||
public class TrimPatternStat extends ChooseStat implements GemStoneStat {
|
||||
public TrimPatternStat() {
|
||||
super("TRIM_PATTERN", Material.LEATHER_CHESTPLATE, "Trim Pattern", new String[]{"Pattern of trimmed armor."}, new String[]{"armor"});
|
||||
|
||||
if (MythicLib.plugin.getVersion().isBelowOrEqual(1, 19)) {
|
||||
disable();
|
||||
return;
|
||||
}
|
||||
// Version dependency
|
||||
if (!isEnabled()) return;
|
||||
|
||||
for (TrimPattern mat : Registry.TRIM_PATTERN)
|
||||
addChoices(new StatChoice(mat.getKey().getKey()));
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmoitems.stat.type;
|
||||
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
@ -8,6 +9,7 @@ import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
|
||||
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
|
||||
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
import net.Indyuce.mmoitems.util.VersionDependant;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
@ -58,6 +60,13 @@ public abstract class ItemStat<R extends RandomStatData<S>, S extends StatData>
|
||||
|
||||
this.configPath = id.toLowerCase().replace("_", "-");
|
||||
this.nbtPath = "MMOITEMS_" + id;
|
||||
|
||||
// Version dependency
|
||||
if (getClass().isAnnotationPresent(VersionDependant.class)) {
|
||||
final VersionDependant implVersion = getClass().getAnnotation(VersionDependant.class);
|
||||
if (MythicLib.plugin.getVersion().isBelowOrEqual(implVersion.major(), implVersion.minor(), implVersion.patch() - 1))
|
||||
disable();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,24 @@
|
||||
package net.Indyuce.mmoitems.util;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* Version string is MAJOR.MINOR.PATCH
|
||||
* <p>
|
||||
* This annotation indicates the LOWEST VERSION at which
|
||||
* the given feature is available. Usually, it's the
|
||||
* version where some non-backwards compatible feature was
|
||||
* implemented into Minecraft or Spigot.
|
||||
*
|
||||
* @author Jules
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface VersionDependant {
|
||||
|
||||
public int major() default 1;
|
||||
|
||||
public int minor();
|
||||
|
||||
public int patch() default 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user