Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/net/Indyuce/mmoitems/manager/EntityManager.java
This commit is contained in:
Jules 2022-02-09 20:08:42 +01:00
commit c19f612928
8 changed files with 56 additions and 14 deletions

View File

@ -141,7 +141,7 @@
<dependency>
<groupId>io.lumine</groupId>
<artifactId>MythicLib-dist</artifactId>
<version>1.3-R27-SNAPSHOT</version>
<version>1.3-R28-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

View File

@ -151,6 +151,7 @@ public class MMOItems extends LuminePlugin {
public void enable() {
new SpigotPlugin(39267, this).checkForUpdate();
new MMOItemsMetrics();
MMOItemUIFilter.register();
RecipeBrowserGUI.registerNativeRecipes();
skillManager.initialize(false);
@ -215,7 +216,6 @@ public class MMOItems extends LuminePlugin {
if (Bukkit.getPluginManager().getPlugin("PhatLoots") != null) {
Bukkit.getPluginManager().registerEvents(new PhatLootsHook(), this);
}
MMOItemUIFilter.register();
Bukkit.getScheduler().runTaskTimer(this, () -> Bukkit.getOnlinePlayers().forEach(player -> PlayerData.get(player).updateStats()), 100, 20);

View File

@ -17,6 +17,7 @@ import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.Indyuce.mmoitems.stat.type.NameData;
import net.Indyuce.mmoitems.stat.type.StatHistory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
@ -41,12 +42,12 @@ public class MMOItemBuilder {
* have. If no tier is given, item uses the default capacity
* formula given in the main config file
*/
public MMOItemBuilder(MMOItemTemplate template, int level, ItemTier tier) {
public MMOItemBuilder(MMOItemTemplate template, int level, @Nullable ItemTier tier) {
this.level = level;
this.tier = tier;
// Either use provided tier or look into the template base data
tier = tier != null ? tier : template.getBaseItemData().containsKey(ItemStats.TIER) ? MMOItems.plugin.getTiers().getOrThrow(template.getBaseItemData().get(ItemStats.TIER).toString()) : null;
tier = tier != null ? tier : template.getBaseItemData().containsKey(ItemStats.TIER) ? MMOItems.plugin.getTiers().get(template.getBaseItemData().get(ItemStats.TIER).toString()) : null;
// Capacity is not final as it keeps lowering as modifiers are selected
double capacity = (tier != null && tier.hasCapacity() ? tier.getModifierCapacity() : MMOItems.plugin.getLanguage().defaultItemCapacity).calculate(level);

View File

@ -3,6 +3,7 @@ package net.Indyuce.mmoitems.api.item.util.identify;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.io.BukkitObjectInputStream;
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
@ -28,9 +29,25 @@ public class IdentifiedItem {
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
ItemStack item = (ItemStack) dataInput.readObject();
ItemStack stack = (ItemStack) dataInput.readObject();
dataInput.close();
return item;
/*
* For some reason, unidentified items keep having slightly different NBT tags
* than items generated from mob drops or the GUI, I suppose it has to do with
* the serialization-deserialization, It seems to get fixed when rebuilding
* the item stack though.
*
* Its annoying because it prevents stacking.
*/
NBTItem toRebuild = NBTItem.get(stack);
if (toRebuild.hasType()) {
// Rebuild
LiveMMOItem rebuilt = new LiveMMOItem(stack);
return rebuilt.newBuilder().build(); }
return stack;
} catch (ClassNotFoundException | IOException e) {
e.printStackTrace();
return null;

View File

@ -2,6 +2,10 @@ package net.Indyuce.mmoitems.comp.mythicmobs.mechanics;
import io.lumine.mythic.lib.api.crafting.uimanager.ProvidedUIFilter;
import io.lumine.mythic.lib.api.crafting.uimanager.UIFilterManager;
import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackCategory;
import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackMessage;
import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackProvider;
import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
import io.lumine.xikage.mythicmobs.adapters.AbstractEntity;
import io.lumine.xikage.mythicmobs.adapters.AbstractLocation;
import io.lumine.xikage.mythicmobs.adapters.SkillAdapter;
@ -12,6 +16,7 @@ import io.lumine.xikage.mythicmobs.skills.placeholders.parsers.PlaceholderDouble
import io.lumine.xikage.mythicmobs.skills.placeholders.parsers.PlaceholderFloat;
import io.lumine.xikage.mythicmobs.skills.placeholders.parsers.PlaceholderInt;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.util.message.FFPMMOItems;
import net.Indyuce.mmoitems.listener.ItemUse;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -40,7 +45,7 @@ public class MMOItemsArrowVolleyMechanic extends SkillMechanic implements ITarge
@NotNull PlaceholderFloat velocity, scale;
@NotNull PlaceholderDouble xOffset, yOffset, zOffset, fOffset, sOffset;
@Nullable ItemStack arrowItem;
@Nullable ItemStack arrowItem = null;
boolean fullEvent;
boolean scalePerArrow;
boolean fromOrigin;
@ -62,8 +67,11 @@ public class MMOItemsArrowVolleyMechanic extends SkillMechanic implements ITarge
//region Get Arrow Item
String itemFilter = mlc.getString(new String[] {"arrowitem", "item", "ai"}, null);
//DBG//MMOItems.log("Found In Config " + itemFilter);
if (itemFilter != null) {
ProvidedUIFilter uiFilter = UIFilterManager.getUIFilter(itemFilter, null);
//DBG//FriendlyFeedbackProvider ffp = new FriendlyFeedbackProvider(FFPMMOItems.get());
ProvidedUIFilter uiFilter = UIFilterManager.getUIFilter(itemFilter.replace("<&sp>", " ").replace("\"", ""), null);
//DBG//MMOItems.log("Errors Result: " + SilentNumbers.collapseList(SilentNumbers.transcribeList(ffp.getFeedbackOf(FriendlyFeedbackCategory.ERROR), message -> { if (message instanceof FriendlyFeedbackMessage) { return ((FriendlyFeedbackMessage) message).forConsole(FFPMMOItems.get()); } return ""; }), ""));
if (uiFilter != null) {
if (uiFilter.isValid(null) && uiFilter.getParent().fullyDefinesItem()) {
uiFilter.setAmount(1);
@ -71,8 +79,11 @@ public class MMOItemsArrowVolleyMechanic extends SkillMechanic implements ITarge
// Generate Item
arrowItem = uiFilter.getItemStack(null);
}
//DBG// else{ MMOItems.log("Invalid\u00a73 " + uiFilter.toString()); }
}
}
//DBG//MMOItems.log("Generated Item " + SilentNumbers.getItemName(arrowItem));
//endregion
// Offsets
@ -121,6 +132,9 @@ public class MMOItemsArrowVolleyMechanic extends SkillMechanic implements ITarge
public void executeMIVolley(@NotNull SkillCaster caster, @NotNull SkillMetadata data, @NotNull AbstractLocation t, int amount, float velocity, float spread, int fireTicks, int removeDelay, @NotNull PlaceholderFloat statsMultiplier) {
// Cancel infinite loops
if (syncEventBlock) { return; }
// Skill caster MUST be a player
if (!(caster.getEntity().getBukkitEntity() instanceof Player)) { return; }
Player player = (Player) caster.getEntity().getBukkitEntity();
@ -147,6 +161,7 @@ public class MMOItemsArrowVolleyMechanic extends SkillMechanic implements ITarge
// Player bow item is held??
ItemStack bowItem = player.getInventory().getItemInMainHand().clone();
ItemStack localArrowItem = (arrowItem != null ? arrowItem.clone() : new ItemStack(Material.ARROW));
//DBG//MMOItems.log("Deployed Item " + SilentNumbers.getItemName(arrowItem));
ItemUse use = new ItemUse();
// Parse
@ -164,8 +179,10 @@ public class MMOItemsArrowVolleyMechanic extends SkillMechanic implements ITarge
a.setShooter(player);
// Run Event
syncEventBlock = true;
EntityShootBowEvent shootBowEvent = new EntityShootBowEvent(player, bowItem, localArrowItem, a, EquipmentSlot.HAND, arrowForce, false);
if (fullEvent) { Bukkit.getPluginManager().callEvent(shootBowEvent); } else { use.handleCustomBows(shootBowEvent); }
syncEventBlock = false;
// Cancelled???
if (shootBowEvent.isCancelled()) { a.remove(); continue; }
@ -184,4 +201,6 @@ public class MMOItemsArrowVolleyMechanic extends SkillMechanic implements ITarge
Bukkit.getScheduler().scheduleSyncDelayedTask(MMOItems.plugin, () -> {
for (Arrow a : arrowList) { a.remove(); }arrowList.clear(); }, removeDelay);
}
static boolean syncEventBlock = false;
}

View File

@ -100,7 +100,6 @@ public class ItemUse implements Listener {
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)) {
MMOItems.log("Running from \u00a7cUNTARGETTED");
// Run attack event
MMOItemsSpecialWeaponAttack attackEvent = new MMOItemsSpecialWeaponAttack(player, useItem, weapon.untargetedTargetTrace(EquipmentSlot.fromBukkit(event.getHand())));
@ -199,7 +198,7 @@ public class ItemUse implements Listener {
// Special staff attack
if (weapon instanceof Staff) {
MMOItems.log("Running from \u00a7aSTAFF");
// Run attack event
MMOItemsSpecialWeaponAttack attackEvent = new MMOItemsSpecialWeaponAttack(player, weapon, target);
Bukkit.getPluginManager().callEvent(attackEvent);
@ -213,7 +212,6 @@ public class ItemUse implements Listener {
// Special gauntlet attack
if (weapon instanceof Gauntlet) {
MMOItems.log("Running from \u00a7bGAUNTLET");
// Run attack event
MMOItemsSpecialWeaponAttack attackEvent = new MMOItemsSpecialWeaponAttack(player, weapon, target);

View File

@ -7,6 +7,7 @@ import io.lumine.mythic.lib.player.PlayerMetadata;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ElementalAttack;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.event.MMOItemsProjectileFireEvent;
import net.Indyuce.mmoitems.api.interaction.projectile.ArrowParticles;
import net.Indyuce.mmoitems.api.interaction.projectile.EntityData;
import net.Indyuce.mmoitems.api.interaction.projectile.ProjectileData;
@ -22,10 +23,8 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
@ -145,6 +144,12 @@ public class EntityManager implements Listener {
}
event.setDamage(damage);
// Remove projectile if it has no piercing anymore
if (projectile instanceof AbstractArrow) {
if (((AbstractArrow) projectile).getPierceLevel() > 1) { return; } }
unregisterCustomProjectile(projectile);
}
// Unregister custom projectiles from the map

View File

@ -45,7 +45,9 @@ public class ItemSetStat extends StringStat {
// Display in lore
ItemSet set = MMOItems.plugin.getSets().get(data.toString());
item.getLore().insert("set", set.getLoreTag());
// Apply lore
if (set != null) { item.getLore().insert("set", set.getLoreTag()); }
// Add NBT
item.addItemTag(getAppliedNBT(data));