Fixed dual wielding bis

This commit is contained in:
Indyuce 2021-06-19 22:16:31 +02:00
parent efaa1f92aa
commit 36c90b766e
5 changed files with 19 additions and 36 deletions

View File

@ -33,8 +33,8 @@ public class Type {
// 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.MAIN_HAND);
public static final Type CROSSBOW = new Type(TypeSet.RANGE, "CROSSBOW", false, 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);

View File

@ -32,7 +32,6 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
@ -182,35 +181,21 @@ public class PlayerData {
* the updateEffects() method
*/
fullHands = areHandsFull();
//region EquipmentSlot mainheld_type = [equipment Type of whatever the player is holding]
EquipmentSlot mainheld_type = null;
ItemStack mainheld = getPlayer().getInventory().getItemInMainHand();
if (mainheld.getType().isItem()) {
NBTItem mainnbt = MythicLib.plugin.getVersion().getWrapper().getNBTItem(mainheld);
if (mainnbt != null) {
Type maintype = Type.get(mainnbt.getType());
if (maintype != null) {
mainheld_type = maintype.getEquipmentType();
}
}
}
//endregion
/*
* Find all the items the player can actually use
*/
for (EquippedItem item : MMOItems.plugin.getInventory().getInventory(getPlayer())) {
NBTItem nbtItem = item.getItem();
Type type = Type.get(nbtItem.getType());
if (nbtItem.getItem() == null || nbtItem.getItem().getType() == Material.AIR)
continue;
/*
* If the item is a custom item, apply slot and item use
* restrictions (items which only work in a specific equipment slot)
*/
if (type != null && (!item.matches(type) || !getRPG().canUse(nbtItem, false, false)))
Type type = Type.get(nbtItem.getType());
if (type == null || !item.matches(type) || !getRPG().canUse(nbtItem, false, false))
continue;
inventory.getEquipped().add(new EquippedPlayerItem(item));

View File

@ -70,7 +70,7 @@ public class PlayerStats {
* at least one item which grants this stat the final value must be lowered
* by a flat amount
*/
boolean mainHand = false;
boolean isHoldingWeapon = false;
/**
* The index of the mmoitem stat modifier being added
@ -85,12 +85,12 @@ public class PlayerStats {
ModifierSource source = type == null ? ModifierSource.OTHER : type.getItemSet().getModifierSource();
packet.addModifier("MMOItem-" + index++, new StatModifier(value, ModifierType.FLAT, item.getSlot(), source));
if (!mainHand && item.getSlot() == EquipmentSlot.MAIN_HAND)
mainHand = true;
if (!isHoldingWeapon && item.getSlot().isHand())
isHoldingWeapon = true;
}
}
if (mainHand && stat instanceof AttributeStat)
if (isHoldingWeapon && stat instanceof AttributeStat)
packet.addModifier("MMOItemOffset", new StatModifier(-((AttributeStat) stat).getOffset()));
/**
@ -100,7 +100,6 @@ public class PlayerStats {
}
}
public class CachedStats {
private final Player player;
private final Map<String, Double> stats = new HashMap<>();
@ -135,12 +134,6 @@ public class PlayerStats {
this.stats.put(ins.getStat(), ins.getTotal());
}
/*public CachedStats() {
player = playerData.getPlayer();
for (StatInstance ins : getMap().getInstances())
this.stats.put(ins.getStat(), ins.getTotal());
}*/
public PlayerData getData() {
return playerData;
}

View File

@ -47,7 +47,12 @@ public class EquippedItem {
* An <code>OFF_CATALYST</code> may only add in the <code>OFFHAND</code>, and such.
*/
public boolean matches(@NotNull Type type) {
return slot == EquipmentSlot.ANY || (type.getEquipmentType() == EquipmentSlot.BOTH_HANDS ? slot.isHand()
: slot == EquipmentSlot.BOTH_HANDS ? type.getEquipmentType().isHand() : slot == type.getEquipmentType());
if (slot == EquipmentSlot.ANY)
return true;
if (type.getEquipmentType() == EquipmentSlot.BOTH_HANDS)
return slot.isHand();
return slot == type.getEquipmentType();
}
}

View File

@ -1,13 +1,13 @@
package net.Indyuce.mmoitems.manager;
import io.lumine.mythic.lib.api.DamageType;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ArrowParticles;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ProjectileData;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import io.lumine.mythic.lib.api.DamageType;
import io.lumine.mythic.lib.api.item.NBTItem;
import org.bukkit.Bukkit;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Arrow;