mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-01-23 09:41:20 +01:00
hopefully fixed an issue with Heroes
This commit is contained in:
parent
fdc264b07c
commit
ed1c58aae5
@ -53,6 +53,7 @@ public class Consumable extends UseItem {
|
||||
/**
|
||||
* @deprecated Use {@link Consumable#useOnPlayer()}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean useWithoutItem() {
|
||||
return useOnPlayer() == ConsumableConsumeResult.CONSUME;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class HeroesHook implements RPGHandler, Listener, DamageHandler {
|
||||
|
||||
@Override
|
||||
public void refreshStats(PlayerData data) {
|
||||
Hero hero = ((HeroesPlayer) data.getRPG()).hero;
|
||||
Hero hero = Heroes.getInstance().getCharacterManager().getHero(data.getPlayer());
|
||||
hero.removeMaxMana("MMOItems");
|
||||
hero.addMaxMana("MMOItems", (int) data.getStats().getStat(ItemStats.MAX_MANA));
|
||||
}
|
||||
@ -76,41 +76,43 @@ public class HeroesHook implements RPGHandler, Listener, DamageHandler {
|
||||
}
|
||||
|
||||
public static class HeroesPlayer extends RPGPlayer {
|
||||
private final Hero hero;
|
||||
|
||||
public HeroesPlayer(PlayerData playerData) {
|
||||
super(playerData);
|
||||
|
||||
hero = Heroes.getInstance().getCharacterManager().getHero(getPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevel() {
|
||||
Hero hero = Heroes.getInstance().getCharacterManager().getHero(getPlayer());
|
||||
return hero.getHeroLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClassName() {
|
||||
Hero hero = Heroes.getInstance().getCharacterManager().getHero(getPlayer());
|
||||
return hero.getHeroClass().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMana() {
|
||||
Hero hero = Heroes.getInstance().getCharacterManager().getHero(getPlayer());
|
||||
return hero.getMana();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getStamina() {
|
||||
Hero hero = Heroes.getInstance().getCharacterManager().getHero(getPlayer());
|
||||
return hero.getStamina();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMana(double value) {
|
||||
Hero hero = Heroes.getInstance().getCharacterManager().getHero(getPlayer());
|
||||
hero.setMana((int) value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStamina(double value) {
|
||||
Hero hero = Heroes.getInstance().getCharacterManager().getHero(getPlayer());
|
||||
hero.setStamina((int) value);
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ public class RacesAndClassesHook implements RPGHandler, Listener {
|
||||
|
||||
@Override
|
||||
public void refreshStats(PlayerData data) {
|
||||
RaCPlayer info = ((RacePlayer) data.getRPG()).info;
|
||||
RaCPlayer info = RaCPlayerManager.get().getPlayer(data.getUniqueId());
|
||||
info.getManaManager().removeMaxManaBonus("MMOItems");
|
||||
info.getManaManager().addMaxManaBonus("MMOItems", data.getStats().getStat(ItemStats.MAX_MANA));
|
||||
}
|
||||
@ -39,41 +39,43 @@ public class RacesAndClassesHook implements RPGHandler, Listener {
|
||||
}
|
||||
|
||||
public static class RacePlayer extends RPGPlayer {
|
||||
private final RaCPlayer info;
|
||||
|
||||
public RacePlayer(PlayerData playerData) {
|
||||
super(playerData);
|
||||
|
||||
info = RaCPlayerManager.get().getPlayer(playerData.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevel() {
|
||||
RaCPlayer info = RaCPlayerManager.get().getPlayer(getPlayer().getUniqueId());
|
||||
return info.getCurrentLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClassName() {
|
||||
RaCPlayer info = RaCPlayerManager.get().getPlayer(getPlayer().getUniqueId());
|
||||
return info.getclass().getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMana() {
|
||||
RaCPlayer info = RaCPlayerManager.get().getPlayer(getPlayer().getUniqueId());
|
||||
return info.getCurrentMana();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getStamina() {
|
||||
RaCPlayer info = RaCPlayerManager.get().getPlayer(getPlayer().getUniqueId());
|
||||
return info.getPlayer().getFoodLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMana(double value) {
|
||||
RaCPlayer info = RaCPlayerManager.get().getPlayer(getPlayer().getUniqueId());
|
||||
info.getManaManager().fillMana(value - info.getManaManager().getCurrentMana());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStamina(double value) {
|
||||
RaCPlayer info = RaCPlayerManager.get().getPlayer(getPlayer().getUniqueId());
|
||||
info.getPlayer().setFoodLevel((int) value);
|
||||
}
|
||||
}
|
||||
|
@ -61,12 +61,8 @@ public class SkillAPIHook implements RPGHandler, Listener, DamageHandler {
|
||||
}
|
||||
|
||||
public static class SkillAPIPlayer extends RPGPlayer {
|
||||
/*private final PlayerData rpgdata;*/
|
||||
|
||||
public SkillAPIPlayer(net.Indyuce.mmoitems.api.player.PlayerData playerData) {
|
||||
super(playerData);
|
||||
|
||||
/*rpgdata = SkillAPI.getPlayerData(playerData.getPlayer());*/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -292,6 +292,10 @@ public class ItemUse implements Listener {
|
||||
event.getForce());
|
||||
}
|
||||
|
||||
/**
|
||||
* Consumables which can be eaten using the
|
||||
* vanilla eating animation are handled here.
|
||||
*/
|
||||
@EventHandler
|
||||
public void handleVanillaEatenConsumables(PlayerItemConsumeEvent event) {
|
||||
NBTItem item = MythicLib.plugin.getVersion().getWrapper().getNBTItem(event.getItem());
|
||||
@ -305,10 +309,6 @@ public class ItemUse implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Consumables which can be eaten using the
|
||||
* vanilla eating animation are handled here.
|
||||
*/
|
||||
if (useItem instanceof Consumable) {
|
||||
|
||||
if (!useItem.getPlayerData().isOnCooldown(useItem.getMMOItem().getId())) {
|
||||
@ -319,11 +319,18 @@ public class ItemUse implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!((Consumable) useItem).useWithoutItem()) {
|
||||
Consumable.ConsumableConsumeResult result = ((Consumable) useItem).useOnPlayer();
|
||||
|
||||
// No effects are applied and not consumed
|
||||
if (result == Consumable.ConsumableConsumeResult.CANCEL) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Item is not consumed but its effects are applied anyways
|
||||
if (result == Consumable.ConsumableConsumeResult.NOT_CONSUME)
|
||||
event.setCancelled(true);
|
||||
|
||||
useItem.getPlayerData().applyItemCooldown(useItem.getMMOItem().getId(), useItem.getNBTItem().getStat("ITEM_COOLDOWN"));
|
||||
useItem.executeCommands();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user