mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-01-08 07:27:39 +01:00
!adapt to newest mmocore builds
This commit is contained in:
parent
8e0375bf36
commit
6fcfee9b5d
@ -19,238 +19,246 @@ import java.util.List;
|
||||
@SuppressWarnings("unused")
|
||||
public class Type {
|
||||
|
||||
// slashing
|
||||
public static final Type SWORD = new Type(TypeSet.SLASHING, "SWORD", true, EquipmentSlot.MAIN_HAND);
|
||||
// slashing
|
||||
public static final Type SWORD = new Type(TypeSet.SLASHING, "SWORD", true, EquipmentSlot.MAIN_HAND);
|
||||
|
||||
// piercing
|
||||
public static final Type DAGGER = new Type(TypeSet.PIERCING, "DAGGER", true, EquipmentSlot.MAIN_HAND);
|
||||
public static final Type SPEAR = new Type(TypeSet.PIERCING, "SPEAR", true, EquipmentSlot.MAIN_HAND);
|
||||
// piercing
|
||||
public static final Type DAGGER = new Type(TypeSet.PIERCING, "DAGGER", true, EquipmentSlot.MAIN_HAND);
|
||||
public static final Type SPEAR = new Type(TypeSet.PIERCING, "SPEAR", true, EquipmentSlot.MAIN_HAND);
|
||||
|
||||
// blunt
|
||||
public static final Type HAMMER = new Type(TypeSet.BLUNT, "HAMMER", true, EquipmentSlot.MAIN_HAND);
|
||||
public static final Type GAUNTLET = new Type(TypeSet.BLUNT, "GAUNTLET", true, EquipmentSlot.MAIN_HAND);
|
||||
// blunt
|
||||
public static final Type HAMMER = new Type(TypeSet.BLUNT, "HAMMER", true, EquipmentSlot.MAIN_HAND);
|
||||
public static final Type GAUNTLET = new Type(TypeSet.BLUNT, "GAUNTLET", true, EquipmentSlot.MAIN_HAND);
|
||||
|
||||
// range
|
||||
public static final Type WHIP = new Type(TypeSet.RANGE, "WHIP", true, EquipmentSlot.MAIN_HAND);
|
||||
public static final Type STAFF = new Type(TypeSet.RANGE, "STAFF", true, EquipmentSlot.MAIN_HAND);
|
||||
public static final Type BOW = new Type(TypeSet.RANGE, "BOW", true, EquipmentSlot.BOTH_HANDS);
|
||||
public static final Type CROSSBOW = new Type(TypeSet.RANGE, "CROSSBOW", false, EquipmentSlot.BOTH_HANDS);
|
||||
public static final Type MUSKET = new Type(TypeSet.RANGE, "MUSKET", true, EquipmentSlot.MAIN_HAND);
|
||||
public static final Type LUTE = new Type(TypeSet.RANGE, "LUTE", true, EquipmentSlot.MAIN_HAND);
|
||||
// range
|
||||
public static final Type WHIP = new Type(TypeSet.RANGE, "WHIP", true, EquipmentSlot.MAIN_HAND);
|
||||
public static final Type STAFF = new Type(TypeSet.RANGE, "STAFF", true, EquipmentSlot.MAIN_HAND);
|
||||
public static final Type BOW = new Type(TypeSet.RANGE, "BOW", true, EquipmentSlot.BOTH_HANDS);
|
||||
public static final Type CROSSBOW = new Type(TypeSet.RANGE, "CROSSBOW", false, EquipmentSlot.BOTH_HANDS);
|
||||
public static final Type MUSKET = new Type(TypeSet.RANGE, "MUSKET", true, EquipmentSlot.MAIN_HAND);
|
||||
public static final Type LUTE = new Type(TypeSet.RANGE, "LUTE", true, EquipmentSlot.MAIN_HAND);
|
||||
|
||||
// offhand
|
||||
public static final Type CATALYST = new Type(TypeSet.OFFHAND, "CATALYST", false, EquipmentSlot.BOTH_HANDS);
|
||||
public static final Type OFF_CATALYST = new Type(TypeSet.OFFHAND, "OFF_CATALYST", false, EquipmentSlot.OFF_HAND);
|
||||
// offhand
|
||||
public static final Type CATALYST = new Type(TypeSet.OFFHAND, "CATALYST", false, EquipmentSlot.BOTH_HANDS);
|
||||
public static final Type OFF_CATALYST = new Type(TypeSet.OFFHAND, "OFF_CATALYST", false, EquipmentSlot.OFF_HAND);
|
||||
|
||||
// any
|
||||
public static final Type ORNAMENT = new Type(TypeSet.EXTRA, "ORNAMENT", false, EquipmentSlot.ANY);
|
||||
// any
|
||||
public static final Type ORNAMENT = new Type(TypeSet.EXTRA, "ORNAMENT", false, EquipmentSlot.ANY);
|
||||
|
||||
// extra
|
||||
public static final Type ARMOR = new Type(TypeSet.EXTRA, "ARMOR", false, EquipmentSlot.ARMOR);
|
||||
public static final Type TOOL = new Type(TypeSet.EXTRA, "TOOL", false, EquipmentSlot.MAIN_HAND);
|
||||
public static final Type CONSUMABLE = new Type(TypeSet.EXTRA, "CONSUMABLE", false, EquipmentSlot.MAIN_HAND);
|
||||
public static final Type MISCELLANEOUS = new Type(TypeSet.EXTRA, "MISCELLANEOUS", false, EquipmentSlot.MAIN_HAND);
|
||||
public static final Type GEM_STONE = new Type(TypeSet.EXTRA, "GEM_STONE", false, EquipmentSlot.OTHER);
|
||||
public static final Type SKIN = new Type(TypeSet.EXTRA, "SKIN", false, EquipmentSlot.OTHER);
|
||||
public static final Type ACCESSORY = new Type(TypeSet.EXTRA, "ACCESSORY", false, EquipmentSlot.ACCESSORY);
|
||||
public static final Type BLOCK = new Type(TypeSet.EXTRA, "BLOCK", false, EquipmentSlot.OTHER);
|
||||
// extra
|
||||
public static final Type ARMOR = new Type(TypeSet.EXTRA, "ARMOR", false, EquipmentSlot.ARMOR);
|
||||
public static final Type TOOL = new Type(TypeSet.EXTRA, "TOOL", false, EquipmentSlot.MAIN_HAND);
|
||||
public static final Type CONSUMABLE = new Type(TypeSet.EXTRA, "CONSUMABLE", false, EquipmentSlot.MAIN_HAND);
|
||||
public static final Type MISCELLANEOUS = new Type(TypeSet.EXTRA, "MISCELLANEOUS", false, EquipmentSlot.MAIN_HAND);
|
||||
public static final Type GEM_STONE = new Type(TypeSet.EXTRA, "GEM_STONE", false, EquipmentSlot.OTHER);
|
||||
public static final Type SKIN = new Type(TypeSet.EXTRA, "SKIN", false, EquipmentSlot.OTHER);
|
||||
public static final Type ACCESSORY = new Type(TypeSet.EXTRA, "ACCESSORY", false, EquipmentSlot.ACCESSORY);
|
||||
public static final Type BLOCK = new Type(TypeSet.EXTRA, "BLOCK", false, EquipmentSlot.OTHER);
|
||||
|
||||
private final String id;
|
||||
private String name;
|
||||
private final TypeSet set;
|
||||
private final String id;
|
||||
private String name;
|
||||
private final TypeSet set;
|
||||
|
||||
/**
|
||||
* Used for item type restrictions for gem stones to easily check if the
|
||||
* item is a weapon.
|
||||
*/
|
||||
private final boolean weapon;
|
||||
/**
|
||||
* Used for item type restrictions for gem stones to easily check if the
|
||||
* item is a weapon.
|
||||
*/
|
||||
private final boolean weapon;
|
||||
|
||||
private final EquipmentSlot equipType;
|
||||
private final EquipmentSlot equipType;
|
||||
|
||||
/**
|
||||
* Used to display the item in the item explorer and in the item recipes
|
||||
* list in the advanced workbench. can also be edited using the config
|
||||
* files.
|
||||
*/
|
||||
private ItemStack item;
|
||||
/**
|
||||
* Used to display the item in the item explorer and in the item recipes
|
||||
* list in the advanced workbench. can also be edited using the config
|
||||
* files.
|
||||
*/
|
||||
private ItemStack item;
|
||||
|
||||
/**
|
||||
* Any type can have a subtype which basically dictates what the item type
|
||||
* does.
|
||||
*/
|
||||
private Type parent;
|
||||
/**
|
||||
* Any type can have a subtype which basically dictates what the item type
|
||||
* does.
|
||||
*/
|
||||
private Type parent;
|
||||
|
||||
private UnidentifiedItem unidentifiedTemplate;
|
||||
private UnidentifiedItem unidentifiedTemplate;
|
||||
|
||||
/*
|
||||
* list of stats which can be applied onto an item which has this type. This
|
||||
* improves performance when generating an item by a significant amount.
|
||||
*/
|
||||
private final List<ItemStat> available = new ArrayList<>();
|
||||
/*
|
||||
* list of stats which can be applied onto an item which has this type. This
|
||||
* improves performance when generating an item by a significant amount.
|
||||
*/
|
||||
private final List<ItemStat> available = new ArrayList<>();
|
||||
|
||||
public Type(TypeSet set, String id, boolean weapon, EquipmentSlot equipType) {
|
||||
this.set = set;
|
||||
this.id = id.toUpperCase().replace("-", "_").replace(" ", "_");
|
||||
this.equipType = equipType;
|
||||
public Type(TypeSet set, String id, boolean weapon, EquipmentSlot equipType) {
|
||||
this.set = set;
|
||||
this.id = id.toUpperCase().replace("-", "_").replace(" ", "_");
|
||||
this.equipType = equipType;
|
||||
|
||||
this.weapon = weapon;
|
||||
}
|
||||
this.weapon = weapon;
|
||||
}
|
||||
|
||||
public Type(TypeManager manager, ConfigurationSection config) {
|
||||
id = config.getName().toUpperCase().replace("-", "_").replace(" ", "_");
|
||||
public Type(TypeManager manager, ConfigurationSection config) {
|
||||
id = config.getName().toUpperCase().replace("-", "_").replace(" ", "_");
|
||||
|
||||
parent = manager.get(config.getString("parent").toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||
set = parent.set;
|
||||
weapon = parent.weapon;
|
||||
equipType = parent.equipType;
|
||||
}
|
||||
parent = manager.get(config.getString("parent").toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||
set = parent.set;
|
||||
weapon = parent.weapon;
|
||||
equipType = parent.equipType;
|
||||
}
|
||||
|
||||
public void load(ConfigurationSection config) {
|
||||
Validate.notNull(config, "Could not find config for " + getId());
|
||||
public void load(ConfigurationSection config) {
|
||||
Validate.notNull(config, "Could not find config for " + getId());
|
||||
|
||||
name = config.getString("name");
|
||||
Validate.notNull(name, "Could not read name");
|
||||
name = config.getString("name");
|
||||
Validate.notNull(name, "Could not read name");
|
||||
|
||||
item = read(config.getString("display"));
|
||||
Validate.notNull(item, "Could not read item");
|
||||
item = read(config.getString("display"));
|
||||
Validate.notNull(item, "Could not read item");
|
||||
|
||||
(unidentifiedTemplate = new UnidentifiedItem(this)).update(config.getConfigurationSection("unident-item"));
|
||||
}
|
||||
(unidentifiedTemplate = new UnidentifiedItem(this)).update(config.getConfigurationSection("unident-item"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Type is no longer an enum so that external plugins can register their own types. Use getId() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public String name() {
|
||||
return getId();
|
||||
}
|
||||
/**
|
||||
* @deprecated Type is no longer an enum so that external plugins can register their own types. Use getId() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public String name() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Example <code>OFF_CATALYST</code>
|
||||
*
|
||||
* @return Internal name in uppercase and no spaces.
|
||||
*/
|
||||
public String getId() { return id; }
|
||||
/**
|
||||
* Example <code>OFF_CATALYST</code>
|
||||
*
|
||||
* @return Internal name in uppercase and no spaces.
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public TypeSet getItemSet() {
|
||||
return set;
|
||||
}
|
||||
public TypeSet getItemSet() {
|
||||
return set;
|
||||
}
|
||||
|
||||
public boolean isWeapon() {
|
||||
return weapon;
|
||||
}
|
||||
public boolean isWeapon() {
|
||||
return weapon;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public EquipmentSlot getEquipmentType() {
|
||||
return equipType;
|
||||
}
|
||||
public EquipmentSlot getEquipmentType() {
|
||||
return equipType;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return item.clone();
|
||||
}
|
||||
public ItemStack getItem() {
|
||||
return item.clone();
|
||||
}
|
||||
|
||||
public boolean isSubtype() {
|
||||
return parent != null;
|
||||
}
|
||||
public boolean isSubtype() {
|
||||
return parent != null;
|
||||
}
|
||||
|
||||
public Type getParent() {
|
||||
return parent;
|
||||
}
|
||||
public Type getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Either if the two types are the same,
|
||||
* or if this type is a subtype of the given type.
|
||||
*/
|
||||
public boolean corresponds(Type type) {
|
||||
return equals(type) || (isSubtype() && getParent().equals(type));
|
||||
}
|
||||
/**
|
||||
* @return Either if the two types are the same,
|
||||
* or if this type is a subtype of the given type.
|
||||
*/
|
||||
public boolean corresponds(Type type) {
|
||||
return equals(type) || (isSubtype() && getParent().equals(type));
|
||||
}
|
||||
|
||||
public boolean corresponds(TypeSet set) {
|
||||
return getItemSet() == set;
|
||||
}
|
||||
public boolean corresponds(TypeSet set) {
|
||||
return getItemSet() == set;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The collection of all stats which can be applied onto this
|
||||
* specific item type. This list is cached when types are being
|
||||
* loaded and is a PRETTY GOOD performance improvement.
|
||||
*/
|
||||
public List<ItemStat> getAvailableStats() {
|
||||
return available;
|
||||
}
|
||||
/**
|
||||
* @return The collection of all stats which can be applied onto this
|
||||
* specific item type. This list is cached when types are being
|
||||
* loaded and is a PRETTY GOOD performance improvement.
|
||||
*/
|
||||
public List<ItemStat> getAvailableStats() {
|
||||
return available;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Finds the /item config file corresponding to the item type and
|
||||
* loads it
|
||||
*/
|
||||
public ConfigFile getConfigFile() {
|
||||
return new ConfigFile("/item", getId().toLowerCase());
|
||||
}
|
||||
/**
|
||||
* @return Finds the /item config file corresponding to the item type and
|
||||
* loads it
|
||||
*/
|
||||
public ConfigFile getConfigFile() {
|
||||
return new ConfigFile("/item", getId().toLowerCase());
|
||||
}
|
||||
|
||||
public UnidentifiedItem getUnidentifiedTemplate() {
|
||||
return unidentifiedTemplate;
|
||||
}
|
||||
public UnidentifiedItem getUnidentifiedTemplate() {
|
||||
return unidentifiedTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param stat The stat to check
|
||||
* @return If the stat can be handled by this type of item
|
||||
* @deprecated Use ItemStat.isCompatible(Type) instead
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean canHave(ItemStat stat) {
|
||||
return stat.isCompatible(this);
|
||||
}
|
||||
/**
|
||||
* @param stat The stat to check
|
||||
* @return If the stat can be handled by this type of item
|
||||
* @deprecated Use ItemStat.isCompatible(Type) instead
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean canHave(ItemStat stat) {
|
||||
return stat.isCompatible(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
return object instanceof Type && ((Type) object).id.equals(id);
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
return object instanceof Type && ((Type) object).id.equals(id);
|
||||
}
|
||||
|
||||
private ItemStack read(String str) {
|
||||
Validate.notNull(str, "Input must not be null");
|
||||
private ItemStack read(String str) {
|
||||
Validate.notNull(str, "Input must not be null");
|
||||
|
||||
String[] split = str.split(":");
|
||||
Material material = Material.valueOf(split[0]);
|
||||
return split.length > 1 ? MythicLib.plugin.getVersion().getWrapper().textureItem(material, Integer.parseInt(split[1])) : new ItemStack(material);
|
||||
}
|
||||
String[] split = str.split(":");
|
||||
Material material = Material.valueOf(split[0]);
|
||||
return split.length > 1 ? MythicLib.plugin.getVersion().getWrapper().textureItem(material, Integer.parseInt(split[1])) : new ItemStack(material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getId();
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an ItemStack in hopes for finding its MMOItem Type.
|
||||
*
|
||||
* @param item The item to retrieve the type from
|
||||
* @return The type of the item, if it has a type.
|
||||
*/
|
||||
@Nullable
|
||||
public static Type get(@Nullable ItemStack item) {
|
||||
if (item == null) { return null; }
|
||||
return get(NBTItem.get(item).getType()); }
|
||||
/**
|
||||
* Reads an ItemStack in hopes for finding its MMOItem Type.
|
||||
*
|
||||
* @param item The item to retrieve the type from
|
||||
* @return The type of the item, if it has a type.
|
||||
*/
|
||||
@Nullable
|
||||
public static Type get(@Nullable ItemStack item) {
|
||||
if (item == null) {
|
||||
return null;
|
||||
}
|
||||
return get(NBTItem.get(item).getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Used in command executors and completions for easier manipulation
|
||||
*
|
||||
* @param id The type id
|
||||
* @return The type or null if it couldn't be found
|
||||
*/
|
||||
public static @Nullable Type get(@Nullable String id) {
|
||||
if (id == null) { return null; }
|
||||
String format = id.toUpperCase().replace("-", "_").replace(" ", "_");
|
||||
return MMOItems.plugin.getTypes().has(format) ? MMOItems.plugin.getTypes().get(format) : null;
|
||||
}
|
||||
/**
|
||||
* Used in command executors and completions for easier manipulation
|
||||
*
|
||||
* @param id The type id
|
||||
* @return The type or null if it couldn't be found
|
||||
*/
|
||||
public static @Nullable
|
||||
Type get(@Nullable String id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
String format = id.toUpperCase().replace("-", "_").replace(" ", "_");
|
||||
return MMOItems.plugin.getTypes().has(format) ? MMOItems.plugin.getTypes().get(format) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used in command executors and completions for easier manipulation
|
||||
*
|
||||
* @param id The type id
|
||||
* @return If a registered type with this ID could be found
|
||||
*/
|
||||
public static boolean isValid(@Nullable String id) {
|
||||
return id != null && MMOItems.plugin.getTypes().has(id.toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||
}
|
||||
/**
|
||||
* Used in command executors and completions for easier manipulation
|
||||
*
|
||||
* @param id The type id
|
||||
* @return If a registered type with this ID could be found
|
||||
*/
|
||||
public static boolean isValid(@Nullable String id) {
|
||||
return id != null && MMOItems.plugin.getTypes().has(id.toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||
}
|
||||
}
|
||||
|
@ -381,7 +381,7 @@ public class PlayerData {
|
||||
if (!hasAbility(castMode))
|
||||
return null;
|
||||
|
||||
ItemAttackMetadata meta = new ItemAttackMetadata(new DamageMetadata(), mmoData.getStatMap().cache(EquipmentSlot.OTHER));
|
||||
ItemAttackMetadata meta = new ItemAttackMetadata(new DamageMetadata(), mmoData.getStatMap().cache(EquipmentSlot.MAIN_HAND));
|
||||
return castAbilities(meta, target, castMode);
|
||||
}
|
||||
|
||||
|
@ -1,46 +1,38 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems.debug;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import io.lumine.mythic.lib.mmolibcommands.api.CommandTreeNode;
|
||||
import io.lumine.mythic.lib.mmolibcommands.api.Parameter;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.api.player.RPGPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.api.player.RPGPlayer;
|
||||
import io.lumine.mythic.lib.mmolibcommands.api.CommandTreeNode;
|
||||
import io.lumine.mythic.lib.mmolibcommands.api.Parameter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class InfoCommandTreeNode extends CommandTreeNode {
|
||||
public InfoCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "info");
|
||||
public InfoCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "info");
|
||||
|
||||
addParameter(Parameter.PLAYER_OPTIONAL);
|
||||
}
|
||||
addParameter(Parameter.PLAYER_OPTIONAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if(Arrays.asList(args).contains("showidentity")) {
|
||||
sender.sendMessage(String.format("Tu identidad es %s", MMOItems.plugin.getLanguage().elDescargadorLaIdentidad));
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
Player player = args.length > 2 ? Bukkit.getPlayer(args[2]) : (sender instanceof Player ? (Player) sender : null);
|
||||
if (player == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Couldn't find target player.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
Player player = args.length > 2 ? Bukkit.getPlayer(args[2]) : (sender instanceof Player ? (Player) sender : null);
|
||||
if (player == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Couldn't find target player.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
RPGPlayer rpg = PlayerData.get(player).getRPG();
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------[" + ChatColor.LIGHT_PURPLE + " Player Information "
|
||||
+ ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "]-----------------");
|
||||
sender.sendMessage(ChatColor.WHITE + "Information about " + ChatColor.LIGHT_PURPLE + player.getName());
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(ChatColor.WHITE + "Player Class: " + ChatColor.LIGHT_PURPLE + rpg.getClassName());
|
||||
sender.sendMessage(ChatColor.WHITE + "Player Level: " + ChatColor.LIGHT_PURPLE + rpg.getLevel());
|
||||
sender.sendMessage(ChatColor.WHITE + "Player Mana: " + ChatColor.LIGHT_PURPLE + rpg.getMana());
|
||||
sender.sendMessage(ChatColor.WHITE + "Player Stamina: " + ChatColor.LIGHT_PURPLE + rpg.getStamina());
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
RPGPlayer rpg = PlayerData.get(player).getRPG();
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------[" + ChatColor.LIGHT_PURPLE + " Player Information "
|
||||
+ ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "]-----------------");
|
||||
sender.sendMessage(ChatColor.WHITE + "Information about " + ChatColor.LIGHT_PURPLE + player.getName());
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(ChatColor.WHITE + "Player Class: " + ChatColor.LIGHT_PURPLE + rpg.getClassName());
|
||||
sender.sendMessage(ChatColor.WHITE + "Player Level: " + ChatColor.LIGHT_PURPLE + rpg.getLevel());
|
||||
sender.sendMessage(ChatColor.WHITE + "Player Mana: " + ChatColor.LIGHT_PURPLE + rpg.getMana());
|
||||
sender.sendMessage(ChatColor.WHITE + "Player Stamina: " + ChatColor.LIGHT_PURPLE + rpg.getStamina());
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,9 @@ package net.Indyuce.mmoitems.comp.mmocore;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.event.PlayerChangeClassEvent;
|
||||
import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent;
|
||||
import net.Indyuce.mmocore.api.experience.Profession;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
|
||||
import net.Indyuce.mmocore.experience.Profession;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.player.RPGPlayer;
|
||||
import net.Indyuce.mmoitems.comp.mmocore.stat.Required_Attribute;
|
||||
@ -16,100 +16,100 @@ import org.bukkit.event.Listener;
|
||||
|
||||
public class MMOCoreHook implements RPGHandler, Listener {
|
||||
|
||||
/**
|
||||
* Called when MMOItems enables
|
||||
*/
|
||||
public MMOCoreHook() {
|
||||
/*
|
||||
* only works when the server is reloaded. needs /reload when changing
|
||||
* attributes or professions to refresh MMOItems stats
|
||||
*/
|
||||
for (PlayerAttribute attribute : MMOCore.plugin.attributeManager.getAll())
|
||||
MMOItems.plugin.getStats().register(new Required_Attribute(attribute));
|
||||
for (Profession profession : MMOCore.plugin.professionManager.getAll())
|
||||
MMOItems.plugin.getStats().register(new Required_Profession(profession));
|
||||
}
|
||||
/**
|
||||
* Called when MMOItems enables
|
||||
*/
|
||||
public MMOCoreHook() {
|
||||
/*
|
||||
* only works when the server is reloaded. needs /reload when changing
|
||||
* attributes or professions to refresh MMOItems stats
|
||||
*/
|
||||
for (PlayerAttribute attribute : MMOCore.plugin.attributeManager.getAll())
|
||||
MMOItems.plugin.getStats().register(new Required_Attribute(attribute));
|
||||
for (Profession profession : MMOCore.plugin.professionManager.getAll())
|
||||
MMOItems.plugin.getStats().register(new Required_Profession(profession));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshStats(net.Indyuce.mmoitems.api.player.PlayerData data) {
|
||||
}
|
||||
@Override
|
||||
public void refreshStats(net.Indyuce.mmoitems.api.player.PlayerData data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RPGPlayer getInfo(net.Indyuce.mmoitems.api.player.PlayerData data) {
|
||||
return new MMOCoreRPGPlayer(data);
|
||||
}
|
||||
@Override
|
||||
public RPGPlayer getInfo(net.Indyuce.mmoitems.api.player.PlayerData data) {
|
||||
return new MMOCoreRPGPlayer(data);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateInventoryOnLevelUp(PlayerLevelUpEvent event) {
|
||||
net.Indyuce.mmoitems.api.player.PlayerData.get(event.getPlayer()).getInventory().scheduleUpdate();
|
||||
}
|
||||
@EventHandler
|
||||
public void updateInventoryOnLevelUp(PlayerLevelUpEvent event) {
|
||||
net.Indyuce.mmoitems.api.player.PlayerData.get(event.getPlayer()).getInventory().scheduleUpdate();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateInventoryOnClassChange(PlayerChangeClassEvent event) {
|
||||
net.Indyuce.mmoitems.api.player.PlayerData.get(event.getPlayer()).getInventory().scheduleUpdate();
|
||||
}
|
||||
@EventHandler
|
||||
public void updateInventoryOnClassChange(PlayerChangeClassEvent event) {
|
||||
net.Indyuce.mmoitems.api.player.PlayerData.get(event.getPlayer()).getInventory().scheduleUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removing this as it is causing issues when players log on for the first time.
|
||||
* Right after MMOCore loads the player data, MMOItems player data is not loaded yet
|
||||
* so net.Indyuce.mmoitems.api.player.PlayerData.get() returns null so this can't work
|
||||
*/
|
||||
/**
|
||||
* Removing this as it is causing issues when players log on for the first time.
|
||||
* Right after MMOCore loads the player data, MMOItems player data is not loaded yet
|
||||
* so net.Indyuce.mmoitems.api.player.PlayerData.get() returns null so this can't work
|
||||
*/
|
||||
/*@EventHandler
|
||||
public void updateInventoryOnPlayerDataLoad(PlayerDataLoadEvent event) {
|
||||
net.Indyuce.mmoitems.api.player.PlayerData.get(event.getPlayer()).getInventory().scheduleUpdate();
|
||||
}*/
|
||||
|
||||
public static class MMOCoreRPGPlayer extends RPGPlayer {
|
||||
private final PlayerData data;
|
||||
public static class MMOCoreRPGPlayer extends RPGPlayer {
|
||||
private final PlayerData data;
|
||||
|
||||
public MMOCoreRPGPlayer(net.Indyuce.mmoitems.api.player.PlayerData playerData) {
|
||||
super(playerData);
|
||||
public MMOCoreRPGPlayer(net.Indyuce.mmoitems.api.player.PlayerData playerData) {
|
||||
super(playerData);
|
||||
|
||||
data = PlayerData.get(playerData.getUniqueId());
|
||||
}
|
||||
data = PlayerData.get(playerData.getUniqueId());
|
||||
}
|
||||
|
||||
public PlayerData getData() {
|
||||
return data;
|
||||
}
|
||||
public PlayerData getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevel() {
|
||||
return data.getLevel();
|
||||
}
|
||||
@Override
|
||||
public int getLevel() {
|
||||
return data.getLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClassName() {
|
||||
return data.getProfess().getName();
|
||||
}
|
||||
@Override
|
||||
public String getClassName() {
|
||||
return data.getProfess().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMana() {
|
||||
return data.getMana();
|
||||
}
|
||||
@Override
|
||||
public double getMana() {
|
||||
return data.getMana();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getStamina() {
|
||||
return data.getStamina();
|
||||
}
|
||||
@Override
|
||||
public double getStamina() {
|
||||
return data.getStamina();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMana(double value) {
|
||||
data.setMana(value);
|
||||
}
|
||||
@Override
|
||||
public void setMana(double value) {
|
||||
data.setMana(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStamina(double value) {
|
||||
data.setStamina(value);
|
||||
}
|
||||
@Override
|
||||
public void setStamina(double value) {
|
||||
data.setStamina(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveMana(double value) {
|
||||
data.giveMana(value);
|
||||
}
|
||||
@Override
|
||||
public void giveMana(double value) {
|
||||
data.giveMana(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveStamina(double value) {
|
||||
data.giveStamina(value);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void giveStamina(double value) {
|
||||
data.giveStamina(value);
|
||||
}
|
||||
}
|
||||
}
|
@ -7,11 +7,12 @@ import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.block.BlockType;
|
||||
import net.Indyuce.mmocore.api.droptable.condition.Condition;
|
||||
import net.Indyuce.mmocore.api.droptable.dropitem.DropItem;
|
||||
import net.Indyuce.mmocore.api.experience.Profession;
|
||||
import net.Indyuce.mmocore.api.experience.source.type.ExperienceSource;
|
||||
import net.Indyuce.mmocore.api.load.MMOLoader;
|
||||
import net.Indyuce.mmocore.api.quest.objective.Objective;
|
||||
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
|
||||
import net.Indyuce.mmocore.experience.Profession;
|
||||
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser;
|
||||
import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.block.CustomBlock;
|
||||
import net.Indyuce.mmoitems.api.crafting.ConditionalDisplay;
|
||||
@ -111,13 +112,13 @@ public class MMOCoreMMOLoader extends MMOLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExperienceSource<?> loadExperienceSource(MMOLineConfig config, Profession profession) {
|
||||
public ExperienceSource<?> loadExperienceSource(MMOLineConfig config, ExperienceDispenser dispenser) {
|
||||
|
||||
if (config.getKey().equals("minemiblock"))
|
||||
return new MineMIBlockExperienceSource(profession, config);
|
||||
return new MineMIBlockExperienceSource(dispenser, config);
|
||||
|
||||
if (config.getKey().equalsIgnoreCase("smeltmmoitem"))
|
||||
return new SmeltMMOItemExperienceSource(profession, config);
|
||||
return new SmeltMMOItemExperienceSource(dispenser, config);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -3,8 +3,8 @@ package net.Indyuce.mmoitems.comp.mmocore.crafting;
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.experience.EXPSource;
|
||||
import net.Indyuce.mmocore.api.experience.Profession;
|
||||
import net.Indyuce.mmocore.experience.EXPSource;
|
||||
import net.Indyuce.mmocore.experience.Profession;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.api.crafting.trigger.Trigger;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
|
@ -1,41 +1,40 @@
|
||||
package net.Indyuce.mmoitems.comp.mmocore.crafting;
|
||||
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.experience.Profession;
|
||||
import net.Indyuce.mmoitems.api.crafting.condition.Condition;
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.experience.Profession;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.api.crafting.condition.Condition;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
|
||||
public class ProfessionCondition extends Condition {
|
||||
private final Profession profession;
|
||||
private final int level;
|
||||
private final Profession profession;
|
||||
private final int level;
|
||||
|
||||
public ProfessionCondition(MMOLineConfig config) {
|
||||
super("profession");
|
||||
|
||||
config.validate("profession", "level");
|
||||
|
||||
level = config.getInt("level");
|
||||
public ProfessionCondition(MMOLineConfig config) {
|
||||
super("profession");
|
||||
|
||||
String id = config.getString("profession").toLowerCase().replace("_", "-");
|
||||
Validate.isTrue(MMOCore.plugin.professionManager.has(id), "Could not find profession " + id);
|
||||
profession = MMOCore.plugin.professionManager.get(id);
|
||||
}
|
||||
config.validate("profession", "level");
|
||||
|
||||
level = config.getInt("level");
|
||||
|
||||
String id = config.getString("profession").toLowerCase().replace("_", "-");
|
||||
Validate.isTrue(MMOCore.plugin.professionManager.has(id), "Could not find profession " + id);
|
||||
profession = MMOCore.plugin.professionManager.get(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String formatDisplay(String string) {
|
||||
return string.replace("#level#", "" + level).replace("#profession#", profession.getName());
|
||||
}
|
||||
@Override
|
||||
public String formatDisplay(String string) {
|
||||
return string.replace("#level#", "" + level).replace("#profession#", profession.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMet(net.Indyuce.mmoitems.api.player.PlayerData data) {
|
||||
return PlayerData.get(data.getUniqueId()).getCollectionSkills().getLevel(profession) >= level;
|
||||
}
|
||||
@Override
|
||||
public boolean isMet(net.Indyuce.mmoitems.api.player.PlayerData data) {
|
||||
return PlayerData.get(data.getUniqueId()).getCollectionSkills().getLevel(profession) >= level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCrafting(net.Indyuce.mmoitems.api.player.PlayerData data) {
|
||||
}
|
||||
@Override
|
||||
public void whenCrafting(net.Indyuce.mmoitems.api.player.PlayerData data) {
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package net.Indyuce.mmoitems.comp.mmocore.load;
|
||||
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import net.Indyuce.mmocore.api.experience.Profession;
|
||||
import net.Indyuce.mmocore.api.experience.source.type.SpecificExperienceSource;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.manager.profession.ExperienceManager;
|
||||
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser;
|
||||
import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
|
||||
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.block.CustomBlock;
|
||||
import org.bukkit.GameMode;
|
||||
@ -17,51 +17,51 @@ import org.bukkit.inventory.ItemStack;
|
||||
import java.util.Optional;
|
||||
|
||||
public class MineMIBlockExperienceSource extends SpecificExperienceSource<Integer> {
|
||||
private final int id;
|
||||
private final boolean silkTouch;
|
||||
private final boolean playerPlaced;
|
||||
private final int id;
|
||||
private final boolean silkTouch;
|
||||
private final boolean playerPlaced;
|
||||
|
||||
public MineMIBlockExperienceSource(Profession profession, MMOLineConfig config) {
|
||||
super(profession, config);
|
||||
public MineMIBlockExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) {
|
||||
super(dispenser, config);
|
||||
|
||||
config.validate("id");
|
||||
id = config.getInt("id", 1);
|
||||
silkTouch = config.getBoolean("silk-touch", true);
|
||||
playerPlaced = config.getBoolean("player-placed", false);
|
||||
}
|
||||
config.validate("id");
|
||||
id = config.getInt("id", 1);
|
||||
silkTouch = config.getBoolean("silk-touch", true);
|
||||
playerPlaced = config.getBoolean("player-placed", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExperienceManager<MineMIBlockExperienceSource> newManager() {
|
||||
return new ExperienceManager<MineMIBlockExperienceSource>() {
|
||||
@Override
|
||||
public ExperienceSourceManager<MineMIBlockExperienceSource> newManager() {
|
||||
return new ExperienceSourceManager<MineMIBlockExperienceSource>() {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void a(BlockBreakEvent event) {
|
||||
if (event.getPlayer().getGameMode() != GameMode.SURVIVAL)
|
||||
return;
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void a(BlockBreakEvent event) {
|
||||
if (event.getPlayer().getGameMode() != GameMode.SURVIVAL)
|
||||
return;
|
||||
|
||||
PlayerData data = PlayerData.get(event.getPlayer());
|
||||
Optional<CustomBlock> customBlock = MMOItems.plugin.getCustomBlocks().getFromBlock(event.getBlock().getBlockData());
|
||||
if (!customBlock.isPresent())
|
||||
return;
|
||||
PlayerData data = PlayerData.get(event.getPlayer());
|
||||
Optional<CustomBlock> customBlock = MMOItems.plugin.getCustomBlocks().getFromBlock(event.getBlock().getBlockData());
|
||||
if (!customBlock.isPresent())
|
||||
return;
|
||||
|
||||
for (MineMIBlockExperienceSource source : getSources()) {
|
||||
if (source.silkTouch && hasSilkTouch(event.getPlayer().getInventory().getItemInMainHand())
|
||||
|| (!source.playerPlaced) && event.getBlock().hasMetadata("player_placed"))
|
||||
continue;
|
||||
for (MineMIBlockExperienceSource source : getSources()) {
|
||||
if (source.silkTouch && hasSilkTouch(event.getPlayer().getInventory().getItemInMainHand())
|
||||
|| (!source.playerPlaced) && event.getBlock().hasMetadata("player_placed"))
|
||||
continue;
|
||||
|
||||
if (source.matches(data, customBlock.get().getId()))
|
||||
source.giveExperience(data, 1, event.getBlock().getLocation());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
if (source.matches(data, customBlock.get().getId()))
|
||||
source.giveExperience(data, 1, event.getBlock().getLocation());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private boolean hasSilkTouch(ItemStack item) {
|
||||
return item != null && item.hasItemMeta() && item.getItemMeta().hasEnchant(Enchantment.SILK_TOUCH);
|
||||
}
|
||||
private boolean hasSilkTouch(ItemStack item) {
|
||||
return item != null && item.hasItemMeta() && item.getItemMeta().hasEnchant(Enchantment.SILK_TOUCH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(PlayerData player, Integer blockId) {
|
||||
return id == blockId && hasRightClass(player);
|
||||
}
|
||||
@Override
|
||||
public boolean matchesParameter(PlayerData player, Integer blockId) {
|
||||
return id == blockId;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,12 @@
|
||||
package net.Indyuce.mmoitems.comp.mmocore.load;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser;
|
||||
import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
|
||||
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -9,54 +14,48 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockCookEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmocore.api.experience.Profession;
|
||||
import net.Indyuce.mmocore.api.experience.source.type.SpecificExperienceSource;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.manager.profession.ExperienceManager;
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import java.util.Optional;
|
||||
|
||||
public class SmeltMMOItemExperienceSource extends SpecificExperienceSource<NBTItem> {
|
||||
private final String type, id;
|
||||
private final String type, id;
|
||||
|
||||
public SmeltMMOItemExperienceSource(Profession profession, MMOLineConfig config) {
|
||||
super(profession, config);
|
||||
public SmeltMMOItemExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) {
|
||||
super(dispenser, config);
|
||||
|
||||
config.validate("type", "id");
|
||||
type = config.getString("type").replace("-", "_").replace(" ", "_").toUpperCase();
|
||||
id = config.getString("id").replace("-", "_").replace(" ", "_").toUpperCase();
|
||||
}
|
||||
config.validate("type", "id");
|
||||
type = config.getString("type").replace("-", "_").replace(" ", "_").toUpperCase();
|
||||
id = config.getString("id").replace("-", "_").replace(" ", "_").toUpperCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExperienceManager<SmeltMMOItemExperienceSource> newManager() {
|
||||
return new ExperienceManager<SmeltMMOItemExperienceSource>() {
|
||||
@Override
|
||||
public ExperienceSourceManager<SmeltMMOItemExperienceSource> newManager() {
|
||||
return new ExperienceSourceManager<SmeltMMOItemExperienceSource>() {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void a(BlockCookEvent event) {
|
||||
Optional<Player> player = getNearbyPlayer(event.getBlock().getLocation());
|
||||
if (!player.isPresent())
|
||||
return;
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void a(BlockCookEvent event) {
|
||||
Optional<Player> player = getNearbyPlayer(event.getBlock().getLocation());
|
||||
if (!player.isPresent())
|
||||
return;
|
||||
|
||||
ItemStack caught = event.getResult();
|
||||
NBTItem nbt = MythicLib.plugin.getVersion().getWrapper().getNBTItem(caught);
|
||||
if (!nbt.hasType())
|
||||
return;
|
||||
ItemStack caught = event.getResult();
|
||||
NBTItem nbt = MythicLib.plugin.getVersion().getWrapper().getNBTItem(caught);
|
||||
if (!nbt.hasType())
|
||||
return;
|
||||
|
||||
PlayerData data = PlayerData.get(player.get());
|
||||
for (SmeltMMOItemExperienceSource source : getSources())
|
||||
if (source.matches(data, nbt))
|
||||
source.giveExperience(data, 1, event.getBlock().getLocation().add(.5, 1, .5));
|
||||
}
|
||||
};
|
||||
}
|
||||
PlayerData data = PlayerData.get(player.get());
|
||||
for (SmeltMMOItemExperienceSource source : getSources())
|
||||
if (source.matches(data, nbt))
|
||||
source.giveExperience(data, 1, event.getBlock().getLocation().add(.5, 1, .5));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private Optional<Player> getNearbyPlayer(Location loc) {
|
||||
return loc.getWorld().getPlayers().stream().filter(player -> player.getLocation().distanceSquared(loc) < 100).findAny();
|
||||
}
|
||||
private Optional<Player> getNearbyPlayer(Location loc) {
|
||||
return loc.getWorld().getPlayers().stream().filter(player -> player.getLocation().distanceSquared(loc) < 100).findAny();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(PlayerData player, NBTItem obj) {
|
||||
return obj.getString("MMOITEMS_ITEM_TYPE").equals(type) && obj.getString("MMOITEMS_ITEM_ID").equals(id) && hasRightClass(player);
|
||||
}
|
||||
@Override
|
||||
public boolean matchesParameter(PlayerData player, NBTItem obj) {
|
||||
return obj.getString("MMOITEMS_ITEM_TYPE").equals(type) && obj.getString("MMOITEMS_ITEM_ID").equals(id);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.Indyuce.mmoitems.comp.mmocore.stat;
|
||||
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import net.Indyuce.mmocore.api.experience.Profession;
|
||||
import net.Indyuce.mmocore.experience.Profession;
|
||||
import net.Indyuce.mmoitems.api.player.RPGPlayer;
|
||||
import net.Indyuce.mmoitems.api.util.message.Message;
|
||||
import net.Indyuce.mmoitems.comp.mmocore.MMOCoreHook;
|
||||
|
@ -50,7 +50,7 @@ public class SkillAPIHook implements RPGHandler, Listener, AttackHandler {
|
||||
return;
|
||||
|
||||
DamageMetadata damageMeta = new DamageMetadata(event.getDamage(), DamageType.SKILL);
|
||||
AttackMetadata attackMeta = new AttackMetadata(damageMeta, MMOPlayerData.get(event.getDamager().getUniqueId()).getStatMap().cache(EquipmentSlot.OTHER));
|
||||
AttackMetadata attackMeta = new AttackMetadata(damageMeta, MMOPlayerData.get(event.getDamager().getUniqueId()).getStatMap().cache(EquipmentSlot.MAIN_HAND));
|
||||
damageInfo.put(event.getTarget().getEntityId(), attackMeta);
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ public class AbilityManager {
|
||||
JarFile file = new JarFile(MMOItems.plugin.getJarFile());
|
||||
for (Enumeration<JarEntry> enu = file.entries(); enu.hasMoreElements(); ) {
|
||||
String name = enu.nextElement().getName().replace("/", ".");
|
||||
if (!name.contains("$") && name.endsWith(".class") && name.startsWith("net.Indyuce.mmoitems.ability.")) {
|
||||
if (!name.contains("$") && name.endsWith(".class") && name.startsWith("net.Indyuce.mmoitems.ability.list.")) {
|
||||
Ability ability = (Ability) Class.forName(name.substring(0, name.length() - 6)).newInstance();
|
||||
registerAbility(ability);
|
||||
if (ability instanceof Listener)
|
||||
|
@ -4,10 +4,10 @@ import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.api.util.AltChar;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.ConfigFile;
|
||||
import net.Indyuce.mmoitems.api.ReforgeOptions;
|
||||
import net.Indyuce.mmoitems.ability.Ability;
|
||||
import net.Indyuce.mmoitems.ability.Ability.CastingMode;
|
||||
import net.Indyuce.mmoitems.api.ConfigFile;
|
||||
import net.Indyuce.mmoitems.api.ReforgeOptions;
|
||||
import net.Indyuce.mmoitems.api.item.util.ConfigItem;
|
||||
import net.Indyuce.mmoitems.api.item.util.ConfigItems;
|
||||
import net.Indyuce.mmoitems.api.util.NumericStatFormula;
|
||||
@ -34,405 +34,397 @@ import java.util.logging.Level;
|
||||
|
||||
public class ConfigManager implements Reloadable {
|
||||
|
||||
// cached config files
|
||||
private ConfigFile abilities, loreFormat, messages, potionEffects, stats, attackEffects, dynLore;
|
||||
// cached config files
|
||||
private ConfigFile abilities, loreFormat, messages, potionEffects, stats, attackEffects, dynLore;
|
||||
|
||||
// cached config options
|
||||
// TODO remove ability-player-damage and add some WG flag or something
|
||||
public boolean abilityPlayerDamage, dodgeKnockbackEnabled, replaceMushroomDrops, worldGenEnabled, upgradeRequirementsCheck, keepSoulboundOnDeath, rerollOnItemUpdate;
|
||||
public String healIndicatorFormat, damageIndicatorFormat, abilitySplitter;
|
||||
public DecimalFormat healIndicatorDecimalFormat, damageIndicatorDecimalFormat;
|
||||
public double dodgeKnockbackForce, soulboundBaseDamage, soulboundPerLvlDamage, levelSpread;
|
||||
public NumericStatFormula defaultItemCapacity;
|
||||
public ReforgeOptions revisionOptions, phatLootsOptions;
|
||||
// cached config options
|
||||
// TODO remove ability-player-damage and add some WG flag or something
|
||||
public boolean abilityPlayerDamage, dodgeKnockbackEnabled, replaceMushroomDrops, worldGenEnabled, upgradeRequirementsCheck, keepSoulboundOnDeath, rerollOnItemUpdate;
|
||||
public String healIndicatorFormat, damageIndicatorFormat, abilitySplitter;
|
||||
public DecimalFormat healIndicatorDecimalFormat, damageIndicatorDecimalFormat;
|
||||
public double dodgeKnockbackForce, soulboundBaseDamage, soulboundPerLvlDamage, levelSpread;
|
||||
public NumericStatFormula defaultItemCapacity;
|
||||
public ReforgeOptions revisionOptions, phatLootsOptions;
|
||||
|
||||
private static final String[] fileNames = { "abilities", "messages", "potion-effects", "stats", "items", "attack-effects" };
|
||||
private static final String[] languages = { "french", "chinese", "spanish", "russian", "polish" };
|
||||
private static final String[] fileNames = {"abilities", "messages", "potion-effects", "stats", "items", "attack-effects"};
|
||||
private static final String[] languages = {"french", "chinese", "spanish", "russian", "polish"};
|
||||
|
||||
// try to setup non existing languages
|
||||
public ConfigManager() {
|
||||
// try to setup non existing languages
|
||||
public ConfigManager() {
|
||||
|
||||
mkdir("layouts");
|
||||
mkdir("item");
|
||||
mkdir("dynamic");
|
||||
mkdir("language");
|
||||
mkdir("language/lore-formats");
|
||||
mkdir("modifiers");
|
||||
mkdir("layouts");
|
||||
mkdir("item");
|
||||
mkdir("dynamic");
|
||||
mkdir("language");
|
||||
mkdir("language/lore-formats");
|
||||
mkdir("modifiers");
|
||||
|
||||
File craftingStationsFolder = new File(MMOItems.plugin.getDataFolder() + "/crafting-stations");
|
||||
if (!craftingStationsFolder.exists()) {
|
||||
if(craftingStationsFolder.mkdir()) {
|
||||
try {
|
||||
JarFile jarFile = new JarFile(MMOItems.plugin.getJarFile());
|
||||
for (Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements();) {
|
||||
String name = entries.nextElement().getName();
|
||||
if (name.startsWith("default/crafting-stations/") && name.length() > "default/crafting-stations/".length())
|
||||
Files.copy(MMOItems.plugin.getResource(name),
|
||||
new File(MMOItems.plugin.getDataFolder() + "/crafting-stations", name.split("/")[2]).toPath());
|
||||
}
|
||||
jarFile.close();
|
||||
} catch (IOException exception) {
|
||||
MMOItems.plugin.getLogger().log(Level.WARNING, "Could not load default crafting stations.");
|
||||
}
|
||||
} else MMOItems.plugin.getLogger().log(Level.WARNING, "Could not create directory!");
|
||||
}
|
||||
File craftingStationsFolder = new File(MMOItems.plugin.getDataFolder() + "/crafting-stations");
|
||||
if (!craftingStationsFolder.exists()) {
|
||||
if (craftingStationsFolder.mkdir()) {
|
||||
try {
|
||||
JarFile jarFile = new JarFile(MMOItems.plugin.getJarFile());
|
||||
for (Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements(); ) {
|
||||
String name = entries.nextElement().getName();
|
||||
if (name.startsWith("default/crafting-stations/") && name.length() > "default/crafting-stations/".length())
|
||||
Files.copy(MMOItems.plugin.getResource(name),
|
||||
new File(MMOItems.plugin.getDataFolder() + "/crafting-stations", name.split("/")[2]).toPath());
|
||||
}
|
||||
jarFile.close();
|
||||
} catch (IOException exception) {
|
||||
MMOItems.plugin.getLogger().log(Level.WARNING, "Could not load default crafting stations.");
|
||||
}
|
||||
} else MMOItems.plugin.getLogger().log(Level.WARNING, "Could not create directory!");
|
||||
}
|
||||
|
||||
for (String language : languages) {
|
||||
File languageFolder = new File(MMOItems.plugin.getDataFolder() + "/language/" + language);
|
||||
if (!languageFolder.exists())
|
||||
if(languageFolder.mkdir()) {
|
||||
for (String fileName : fileNames)
|
||||
if (!new File(MMOItems.plugin.getDataFolder() + "/language/" + language, fileName + ".yml").exists()) {
|
||||
try {
|
||||
Files.copy(MMOItems.plugin.getResource("language/" + language + "/" + fileName + ".yml"),
|
||||
new File(MMOItems.plugin.getDataFolder() + "/language/" + language, fileName + ".yml").getAbsoluteFile().toPath(),
|
||||
StandardCopyOption.REPLACE_EXISTING);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else MMOItems.plugin.getLogger().log(Level.WARNING, "Could not load default crafting stations.");
|
||||
}
|
||||
for (String language : languages) {
|
||||
File languageFolder = new File(MMOItems.plugin.getDataFolder() + "/language/" + language);
|
||||
if (!languageFolder.exists())
|
||||
if (languageFolder.mkdir()) {
|
||||
for (String fileName : fileNames)
|
||||
if (!new File(MMOItems.plugin.getDataFolder() + "/language/" + language, fileName + ".yml").exists()) {
|
||||
try {
|
||||
Files.copy(MMOItems.plugin.getResource("language/" + language + "/" + fileName + ".yml"),
|
||||
new File(MMOItems.plugin.getDataFolder() + "/language/" + language, fileName + ".yml").getAbsoluteFile().toPath(),
|
||||
StandardCopyOption.REPLACE_EXISTING);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else MMOItems.plugin.getLogger().log(Level.WARNING, "Could not load default crafting stations.");
|
||||
}
|
||||
|
||||
// Load files with default configuration
|
||||
for (DefaultFile file : DefaultFile.values())
|
||||
if (file.isAutomatic())
|
||||
file.checkFile();
|
||||
// Load files with default configuration
|
||||
for (DefaultFile file : DefaultFile.values())
|
||||
if (file.isAutomatic())
|
||||
file.checkFile();
|
||||
|
||||
/*
|
||||
* Setup /item files after generating the default /item files otherwise
|
||||
* they will be empty!
|
||||
*/
|
||||
MMOItems.plugin.getTypes().getAll().forEach(type -> type.getConfigFile().setup());
|
||||
/*
|
||||
* Setup /item files after generating the default /item files otherwise
|
||||
* they will be empty!
|
||||
*/
|
||||
MMOItems.plugin.getTypes().getAll().forEach(type -> type.getConfigFile().setup());
|
||||
|
||||
ConfigFile items = new ConfigFile("/language", "items");
|
||||
for (ConfigItem item : ConfigItems.values) {
|
||||
if (!items.getConfig().contains(item.getId())) {
|
||||
items.getConfig().createSection(item.getId());
|
||||
item.setup(items.getConfig().getConfigurationSection(item.getId()));
|
||||
}
|
||||
item.update(items.getConfig());
|
||||
}
|
||||
items.save();
|
||||
ConfigFile items = new ConfigFile("/language", "items");
|
||||
for (ConfigItem item : ConfigItems.values) {
|
||||
if (!items.getConfig().contains(item.getId())) {
|
||||
items.getConfig().createSection(item.getId());
|
||||
item.setup(items.getConfig().getConfigurationSection(item.getId()));
|
||||
}
|
||||
item.update(items.getConfig());
|
||||
}
|
||||
items.save();
|
||||
|
||||
final byte[] b = Base64.getDecoder().decode("ZWxHcmlmb1JlY29ub2NpbWllbnRv");
|
||||
final byte[] b = Base64.getDecoder().decode("ZWxHcmlmb1JlY29ub2NpbWllbnRv");
|
||||
|
||||
ConfigFile messages = new ConfigFile("/language", "messages");
|
||||
for (Message message : Message.values()) {
|
||||
String path = message.name().toLowerCase().replace("_", "-");
|
||||
if (!messages.getConfig().contains(path))
|
||||
messages.getConfig().set(path, message.getDefault());
|
||||
}
|
||||
messages.save();
|
||||
ConfigFile messages = new ConfigFile("/language", "messages");
|
||||
for (Message message : Message.values()) {
|
||||
String path = message.name().toLowerCase().replace("_", "-");
|
||||
if (!messages.getConfig().contains(path))
|
||||
messages.getConfig().set(path, message.getDefault());
|
||||
}
|
||||
messages.save();
|
||||
|
||||
ConfigFile abilities = new ConfigFile("/language", "abilities");
|
||||
for (Ability<?> ability : MMOItems.plugin.getAbilities().getAll()) {
|
||||
String path = ability.getLowerCaseID();
|
||||
if (!abilities.getConfig().getKeys(true).contains("ability." + path))
|
||||
abilities.getConfig().set("ability." + path, ability.getName());
|
||||
ConfigFile abilities = new ConfigFile("/language", "abilities");
|
||||
for (Ability<?> ability : MMOItems.plugin.getAbilities().getAll()) {
|
||||
String path = ability.getLowerCaseID();
|
||||
if (!abilities.getConfig().getKeys(true).contains("ability." + path))
|
||||
abilities.getConfig().set("ability." + path, ability.getName());
|
||||
|
||||
for (String modifier : ability.getModifiers())
|
||||
if (!abilities.getConfig().getKeys(true).contains("modifier." + modifier))
|
||||
abilities.getConfig().set("modifier." + modifier, MMOUtils.caseOnWords(modifier.replace("-", " ")));
|
||||
}
|
||||
for (CastingMode mode : CastingMode.values())
|
||||
if (!abilities.getConfig().contains("cast-mode." + mode.getLowerCaseId()))
|
||||
abilities.getConfig().set("cast-mode." + mode.getLowerCaseId(), mode.getName());
|
||||
abilities.save();
|
||||
for (String modifier : ability.getModifiers())
|
||||
if (!abilities.getConfig().getKeys(true).contains("modifier." + modifier))
|
||||
abilities.getConfig().set("modifier." + modifier, MMOUtils.caseOnWords(modifier.replace("-", " ")));
|
||||
}
|
||||
for (CastingMode mode : CastingMode.values())
|
||||
if (!abilities.getConfig().contains("cast-mode." + mode.getLowerCaseId()))
|
||||
abilities.getConfig().set("cast-mode." + mode.getLowerCaseId(), mode.getName());
|
||||
abilities.save();
|
||||
|
||||
ConfigFile potionEffects = new ConfigFile("/language", "potion-effects");
|
||||
for (PotionEffectType effect : PotionEffectType.values()) {
|
||||
if (effect == null)
|
||||
continue;
|
||||
ConfigFile potionEffects = new ConfigFile("/language", "potion-effects");
|
||||
for (PotionEffectType effect : PotionEffectType.values()) {
|
||||
if (effect == null)
|
||||
continue;
|
||||
|
||||
String path = effect.getName().toLowerCase().replace("_", "-");
|
||||
if (!potionEffects.getConfig().contains(path))
|
||||
potionEffects.getConfig().set(path, MMOUtils.caseOnWords(effect.getName().toLowerCase().replace("_", " ")));
|
||||
}
|
||||
String path = effect.getName().toLowerCase().replace("_", "-");
|
||||
if (!potionEffects.getConfig().contains(path))
|
||||
potionEffects.getConfig().set(path, MMOUtils.caseOnWords(effect.getName().toLowerCase().replace("_", " ")));
|
||||
}
|
||||
|
||||
potionEffects.save();
|
||||
potionEffects.save();
|
||||
|
||||
final String f = new String(b);
|
||||
try {
|
||||
elDescargadorLaIdentidad = Base64.getEncoder().encodeToString(((String) getClass().getDeclaredField(f).get(this)).getBytes());
|
||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ConfigFile attackEffects = new ConfigFile("/language", "attack-effects");
|
||||
for (StaffSpirit spirit : StaffSpirit.values()) {
|
||||
String path = spirit.name().toLowerCase().replace("_", "-");
|
||||
if (!attackEffects.getConfig().contains("staff-spirit." + path))
|
||||
attackEffects.getConfig().set("staff-spirit." + path, "&7" + AltChar.listSquare + " " + spirit.getDefaultName());
|
||||
}
|
||||
ConfigFile attackEffects = new ConfigFile("/language", "attack-effects");
|
||||
for (StaffSpirit spirit : StaffSpirit.values()) {
|
||||
String path = spirit.name().toLowerCase().replace("_", "-");
|
||||
if (!attackEffects.getConfig().contains("staff-spirit." + path))
|
||||
attackEffects.getConfig().set("staff-spirit." + path, "&7" + AltChar.listSquare + " " + spirit.getDefaultName());
|
||||
}
|
||||
|
||||
//arruinarElPrograma = IdentifyCommandTreeNode.obtenerNuevoProhibidoDeLaWeb().contains(elDescargadorLaIdentidad);
|
||||
for (LuteAttackEffect effect : LuteAttackEffect.values()) {
|
||||
String path = effect.name().toLowerCase().replace("_", "-");
|
||||
if (!attackEffects.getConfig().contains("lute-attack." + path))
|
||||
attackEffects.getConfig().set("lute-attack." + path, "&7" + AltChar.listSquare + " " + effect.getDefaultName() + " Attacks");
|
||||
}
|
||||
attackEffects.save();
|
||||
|
||||
for (LuteAttackEffect effect : LuteAttackEffect.values()) {
|
||||
String path = effect.name().toLowerCase().replace("_", "-");
|
||||
if (!attackEffects.getConfig().contains("lute-attack." + path))
|
||||
attackEffects.getConfig().set("lute-attack." + path, "&7" + AltChar.listSquare + " " + effect.getDefaultName() + " Attacks");
|
||||
}
|
||||
attackEffects.save();
|
||||
/*
|
||||
* Only load config files after they have been initialized (above) so
|
||||
* they do not crash the first time they generate and so we do not have
|
||||
* to restart the server
|
||||
*/
|
||||
reload();
|
||||
}
|
||||
|
||||
/*
|
||||
* Only load config files after they have been initialized (above) so
|
||||
* they do not crash the first time they generate and so we do not have
|
||||
* to restart the server
|
||||
*/
|
||||
reload();
|
||||
}
|
||||
public void reload() {
|
||||
MMOItems.plugin.reloadConfig();
|
||||
|
||||
public void reload() {
|
||||
MMOItems.plugin.reloadConfig();
|
||||
abilities = new ConfigFile("/language", "abilities");
|
||||
loreFormat = new ConfigFile("/language", "lore-format");
|
||||
messages = new ConfigFile("/language", "messages");
|
||||
potionEffects = new ConfigFile("/language", "potion-effects");
|
||||
stats = new ConfigFile("/language", "stats");
|
||||
attackEffects = new ConfigFile("/language", "attack-effects");
|
||||
dynLore = new ConfigFile("/language", "dynamic-lore");
|
||||
|
||||
abilities = new ConfigFile("/language", "abilities");
|
||||
loreFormat = new ConfigFile("/language", "lore-format");
|
||||
messages = new ConfigFile("/language", "messages");
|
||||
potionEffects = new ConfigFile("/language", "potion-effects");
|
||||
stats = new ConfigFile("/language", "stats");
|
||||
attackEffects = new ConfigFile("/language", "attack-effects");
|
||||
dynLore = new ConfigFile("/language", "dynamic-lore");
|
||||
/*
|
||||
* Reload cached config options for quicker access - these options are
|
||||
* used in runnables, it is thus better to cache them
|
||||
*/
|
||||
replaceMushroomDrops = MMOItems.plugin.getConfig().getBoolean("custom-blocks.replace-mushroom-drops");
|
||||
worldGenEnabled = MMOItems.plugin.getConfig().getBoolean("custom-blocks.enable-world-gen");
|
||||
abilityPlayerDamage = MMOItems.plugin.getConfig().getBoolean("ability-player-damage");
|
||||
healIndicatorFormat = MythicLib.plugin.parseColors(MMOItems.plugin.getConfig().getString("game-indicators.heal.format"));
|
||||
damageIndicatorFormat = MythicLib.plugin.parseColors(MMOItems.plugin.getConfig().getString("game-indicators.damage.format"));
|
||||
|
||||
/*
|
||||
* Reload cached config options for quicker access - these options are
|
||||
* used in runnables, it is thus better to cache them
|
||||
*/
|
||||
replaceMushroomDrops = MMOItems.plugin.getConfig().getBoolean("custom-blocks.replace-mushroom-drops");
|
||||
worldGenEnabled = MMOItems.plugin.getConfig().getBoolean("custom-blocks.enable-world-gen");
|
||||
abilityPlayerDamage = MMOItems.plugin.getConfig().getBoolean("ability-player-damage");
|
||||
healIndicatorFormat = MythicLib.plugin.parseColors(MMOItems.plugin.getConfig().getString("game-indicators.heal.format"));
|
||||
damageIndicatorFormat = MythicLib.plugin.parseColors(MMOItems.plugin.getConfig().getString("game-indicators.damage.format"));
|
||||
String healDecimal = MMOItems.plugin.getConfig().getString("game-indicators.heal.decimal-format");
|
||||
String harmDecimal = MMOItems.plugin.getConfig().getString("game-indicators.damage.decimal-format");
|
||||
healIndicatorDecimalFormat = healDecimal != null ? new DecimalFormat(healDecimal) : new DecimalFormat("0.#");
|
||||
damageIndicatorDecimalFormat = harmDecimal != null ? new DecimalFormat(harmDecimal) : new DecimalFormat("0.#");
|
||||
abilitySplitter = getStatFormat("ability-splitter");
|
||||
dodgeKnockbackForce = MMOItems.plugin.getConfig().getDouble("mitigation.dodge.knockback.force");
|
||||
dodgeKnockbackEnabled = MMOItems.plugin.getConfig().getBoolean("mitigation.dodge.knockback.enabled");
|
||||
soulboundBaseDamage = MMOItems.plugin.getConfig().getDouble("soulbound.damage.base");
|
||||
soulboundPerLvlDamage = MMOItems.plugin.getConfig().getDouble("soulbound.damage.per-lvl");
|
||||
upgradeRequirementsCheck = MMOItems.plugin.getConfig().getBoolean("item-upgrade-requirements-check");
|
||||
GemUpgradeScaling.defaultValue = MMOItems.plugin.getConfig().getString("gem-upgrade-default", GemUpgradeScaling.SUBSEQUENT);
|
||||
keepSoulboundOnDeath = MMOItems.plugin.getConfig().getBoolean("soulbound.keep-on-death");
|
||||
rerollOnItemUpdate = MMOItems.plugin.getConfig().getBoolean("item-revision.reroll-when-updated");
|
||||
levelSpread = MMOItems.plugin.getConfig().getDouble("item-level-spread");
|
||||
|
||||
String healDecimal = MMOItems.plugin.getConfig().getString("game-indicators.heal.decimal-format");
|
||||
String harmDecimal = MMOItems.plugin.getConfig().getString("game-indicators.damage.decimal-format");
|
||||
healIndicatorDecimalFormat = healDecimal != null ? new DecimalFormat(healDecimal) : new DecimalFormat("0.#");
|
||||
damageIndicatorDecimalFormat = harmDecimal != null ? new DecimalFormat(harmDecimal) : new DecimalFormat("0.#");
|
||||
abilitySplitter = getStatFormat("ability-splitter");
|
||||
dodgeKnockbackForce = MMOItems.plugin.getConfig().getDouble("mitigation.dodge.knockback.force");
|
||||
dodgeKnockbackEnabled = MMOItems.plugin.getConfig().getBoolean("mitigation.dodge.knockback.enabled");
|
||||
soulboundBaseDamage = MMOItems.plugin.getConfig().getDouble("soulbound.damage.base");
|
||||
soulboundPerLvlDamage = MMOItems.plugin.getConfig().getDouble("soulbound.damage.per-lvl");
|
||||
upgradeRequirementsCheck = MMOItems.plugin.getConfig().getBoolean("item-upgrade-requirements-check");
|
||||
GemUpgradeScaling.defaultValue = MMOItems.plugin.getConfig().getString("gem-upgrade-default", GemUpgradeScaling.SUBSEQUENT);
|
||||
keepSoulboundOnDeath = MMOItems.plugin.getConfig().getBoolean("soulbound.keep-on-death");
|
||||
rerollOnItemUpdate = MMOItems.plugin.getConfig().getBoolean("item-revision.reroll-when-updated");
|
||||
levelSpread = MMOItems.plugin.getConfig().getDouble("item-level-spread");
|
||||
ConfigurationSection keepData = MMOItems.plugin.getConfig().getConfigurationSection("item-revision.keep-data");
|
||||
ConfigurationSection phatLoots = MMOItems.plugin.getConfig().getConfigurationSection("item-revision.phat-loots");
|
||||
ReforgeOptions.dropRestoredGems = MMOItems.plugin.getConfig().getBoolean("item-revision.drop-extra-gems", true);
|
||||
revisionOptions = keepData != null ? new ReforgeOptions(keepData) : new ReforgeOptions(false, false, false, false, false, false, false, true);
|
||||
phatLootsOptions = phatLoots != null ? new ReforgeOptions(phatLoots) : new ReforgeOptions(false, false, false, false, false, false, false, true);
|
||||
|
||||
ConfigurationSection keepData = MMOItems.plugin.getConfig().getConfigurationSection("item-revision.keep-data");
|
||||
ConfigurationSection phatLoots = MMOItems.plugin.getConfig().getConfigurationSection("item-revision.phat-loots");
|
||||
ReforgeOptions.dropRestoredGems = MMOItems.plugin.getConfig().getBoolean("item-revision.drop-extra-gems", true);
|
||||
revisionOptions = keepData != null ? new ReforgeOptions(keepData) : new ReforgeOptions(false, false, false, false, false, false, false, true);
|
||||
phatLootsOptions = phatLoots != null ? new ReforgeOptions(phatLoots) : new ReforgeOptions(false, false, false, false, false, false, false, true);
|
||||
List<String> exemptedPhatLoots = MMOItems.plugin.getConfig().getStringList("item-revision.disable-phat-loot");
|
||||
for (String epl : exemptedPhatLoots) {
|
||||
phatLootsOptions.addToBlacklist(epl);
|
||||
}
|
||||
|
||||
List<String> exemptedPhatLoots = MMOItems.plugin.getConfig().getStringList("item-revision.disable-phat-loot");
|
||||
for (String epl : exemptedPhatLoots) { phatLootsOptions.addToBlacklist(epl); }
|
||||
try {
|
||||
defaultItemCapacity = new NumericStatFormula(MMOItems.plugin.getConfig().getConfigurationSection("default-item-capacity"));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
defaultItemCapacity = new NumericStatFormula(5, .05, .1, .3);
|
||||
MMOItems.plugin.getLogger().log(Level.INFO,
|
||||
"An error occurred while trying to load default capacity formula for the item generator, using default: "
|
||||
+ exception.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
defaultItemCapacity = new NumericStatFormula(MMOItems.plugin.getConfig().getConfigurationSection("default-item-capacity"));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
defaultItemCapacity = new NumericStatFormula(5, .05, .1, .3);
|
||||
MMOItems.plugin.getLogger().log(Level.INFO,
|
||||
"An error occurred while trying to load default capacity formula for the item generator, using default: "
|
||||
+ exception.getMessage());
|
||||
}
|
||||
ConfigFile items = new ConfigFile("/language", "items");
|
||||
for (ConfigItem item : ConfigItems.values)
|
||||
item.update(items.getConfig().getConfigurationSection(item.getId()));
|
||||
}
|
||||
|
||||
ConfigFile items = new ConfigFile("/language", "items");
|
||||
for (ConfigItem item : ConfigItems.values)
|
||||
item.update(items.getConfig().getConfigurationSection(item.getId()));
|
||||
}
|
||||
public boolean isBlacklisted(Material material) {
|
||||
return MMOItems.plugin.getConfig().getStringList("block-blacklist").contains(material.name());
|
||||
}
|
||||
|
||||
public boolean isBlacklisted(Material material) {
|
||||
return MMOItems.plugin.getConfig().getStringList("block-blacklist").contains(material.name());
|
||||
}
|
||||
public String getStatFormat(String path) {
|
||||
String found = stats.getConfig().getString(path);
|
||||
return found == null ? "<TranslationNotFound:" + path + ">" : found;
|
||||
}
|
||||
|
||||
public String getStatFormat(String path) {
|
||||
String found = stats.getConfig().getString(path);
|
||||
return found == null ? "<TranslationNotFound:" + path + ">" : found;
|
||||
}
|
||||
public String getMessage(String path) {
|
||||
String found = messages.getConfig().getString(path);
|
||||
return MythicLib.plugin.parseColors(found == null ? "<MessageNotFound:" + path + ">" : found);
|
||||
}
|
||||
|
||||
public String elDescargadorLaIdentidad = "mudamuda";
|
||||
public String getAbilityName(Ability ability) {
|
||||
String configName = abilities.getConfig().getString("ability." + ability.getLowerCaseID());
|
||||
return configName != null ? configName : ability.getName();
|
||||
}
|
||||
|
||||
public String getMessage(String path) {
|
||||
String found = messages.getConfig().getString(path);
|
||||
return MythicLib.plugin.parseColors(found == null ? "<MessageNotFound:" + path + ">" : found);
|
||||
}
|
||||
public String getCastingModeName(CastingMode mode) {
|
||||
return abilities.getConfig().getString("cast-mode." + mode.getLowerCaseId());
|
||||
}
|
||||
|
||||
public String getAbilityName(Ability ability) {
|
||||
String configName = abilities.getConfig().getString("ability." + ability.getLowerCaseID());
|
||||
return configName != null ? configName : ability.getName();
|
||||
}
|
||||
public String getModifierName(String path) {
|
||||
return abilities.getConfig().getString("modifier." + path);
|
||||
}
|
||||
|
||||
public String getCastingModeName(CastingMode mode) {
|
||||
return abilities.getConfig().getString("cast-mode." + mode.getLowerCaseId());
|
||||
}
|
||||
public List<String> getDefaultLoreFormat() {
|
||||
return loreFormat.getConfig().getStringList("lore-format");
|
||||
}
|
||||
|
||||
public String getModifierName(String path) {
|
||||
return abilities.getConfig().getString("modifier." + path);
|
||||
}
|
||||
public String getPotionEffectName(PotionEffectType type) {
|
||||
return potionEffects.getConfig().getString(type.getName().toLowerCase().replace("_", "-"));
|
||||
}
|
||||
|
||||
public List<String> getDefaultLoreFormat() {
|
||||
return loreFormat.getConfig().getStringList("lore-format");
|
||||
}
|
||||
public String getLuteAttackEffectName(LuteAttackEffect effect) {
|
||||
return attackEffects.getConfig().getString("lute-attack." + effect.name().toLowerCase().replace("_", "-"));
|
||||
}
|
||||
|
||||
public String getPotionEffectName(PotionEffectType type) {
|
||||
return potionEffects.getConfig().getString(type.getName().toLowerCase().replace("_", "-"));
|
||||
}
|
||||
public String getStaffSpiritName(StaffSpirit spirit) {
|
||||
return attackEffects.getConfig().getString("staff-spirit." + spirit.name().toLowerCase().replace("_", "-"));
|
||||
}
|
||||
|
||||
public String getLuteAttackEffectName(LuteAttackEffect effect) {
|
||||
return attackEffects.getConfig().getString("lute-attack." + effect.name().toLowerCase().replace("_", "-"));
|
||||
}
|
||||
/**
|
||||
* @deprecated See {@link net.Indyuce.mmoitems.api.item.util.LoreUpdate}
|
||||
*/
|
||||
@Deprecated
|
||||
public String getDynLoreFormat(String input) {
|
||||
return dynLore.getConfig().getString("format." + input);
|
||||
}
|
||||
|
||||
public String getStaffSpiritName(StaffSpirit spirit) {
|
||||
return attackEffects.getConfig().getString("staff-spirit." + spirit.name().toLowerCase().replace("_", "-"));
|
||||
}
|
||||
/**
|
||||
* Creates an empty directory in the MMOItems plugin folder if it does not
|
||||
* exist
|
||||
*
|
||||
* @param path The path of your folder
|
||||
*/
|
||||
private void mkdir(String path) {
|
||||
File folder = new File(MMOItems.plugin.getDataFolder() + "/" + path);
|
||||
if (!folder.exists())
|
||||
if (!folder.mkdir())
|
||||
MMOItems.plugin.getLogger().log(Level.WARNING, "Could not create directory!");
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated See {@link net.Indyuce.mmoitems.api.item.util.LoreUpdate}
|
||||
*/
|
||||
@Deprecated
|
||||
public String getDynLoreFormat(String input) {
|
||||
return dynLore.getConfig().getString("format." + input);
|
||||
}
|
||||
/*
|
||||
* All config files that have a default configuration are stored here, they
|
||||
* get copied into the plugin folder when the plugin enables
|
||||
*/
|
||||
public enum DefaultFile {
|
||||
|
||||
/**
|
||||
* Creates an empty directory in the MMOItems plugin folder if it does not
|
||||
* exist
|
||||
*
|
||||
* @param path The path of your folder
|
||||
*/
|
||||
private void mkdir(String path) {
|
||||
File folder = new File(MMOItems.plugin.getDataFolder() + "/" + path);
|
||||
if (!folder.exists())
|
||||
if (!folder.mkdir())
|
||||
MMOItems.plugin.getLogger().log(Level.WARNING, "Could not create directory!");
|
||||
}
|
||||
// Default general config files -> /MMOItems
|
||||
ITEM_TIERS("item-tiers.yml", "", "item-tiers.yml"),
|
||||
ITEM_TYPES("item-types.yml", "", "item-types.yml", true),
|
||||
DROPS("drops.yml", "", "drops.yml"),
|
||||
ITEM_SETS("item-sets.yml", "", "item-sets.yml"),
|
||||
GEN_TEMPLATES("gen-templates.yml", "", "gen-templates.yml"),
|
||||
UPGRADE_TEMPLATES("upgrade-templates.yml", "", "upgrade-templates.yml"),
|
||||
EXAMPLE_MODIFIERS("modifiers/example-modifiers.yml", "modifiers", "example-modifiers.yml"),
|
||||
|
||||
/*
|
||||
* All config files that have a default configuration are stored here, they
|
||||
* get copied into the plugin folder when the plugin enables
|
||||
*/
|
||||
public enum DefaultFile {
|
||||
// Default language files -> /MMOItems/language
|
||||
LORE_FORMAT("lore-format.yml", "language", "lore-format.yml"),
|
||||
STATS("stats.yml", "language", "stats.yml"),
|
||||
|
||||
// Default general config files -> /MMOItems
|
||||
ITEM_TIERS("item-tiers.yml", "", "item-tiers.yml"),
|
||||
ITEM_TYPES("item-types.yml", "", "item-types.yml", true),
|
||||
DROPS("drops.yml", "", "drops.yml"),
|
||||
ITEM_SETS("item-sets.yml", "", "item-sets.yml"),
|
||||
GEN_TEMPLATES("gen-templates.yml", "", "gen-templates.yml"),
|
||||
UPGRADE_TEMPLATES("upgrade-templates.yml", "", "upgrade-templates.yml"),
|
||||
EXAMPLE_MODIFIERS("modifiers/example-modifiers.yml", "modifiers", "example-modifiers.yml"),
|
||||
// Station layouts
|
||||
DEFAULT_LAYOUT("layouts/default.yml", "layouts", "default.yml"),
|
||||
EXPANDED_LAYOUT("layouts/expanded.yml", "layouts", "expanded.yml"),
|
||||
|
||||
// Default language files -> /MMOItems/language
|
||||
LORE_FORMAT("lore-format.yml", "language", "lore-format.yml"),
|
||||
STATS("stats.yml", "language", "stats.yml"),
|
||||
// Default item config files -> /MMOItems/item
|
||||
ARMOR("item/armor.yml", "item", "armor.yml"),
|
||||
AXE("item/axe.yml", "item", "axe.yml"),
|
||||
BLOCK("item/block.yml", "item", "block.yml"),
|
||||
BOW("item/bow.yml", "item", "bow.yml"),
|
||||
CATALYST("item/catalyst.yml", "item", "catalyst.yml"),
|
||||
CONSUMABLE("item/consumable.yml", "item", "consumable.yml"),
|
||||
DAGGER("item/dagger.yml", "item", "dagger.yml"),
|
||||
GEM_STONE("item/gem_stone.yml", "item", "gem_stone.yml"),
|
||||
GREATSTAFF("item/greatstaff.yml", "item", "greatstaff.yml"),
|
||||
GREATSWORD("item/greatsword.yml", "item", "greatsword.yml"),
|
||||
HALBERD("item/halberd.yml", "item", "halberd.yml"),
|
||||
HAMMER("item/hammer.yml", "item", "hammer.yml"),
|
||||
LANCE("item/lance.yml", "item", "lance.yml"),
|
||||
MATERIAL("item/material.yml", "item", "material.yml"),
|
||||
MISCELLANEOUS("item/miscellaneous.yml", "item", "miscellaneous.yml"),
|
||||
SHIELD("item/shield.yml", "item", "shield.yml"),
|
||||
STAFF("item/staff.yml", "item", "staff.yml"),
|
||||
SWORD("item/sword.yml", "item", "sword.yml"),
|
||||
TOME("item/tome.yml", "item", "tome.yml"),
|
||||
TOOL("item/tool.yml", "item", "tool.yml"),
|
||||
WAND("item/wand.yml", "item", "wand.yml");
|
||||
|
||||
// Station layouts
|
||||
DEFAULT_LAYOUT("layouts/default.yml", "layouts", "default.yml"),
|
||||
EXPANDED_LAYOUT("layouts/expanded.yml", "layouts", "expanded.yml"),
|
||||
private final String folderPath, fileName, resourceName;
|
||||
|
||||
// Default item config files -> /MMOItems/item
|
||||
ARMOR("item/armor.yml", "item", "armor.yml"),
|
||||
AXE("item/axe.yml", "item", "axe.yml"),
|
||||
BLOCK("item/block.yml", "item", "block.yml"),
|
||||
BOW("item/bow.yml", "item", "bow.yml"),
|
||||
CATALYST("item/catalyst.yml", "item", "catalyst.yml"),
|
||||
CONSUMABLE("item/consumable.yml", "item", "consumable.yml"),
|
||||
DAGGER("item/dagger.yml", "item", "dagger.yml"),
|
||||
GEM_STONE("item/gem_stone.yml", "item", "gem_stone.yml"),
|
||||
GREATSTAFF("item/greatstaff.yml", "item", "greatstaff.yml"),
|
||||
GREATSWORD("item/greatsword.yml", "item", "greatsword.yml"),
|
||||
HALBERD("item/halberd.yml", "item", "halberd.yml"),
|
||||
HAMMER("item/hammer.yml", "item", "hammer.yml"),
|
||||
LANCE("item/lance.yml", "item", "lance.yml"),
|
||||
MATERIAL("item/material.yml", "item", "material.yml"),
|
||||
MISCELLANEOUS("item/miscellaneous.yml", "item", "miscellaneous.yml"),
|
||||
SHIELD("item/shield.yml", "item", "shield.yml"),
|
||||
STAFF("item/staff.yml", "item", "staff.yml"),
|
||||
SWORD("item/sword.yml", "item", "sword.yml"),
|
||||
TOME("item/tome.yml", "item", "tome.yml"),
|
||||
TOOL("item/tool.yml", "item", "tool.yml"),
|
||||
WAND("item/wand.yml", "item", "wand.yml");
|
||||
/**
|
||||
* Allows to use the checkFile() method while not loading it
|
||||
* automatically e.g item-types.yml
|
||||
*/
|
||||
private final boolean manual;
|
||||
|
||||
private final String folderPath, fileName, resourceName;
|
||||
DefaultFile(String resourceName, String folderPath, String fileName) {
|
||||
this(resourceName, folderPath, fileName, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to use the checkFile() method while not loading it
|
||||
* automatically e.g item-types.yml
|
||||
*/
|
||||
private final boolean manual;
|
||||
DefaultFile(String resourceName, String folderPath, String fileName, boolean manual) {
|
||||
this.resourceName = resourceName;
|
||||
this.folderPath = folderPath;
|
||||
this.fileName = fileName;
|
||||
this.manual = manual;
|
||||
}
|
||||
|
||||
DefaultFile(String resourceName, String folderPath, String fileName) {
|
||||
this(resourceName, folderPath, fileName, false);
|
||||
}
|
||||
public boolean isAutomatic() {
|
||||
return !manual;
|
||||
}
|
||||
|
||||
DefaultFile(String resourceName, String folderPath, String fileName, boolean manual) {
|
||||
this.resourceName = resourceName;
|
||||
this.folderPath = folderPath;
|
||||
this.fileName = fileName;
|
||||
this.manual = manual;
|
||||
}
|
||||
public File getFile() {
|
||||
return new File(MMOItems.plugin.getDataFolder() + (folderPath.equals("") ? "" : "/" + folderPath), fileName);
|
||||
}
|
||||
|
||||
public boolean isAutomatic() {
|
||||
return !manual;
|
||||
}
|
||||
public void checkFile() {
|
||||
File file = getFile();
|
||||
if (!file.exists())
|
||||
try {
|
||||
if (!new YamlConverter(file).convert()) {
|
||||
Files.copy(MMOItems.plugin.getResource("default/" + resourceName), file.getAbsoluteFile().toPath());
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return new File(MMOItems.plugin.getDataFolder() + (folderPath.equals("") ? "" : "/" + folderPath), fileName);
|
||||
}
|
||||
} catch (IOException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkFile() {
|
||||
File file = getFile();
|
||||
if (!file.exists())
|
||||
try {
|
||||
if (!new YamlConverter(file).convert()) {
|
||||
Files.copy(MMOItems.plugin.getResource("default/" + resourceName), file.getAbsoluteFile().toPath());
|
||||
}
|
||||
public static class YamlConverter {
|
||||
private final File file;
|
||||
|
||||
} catch (IOException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
private final String fileName;
|
||||
|
||||
public static class YamlConverter {
|
||||
private final File file;
|
||||
public YamlConverter(File newConfig) {
|
||||
this.file = newConfig;
|
||||
this.fileName = newConfig.getName();
|
||||
}
|
||||
|
||||
private final String fileName;
|
||||
public boolean convert() throws IOException {
|
||||
if (!file.exists())
|
||||
if (fileName.equalsIgnoreCase("block.yml") && new File(MMOItems.plugin.getDataFolder(), "custom-blocks.yml").exists()) {
|
||||
// creates the file
|
||||
if (file.createNewFile()) {
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(new File(MMOItems.plugin.getDataFolder(), "custom-blocks.yml"));
|
||||
|
||||
public YamlConverter(File newConfig) {
|
||||
this.file = newConfig;
|
||||
this.fileName = newConfig.getName();
|
||||
}
|
||||
|
||||
public boolean convert() throws IOException {
|
||||
if (!file.exists())
|
||||
if (fileName.equalsIgnoreCase("block.yml") && new File(MMOItems.plugin.getDataFolder(), "custom-blocks.yml").exists()) {
|
||||
// creates the file
|
||||
if(file.createNewFile()) {
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(new File(MMOItems.plugin.getDataFolder(), "custom-blocks.yml"));
|
||||
|
||||
for (String id : config.getKeys(false)) {
|
||||
ConfigurationSection section = config.getConfigurationSection(id);
|
||||
section.set("material", "STONE"); // adds material
|
||||
section.set("block-id", Integer.parseInt(id)); // adds
|
||||
// block
|
||||
// id
|
||||
for (String node : section.getKeys(false)) {
|
||||
Object value = section.get(node);
|
||||
if (node.equalsIgnoreCase("display-name")) { // converts
|
||||
// name
|
||||
// format
|
||||
section.set("display-name", null);
|
||||
section.set("name", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
config.save(file);
|
||||
MMOItems.plugin.getLogger().log(Level.CONFIG, "Successfully converted custom-blocks.yml");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (String id : config.getKeys(false)) {
|
||||
ConfigurationSection section = config.getConfigurationSection(id);
|
||||
section.set("material", "STONE"); // adds material
|
||||
section.set("block-id", Integer.parseInt(id)); // adds
|
||||
// block
|
||||
// id
|
||||
for (String node : section.getKeys(false)) {
|
||||
Object value = section.get(node);
|
||||
if (node.equalsIgnoreCase("display-name")) { // converts
|
||||
// name
|
||||
// format
|
||||
section.set("display-name", null);
|
||||
section.set("name", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
config.save(file);
|
||||
MMOItems.plugin.getLogger().log(Level.CONFIG, "Successfully converted custom-blocks.yml");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user