mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2024-12-31 06:07:34 +01:00
Bug fix with the 'Workbench only' upgrade option
This commit is contained in:
parent
e791926ddb
commit
317bd675e3
@ -1,51 +1,68 @@
|
||||
package net.Indyuce.mmoitems.comp.rpg;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.api.player.RPGPlayer;
|
||||
import net.Indyuce.mmoitems.comp.mmocore.MMOCoreHook;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public interface RPGHandler {
|
||||
RPGPlayer getInfo(PlayerData data);
|
||||
|
||||
void refreshStats(PlayerData data);
|
||||
/**
|
||||
* A RPGPlayer is a class used to retrieve all the rpg
|
||||
* information of a player, like its class, level, mana
|
||||
* stamina. It's also used to give or take mana/stamina
|
||||
* to handle ability costs.
|
||||
*
|
||||
* @param data Player to retrieve rpg info from
|
||||
* @return A new RPGPlayer for the given player
|
||||
*/
|
||||
RPGPlayer getInfo(PlayerData data);
|
||||
|
||||
enum PluginEnum {
|
||||
MMOCORE("MMOCore", MMOCoreHook.class),
|
||||
HEROES("Heroes", HeroesHook.class),
|
||||
SKILLAPI("SkillAPI", SkillAPIHook.class),
|
||||
RPGPLAYERLEVELING("RPGPlayerLeveling", RPGPlayerLevelingHook.class),
|
||||
RACESANDCLASSES("RacesAndClasses", RacesAndClassesHook.class),
|
||||
BATTLELEVELS("BattleLevels", BattleLevelsHook.class),
|
||||
MCMMO("mcMMO", McMMOHook.class),
|
||||
MCRPG("McRPG", McRPGHook.class),
|
||||
SKILLS("Skills", SkillsHook.class),
|
||||
AURELIUM_SKILLS("AureliumSkills", AureliumSkillsHook.class),
|
||||
SKILLSPRO("SkillsPro", SkillsProHook.class);
|
||||
/**
|
||||
* Called everytime the player's inventory updates. This
|
||||
* method should update the rpg stats like Max Mana which
|
||||
* are normally given by items.
|
||||
*
|
||||
* @param data Player to update
|
||||
*/
|
||||
void refreshStats(PlayerData data);
|
||||
|
||||
private final Class<? extends RPGHandler> pluginClass;
|
||||
private final String name;
|
||||
enum PluginEnum {
|
||||
MMOCORE("MMOCore", MMOCoreHook.class),
|
||||
HEROES("Heroes", HeroesHook.class),
|
||||
SKILLAPI("SkillAPI", SkillAPIHook.class),
|
||||
RPGPLAYERLEVELING("RPGPlayerLeveling", RPGPlayerLevelingHook.class),
|
||||
RACESANDCLASSES("RacesAndClasses", RacesAndClassesHook.class),
|
||||
BATTLELEVELS("BattleLevels", BattleLevelsHook.class),
|
||||
MCMMO("mcMMO", McMMOHook.class),
|
||||
MCRPG("McRPG", McRPGHook.class),
|
||||
SKILLS("Skills", SkillsHook.class),
|
||||
AURELIUM_SKILLS("AureliumSkills", AureliumSkillsHook.class),
|
||||
SKILLSPRO("SkillsPro", SkillsProHook.class);
|
||||
|
||||
PluginEnum(String name, Class<? extends RPGHandler> pluginClass) {
|
||||
this.pluginClass = pluginClass;
|
||||
this.name = name;
|
||||
}
|
||||
private final Class<? extends RPGHandler> pluginClass;
|
||||
private final String name;
|
||||
|
||||
public RPGHandler load() {
|
||||
try {
|
||||
return pluginClass.getDeclaredConstructor().newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException exception) {
|
||||
MMOItems.plugin.getLogger().log(Level.WARNING,
|
||||
"Could not initialize RPG plugin compatibility with " + name + ": " + exception.getMessage());
|
||||
return new DefaultHook();
|
||||
}
|
||||
}
|
||||
PluginEnum(String name, Class<? extends RPGHandler> pluginClass) {
|
||||
this.pluginClass = pluginClass;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
public RPGHandler load() {
|
||||
try {
|
||||
return pluginClass.getDeclaredConstructor().newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException exception) {
|
||||
MMOItems.plugin.getLogger().log(Level.WARNING,
|
||||
"Could not initialize RPG plugin compatibility with " + name + ": " + exception.getMessage());
|
||||
return new DefaultHook();
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -178,6 +178,9 @@ public class UpgradeStat extends ItemStat implements ConsumableItemInteraction {
|
||||
|
||||
MMOItem targetMMO = new LiveMMOItem(target);
|
||||
UpgradeData targetSharpening = (UpgradeData) targetMMO.getData(ItemStats.UPGRADE);
|
||||
if (targetSharpening.isWorkbench())
|
||||
return false;
|
||||
|
||||
if (!targetSharpening.canLevelUp()) {
|
||||
Message.MAX_UPGRADES_HIT.format(ChatColor.RED).send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2);
|
||||
|
Loading…
Reference in New Issue
Block a user