mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2024-12-22 04:37:42 +01:00
Merge branch '600-unapply-gem-event' into 'master'
UnsocketGemStoneEvent (Fixes #600) Closes #600 See merge request phoenix-dvpmt/mmoitems!80
This commit is contained in:
commit
4556259a6b
@ -0,0 +1,44 @@
|
||||
package net.Indyuce.mmoitems.api.event.item;
|
||||
|
||||
import net.Indyuce.mmoitems.api.event.PlayerDataEvent;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class UnsocketGemStoneEvent extends PlayerDataEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private final VolatileMMOItem consumable;
|
||||
private final MMOItem targetItem;
|
||||
|
||||
/**
|
||||
* Called when a player tries to un-socket a gem stone onto an item, default via consumable item
|
||||
*
|
||||
* @param playerData Player un-applying the gem stone
|
||||
* @param consumable Consumable item being applied
|
||||
* @param targetItem Item on which the consumable item is being applied
|
||||
*/
|
||||
public UnsocketGemStoneEvent(PlayerData playerData, VolatileMMOItem consumable, MMOItem targetItem) {
|
||||
super(playerData);
|
||||
|
||||
this.consumable = consumable;
|
||||
this.targetItem = targetItem;
|
||||
}
|
||||
|
||||
public VolatileMMOItem getConsumable() {
|
||||
return consumable;
|
||||
}
|
||||
|
||||
public MMOItem getTargetItem() {
|
||||
return targetItem;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -4,8 +4,8 @@ import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
|
||||
import net.Indyuce.mmoitems.ItemStats;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.util.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.event.item.UnsocketGemStoneEvent;
|
||||
import net.Indyuce.mmoitems.api.interaction.Consumable;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
||||
@ -18,7 +18,9 @@ import net.Indyuce.mmoitems.stat.data.GemstoneData;
|
||||
import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction;
|
||||
import net.Indyuce.mmoitems.stat.type.DoubleStat;
|
||||
import net.Indyuce.mmoitems.stat.type.StatHistory;
|
||||
import net.Indyuce.mmoitems.util.MMOUtils;
|
||||
import net.Indyuce.mmoitems.util.Pair;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -83,6 +85,11 @@ public class RandomUnsocket extends DoubleStat implements ConsumableItemInteract
|
||||
int s = 1; if (unsocket != null) { s = SilentNumbers.floor(unsocket.getValue()); }
|
||||
//GEM//for (String str : SilentNumbers.transcribeList(mmoGemStones, (lam) -> "\u00a73Found \u00a77 " + ((MMOItem) lam).getType().getId() + " " + ((MMOItem) lam).getId() )) { MMOItems.log(str); };
|
||||
|
||||
// Remove when call event successfully
|
||||
UnsocketGemStoneEvent unsocketGemStoneEvent = new UnsocketGemStoneEvent(playerData, consumableVol, mmo);
|
||||
Bukkit.getServer().getPluginManager().callEvent(unsocketGemStoneEvent);
|
||||
if (unsocketGemStoneEvent.isCancelled()) return false;
|
||||
|
||||
// Drop gemstones to the ground :0
|
||||
ArrayList<ItemStack> items2Drop = new ArrayList<>();
|
||||
while (s > 0 && mmoGemStones.size() > 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user