mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2024-12-31 06:07:34 +01:00
Abilities issues fixed & deprecated methods replaced
This commit is contained in:
parent
0db2980fda
commit
2ab70183ed
@ -170,7 +170,7 @@ public class DurabilityItem {
|
|||||||
// Play sound when item breaks
|
// Play sound when item breaks
|
||||||
if (isBroken()) {
|
if (isBroken()) {
|
||||||
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1);
|
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1);
|
||||||
PlayerData.get(player).getInventory().scheduleUpdate();
|
PlayerData.get(player).getInventory().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
@ -5,17 +5,15 @@ import net.Indyuce.mmoitems.api.player.PlayerData;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval
|
||||||
/**
|
/**
|
||||||
* TODO
|
* @deprecated Use {@link net.Indyuce.mmoitems.comp.inventory.PlayerInventoryHandler} instead
|
||||||
* <p>
|
|
||||||
* It's one of the most urgent systems to update. Moving everything to a new
|
|
||||||
* class to mark everything that needs to be changed
|
|
||||||
*
|
|
||||||
* @author indyuce
|
|
||||||
*/
|
*/
|
||||||
public class InventoryUpdateHandler {
|
public class InventoryUpdateHandler {
|
||||||
private final PlayerData player;
|
private final PlayerData player;
|
||||||
|
@ -311,9 +311,7 @@ public class PlayerInventoryHandler implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void processNewItem(@NotNull PlayerInventoryImage newImage, @Nullable SlotEquippedItem item, @Nullable VolatileMMOItem newItem) {
|
private void processNewItem(@NotNull PlayerInventoryImage newImage, @Nullable SlotEquippedItem item, @Nullable VolatileMMOItem newItem) {
|
||||||
if (newItem == null || item == null)
|
if (newItem == null || item == null || !item.isPlacementLegal() || !this.data.getRPG().canUse(item.getNBT(), false, false))
|
||||||
return;
|
|
||||||
if (!item.isPlacementLegal() || !this.data.getRPG().canUse(item.getNBT(), false, false))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Cache item and add it to the inventory
|
// Cache item and add it to the inventory
|
||||||
@ -330,7 +328,6 @@ public class PlayerInventoryHandler implements Runnable {
|
|||||||
final ModifierSource source = item.getCached().getType().getModifierSource();
|
final ModifierSource source = item.getCached().getType().getModifierSource();
|
||||||
|
|
||||||
double value = item.getNBT().getStat(stat.getId());
|
double value = item.getNBT().getStat(stat.getId());
|
||||||
|
|
||||||
// Apply hand weapon stat offset
|
// Apply hand weapon stat offset
|
||||||
if (source.isWeapon() && stat instanceof AttackWeaponStat)
|
if (source.isWeapon() && stat instanceof AttackWeaponStat)
|
||||||
value -= ((AttackWeaponStat) stat).getOffset(this.data);
|
value -= ((AttackWeaponStat) stat).getOffset(this.data);
|
||||||
@ -344,8 +341,8 @@ public class PlayerInventoryHandler implements Runnable {
|
|||||||
List<UUID> uuids = new ArrayList<>();
|
List<UUID> uuids = new ArrayList<>();
|
||||||
for (AbilityData abilityData : ((AbilityListData) newItem.getData(ItemStats.ABILITIES)).getAbilities()) {
|
for (AbilityData abilityData : ((AbilityListData) newItem.getData(ItemStats.ABILITIES)).getAbilities()) {
|
||||||
ModifierSource modSource = item.getCached().getType().getModifierSource();
|
ModifierSource modSource = item.getCached().getType().getModifierSource();
|
||||||
PassiveSkill skill = this.data.getMMOPlayerData().getPassiveSkillMap().addModifier(new PassiveSkill("MMOItemsItem", abilityData, item.getSlot(), modSource));
|
PassiveSkill skill = new PassiveSkill("MMOItemsItem", abilityData, item.getSlot(), modSource);
|
||||||
if (skill != null)
|
this.data.getMMOPlayerData().getPassiveSkillMap().addModifier(skill);
|
||||||
uuids.add(skill.getUniqueId());
|
uuids.add(skill.getUniqueId());
|
||||||
}
|
}
|
||||||
newImage.itemAbilities().put(item.getSlotNumber(), uuids);
|
newImage.itemAbilities().put(item.getSlotNumber(), uuids);
|
||||||
|
@ -8,7 +8,6 @@ import org.jetbrains.annotations.ApiStatus;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -66,7 +65,7 @@ public class PlayerMMOInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<EquippedItem> equipped() {
|
public List<EquippedItem> equipped() {
|
||||||
return Collections.unmodifiableList(content);
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerInventoryHandler getHandler() {
|
public PlayerInventoryHandler getHandler() {
|
||||||
|
@ -6,8 +6,8 @@ import io.lumine.mythic.lib.api.player.EquipmentSlot;
|
|||||||
import net.Indyuce.mmoitems.api.Type;
|
import net.Indyuce.mmoitems.api.Type;
|
||||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||||
import net.Indyuce.mmoitems.api.player.inventory.EquippedItem;
|
import net.Indyuce.mmoitems.api.player.inventory.EquippedItem;
|
||||||
import net.Indyuce.mmoitems.comp.inventory.model.SlotEquippedItem;
|
|
||||||
import net.Indyuce.mmoitems.comp.inventory.model.PlayerInventory;
|
import net.Indyuce.mmoitems.comp.inventory.model.PlayerInventory;
|
||||||
|
import net.Indyuce.mmoitems.comp.inventory.model.SlotEquippedItem;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -54,7 +54,7 @@ public class OrnamentPlayerInventory implements PlayerInventory, Listener {
|
|||||||
if (event.getEntityType() == EntityType.PLAYER) {
|
if (event.getEntityType() == EntityType.PLAYER) {
|
||||||
final NBTItem nbt = NBTItem.get(event.getItem().getItemStack());
|
final NBTItem nbt = NBTItem.get(event.getItem().getItemStack());
|
||||||
if (nbt.hasType() && Type.get(nbt.getType()).getSupertype().equals(Type.ORNAMENT))
|
if (nbt.hasType() && Type.get(nbt.getType()).getSupertype().equals(Type.ORNAMENT))
|
||||||
PlayerData.get((Player) event.getEntity()).getInventory().scheduleUpdate();
|
PlayerData.get((Player) event.getEntity()).getInventory().update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,6 +62,6 @@ public class OrnamentPlayerInventory implements PlayerInventory, Listener {
|
|||||||
public void updateOnItemDrop(PlayerDropItemEvent event) {
|
public void updateOnItemDrop(PlayerDropItemEvent event) {
|
||||||
final NBTItem nbt = NBTItem.get(event.getItemDrop().getItemStack());
|
final NBTItem nbt = NBTItem.get(event.getItemDrop().getItemStack());
|
||||||
if (nbt.hasType() && Type.get(nbt.getType()).getSupertype().equals(Type.ORNAMENT))
|
if (nbt.hasType() && Type.get(nbt.getType()).getSupertype().equals(Type.ORNAMENT))
|
||||||
PlayerData.get(event.getPlayer()).updateInventory();
|
PlayerData.get(event.getPlayer()).getInventory().update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,12 +67,12 @@ public class MMOCoreHook implements RPGHandler, Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void updateInventoryOnLevelUp(PlayerLevelUpEvent event) {
|
public void updateInventoryOnLevelUp(PlayerLevelUpEvent event) {
|
||||||
PlayerData.get(event.getPlayer()).getInventory().scheduleUpdate();
|
PlayerData.get(event.getPlayer()).getInventory().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void updateInventoryOnClassChange(PlayerChangeClassEvent event) {
|
public void updateInventoryOnClassChange(PlayerChangeClassEvent event) {
|
||||||
PlayerData.get(event.getPlayer()).getInventory().scheduleUpdate();
|
PlayerData.get(event.getPlayer()).getInventory().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,7 +86,7 @@ public class MMOCoreHook implements RPGHandler, Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void updateInventoryOnLoad(AsyncPlayerDataLoadEvent event) {
|
public void updateInventoryOnLoad(AsyncPlayerDataLoadEvent event) {
|
||||||
if (PlayerData.has(event.getPlayer()))
|
if (PlayerData.has(event.getPlayer()))
|
||||||
PlayerData.get(event.getPlayer()).getInventory().scheduleUpdate();
|
PlayerData.get(event.getPlayer()).getInventory().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MMOCoreRPGPlayer extends RPGPlayer {
|
public static class MMOCoreRPGPlayer extends RPGPlayer {
|
||||||
|
@ -47,7 +47,7 @@ public class AureliumSkillsHook implements RPGHandler, Listener {
|
|||||||
public void a(SkillLevelUpEvent event) {
|
public void a(SkillLevelUpEvent event) {
|
||||||
OfflinePlayer player = event.getPlayer();
|
OfflinePlayer player = event.getPlayer();
|
||||||
if (player.isOnline())
|
if (player.isOnline())
|
||||||
PlayerData.get(player).getInventory().scheduleUpdate();
|
PlayerData.get(player).getInventory().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -12,7 +12,7 @@ public class BattleLevelsHook implements RPGHandler, Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void a(PlayerLevelUpEvent event) {
|
public void a(PlayerLevelUpEvent event) {
|
||||||
PlayerData.get(event.getPlayer()).getInventory().scheduleUpdate();
|
PlayerData.get(event.getPlayer()).getInventory().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -15,7 +15,7 @@ public class DefaultHook implements RPGHandler, Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void a(PlayerLevelChangeEvent event) {
|
public void a(PlayerLevelChangeEvent event) {
|
||||||
PlayerData.get(event.getPlayer()).getInventory().scheduleUpdate();
|
PlayerData.get(event.getPlayer()).getInventory().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -76,7 +76,7 @@ public class HeroesHook implements RPGHandler, Listener, AttackHandler {
|
|||||||
*/
|
*/
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void a(HeroChangeLevelEvent event) {
|
public void a(HeroChangeLevelEvent event) {
|
||||||
PlayerData.get(event.getHero().getPlayer()).getInventory().scheduleUpdate();
|
PlayerData.get(event.getHero().getPlayer()).getInventory().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -85,7 +85,7 @@ public class HeroesHook implements RPGHandler, Listener, AttackHandler {
|
|||||||
*/
|
*/
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void b(ClassChangeEvent event) {
|
public void b(ClassChangeEvent event) {
|
||||||
PlayerData.get(event.getHero().getPlayer()).getInventory().scheduleUpdate();
|
PlayerData.get(event.getHero().getPlayer()).getInventory().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class HeroesPlayer extends RPGPlayer {
|
public static class HeroesPlayer extends RPGPlayer {
|
||||||
|
@ -1,19 +1,16 @@
|
|||||||
package net.Indyuce.mmoitems.comp.rpg;
|
package net.Indyuce.mmoitems.comp.rpg;
|
||||||
|
|
||||||
import net.Indyuce.mmoitems.MMOItems;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.api.ExperienceAPI;
|
import com.gmail.nossr50.api.ExperienceAPI;
|
||||||
import com.gmail.nossr50.api.exceptions.McMMOPlayerNotFoundException;
|
import com.gmail.nossr50.api.exceptions.McMMOPlayerNotFoundException;
|
||||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelDownEvent;
|
import com.gmail.nossr50.events.experience.McMMOPlayerLevelDownEvent;
|
||||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
||||||
|
|
||||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||||
import net.Indyuce.mmoitems.api.player.RPGPlayer;
|
import net.Indyuce.mmoitems.api.player.RPGPlayer;
|
||||||
import net.Indyuce.mmoitems.stat.type.DisableStat;
|
import net.Indyuce.mmoitems.stat.type.DisableStat;
|
||||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
public class McMMOHook implements RPGHandler, Listener {
|
public class McMMOHook implements RPGHandler, Listener {
|
||||||
|
|
||||||
@ -28,12 +25,12 @@ public class McMMOHook implements RPGHandler, Listener {
|
|||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void a(McMMOPlayerLevelUpEvent event) {
|
public void a(McMMOPlayerLevelUpEvent event) {
|
||||||
PlayerData.get(event.getPlayer()).getInventory().scheduleUpdate();
|
PlayerData.get(event.getPlayer()).getInventory().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void b(McMMOPlayerLevelDownEvent event) {
|
public void b(McMMOPlayerLevelDownEvent event) {
|
||||||
PlayerData.get(event.getPlayer()).getInventory().scheduleUpdate();
|
PlayerData.get(event.getPlayer()).getInventory().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -12,7 +12,7 @@ public class McRPGHook implements RPGHandler, Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void a(McRPGPlayerLevelChangeEvent event) {
|
public void a(McRPGPlayerLevelChangeEvent event) {
|
||||||
PlayerData.get(event.getMcRPGPlayer().getOfflineMcRPGPlayer()).getInventory().scheduleUpdate();
|
PlayerData.get(event.getMcRPGPlayer().getOfflineMcRPGPlayer()).getInventory().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,7 +58,7 @@ public class ProSkillAPIHook implements RPGHandler, Listener, AttackHandler {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void b(PlayerLevelUpEvent event) {
|
public void b(PlayerLevelUpEvent event) {
|
||||||
net.Indyuce.mmoitems.api.player.PlayerData.get(event.getPlayerData().getPlayer()).getInventory().scheduleUpdate();
|
net.Indyuce.mmoitems.api.player.PlayerData.get(event.getPlayerData().getPlayer()).getInventory().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,12 +30,12 @@ public class RacesAndClassesHook implements RPGHandler, Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void a(LevelUpEvent event) {
|
public void a(LevelUpEvent event) {
|
||||||
PlayerData.get(event.getPlayer()).getInventory().scheduleUpdate();
|
PlayerData.get(event.getPlayer()).getInventory().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void b(LevelDownEvent event) {
|
public void b(LevelDownEvent event) {
|
||||||
PlayerData.get(event.getPlayer()).getInventory().scheduleUpdate();
|
PlayerData.get(event.getPlayer()).getInventory().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RacePlayer extends RPGPlayer {
|
public static class RacePlayer extends RPGPlayer {
|
||||||
|
@ -58,7 +58,7 @@ public class SkillAPIHook implements RPGHandler, Listener, AttackHandler {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void b(PlayerLevelUpEvent event) {
|
public void b(PlayerLevelUpEvent event) {
|
||||||
net.Indyuce.mmoitems.api.player.PlayerData.get(event.getPlayerData().getPlayer()).getInventory().scheduleUpdate();
|
net.Indyuce.mmoitems.api.player.PlayerData.get(event.getPlayerData().getPlayer()).getInventory().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -16,7 +16,7 @@ public class SkillsHook implements RPGHandler, Listener {
|
|||||||
public void a(SkillLevelUpEvent event) {
|
public void a(SkillLevelUpEvent event) {
|
||||||
OfflinePlayer player = event.getPlayer();
|
OfflinePlayer player = event.getPlayer();
|
||||||
if (player.isOnline())
|
if (player.isOnline())
|
||||||
PlayerData.get(player).getInventory().scheduleUpdate();
|
PlayerData.get(player).getInventory().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -16,7 +16,7 @@ public class SkillsProHook implements RPGHandler, Listener {
|
|||||||
public void a(SkillLevelUpEvent event) {
|
public void a(SkillLevelUpEvent event) {
|
||||||
OfflinePlayer player = event.getPlayer();
|
OfflinePlayer player = event.getPlayer();
|
||||||
if (player.isOnline())
|
if (player.isOnline())
|
||||||
PlayerData.get(player).getInventory().scheduleUpdate();
|
PlayerData.get(player).getInventory().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -166,7 +166,7 @@ public class PlayerListener implements Listener {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void registerInventoryUpdates1(PlayerSwapHandItemsEvent event) {
|
public void registerInventoryUpdates1(PlayerSwapHandItemsEvent event) {
|
||||||
PlayerData.get(event.getPlayer()).getInventory().scheduleUpdate();
|
PlayerData.get(event.getPlayer()).getInventory().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -180,7 +180,7 @@ public class PlayerListener implements Listener {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void registerInventoryUpdates2(PlayerItemHeldEvent event) {
|
public void registerInventoryUpdates2(PlayerItemHeldEvent event) {
|
||||||
PlayerData.get(event.getPlayer()).getInventory().scheduleUpdate();
|
PlayerData.get(event.getPlayer()).getInventory().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user