mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2024-12-23 04:47:34 +01:00
Fixed shield pattern & item cache issue
This commit is contained in:
parent
f9bc8e51be
commit
d48733a360
@ -57,4 +57,10 @@ public class MMOItem {
|
||||
public MMOItemBuilder newBuilder() {
|
||||
return new MMOItemBuilder(this);
|
||||
}
|
||||
|
||||
public MMOItem clone() {
|
||||
MMOItem clone = new MMOItem(type, id);
|
||||
stats.forEach((stat, data) -> clone.stats.put(stat, data));
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,9 @@ public class ItemUse implements Listener {
|
||||
// commands & consummables
|
||||
if (event.getAction().name().contains("RIGHT_CLICK")) {
|
||||
if (!useItem.getPlayerData().canUseItem(useItem.getMMOItem().getId())) {
|
||||
Message.ITEM_ON_COOLDOWN.format(ChatColor.RED, "#left#", digit.format(useItem.getPlayerData().getItemCooldown(useItem.getMMOItem().getId()))).send(player, "item-cooldown");
|
||||
Message.ITEM_ON_COOLDOWN
|
||||
.format(ChatColor.RED, "#left#", digit.format(useItem.getPlayerData().getItemCooldown(useItem.getMMOItem().getId())))
|
||||
.send(player, "item-cooldown");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -96,7 +98,8 @@ public class ItemUse implements Listener {
|
||||
|
||||
if (useItem instanceof UntargetedWeapon) {
|
||||
UntargetedWeapon weapon = (UntargetedWeapon) useItem;
|
||||
if ((event.getAction().name().contains("RIGHT_CLICK") && weapon.getWeaponType() == WeaponType.RIGHT_CLICK) || (event.getAction().name().contains("LEFT_CLICK") && weapon.getWeaponType() == WeaponType.LEFT_CLICK))
|
||||
if ((event.getAction().name().contains("RIGHT_CLICK") && weapon.getWeaponType() == WeaponType.RIGHT_CLICK)
|
||||
|| (event.getAction().name().contains("LEFT_CLICK") && weapon.getWeaponType() == WeaponType.LEFT_CLICK))
|
||||
weapon.untargetedAttack(EquipmentSlot.HAND);
|
||||
}
|
||||
}
|
||||
@ -108,7 +111,8 @@ public class ItemUse implements Listener {
|
||||
* Citizens and Sentinels NPC support; damage = 0 check to ignore safety
|
||||
* checks; check for entity attack
|
||||
*/
|
||||
if (event.getDamage() == 0 || event.getCause() != DamageCause.ENTITY_ATTACK || !(event.getEntity() instanceof LivingEntity) || !(event.getDamager() instanceof Player) || event.getEntity().hasMetadata("NPC") || event.getDamager().hasMetadata("NPC"))
|
||||
if (event.getDamage() == 0 || event.getCause() != DamageCause.ENTITY_ATTACK || !(event.getEntity() instanceof LivingEntity)
|
||||
|| !(event.getDamager() instanceof Player) || event.getEntity().hasMetadata("NPC") || event.getDamager().hasMetadata("NPC"))
|
||||
return;
|
||||
|
||||
// custom damage check
|
||||
@ -292,7 +296,8 @@ public class ItemUse implements Listener {
|
||||
Arrow arrow = (Arrow) event.getProjectile();
|
||||
if (!(item.getStat(ItemStat.ARROW_VELOCITY) <= 0))
|
||||
arrow.setVelocity(arrow.getVelocity().multiply(1 + (item.getStat(ItemStat.ARROW_VELOCITY) / 2)));
|
||||
MMOItems.plugin.getEntities().registerCustomProjectile(item, playerData.getStats().newTemporary(), (Arrow) event.getProjectile(), type != null, event.getForce());
|
||||
MMOItems.plugin.getEntities().registerCustomProjectile(item, playerData.getStats().newTemporary(), (Arrow) event.getProjectile(),
|
||||
type != null, event.getForce());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -11,7 +11,6 @@ import java.util.logging.Level;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -176,7 +175,8 @@ public class UpdaterManager implements Listener {
|
||||
if (did.matches(item))
|
||||
return item.getItem();
|
||||
|
||||
MMOItem newItemMMO = MMOItems.plugin.getItems().getMMOItem(type, id);
|
||||
// (funny bug fix) CLONE THE MMOITEM
|
||||
MMOItem newItemMMO = MMOItems.plugin.getItems().getMMOItem(type, id).clone();
|
||||
|
||||
/*
|
||||
* apply older gem stones, using a light MMOItem so the item does not
|
||||
@ -203,11 +203,8 @@ public class UpdaterManager implements Listener {
|
||||
* remember of ANY enchant on the old item, even the enchants that were
|
||||
* removed!
|
||||
*/
|
||||
if (did.hasOption(KeepOption.KEEP_ENCHANTS)) {
|
||||
Map<Enchantment, Integer> enchants = item.getItem().getItemMeta().getEnchants();
|
||||
for (Enchantment enchant : enchants.keySet())
|
||||
newItemMeta.addEnchant(enchant, enchants.get(enchant), true);
|
||||
}
|
||||
if (did.hasOption(KeepOption.KEEP_ENCHANTS))
|
||||
item.getItem().getItemMeta().getEnchants().forEach((enchant, level) -> newItemMeta.addEnchant(enchant, level, true));
|
||||
|
||||
/*
|
||||
* keepLore is used to save enchants from custom enchants plugins that
|
||||
|
@ -137,7 +137,6 @@ public class UpgradeStat extends ItemStat {
|
||||
|
||||
@Override
|
||||
public void whenDisplayed(List<String> lore, MMOItem mmoitem) {
|
||||
lore.add("");
|
||||
lore.add(ChatColor.YELLOW + AltChar.listDash + " Left click to setup upgrading.");
|
||||
lore.add(ChatColor.YELLOW + AltChar.listDash + " Right click to reset.");
|
||||
}
|
||||
|
@ -31,6 +31,6 @@ public class ShieldPatternData implements StatData {
|
||||
}
|
||||
|
||||
public void addAll(List<Pattern> patterns) {
|
||||
patterns.addAll(patterns);
|
||||
this.patterns.addAll(patterns);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user