mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2024-12-22 04:37:42 +01:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a284fb1a49
@ -50,8 +50,9 @@ public class ItemStats {
|
||||
DISABLE_ENCHANTING = new DisableStat("ENCHANTING", VersionMaterial.ENCHANTING_TABLE.toMaterial(), "Disable Enchanting", new String[]{"!block", "all"}, "Players can't enchant this item."),
|
||||
DISABLE_REPAIRING = new DisableStat("REPAIRING", Material.ANVIL, "Disable Repairing", new String[]{"!block", "all"}, "Players can't use this item in anvils."),
|
||||
DISABLE_ARROW_SHOOTING = new DisableStat("ARROW_SHOOTING", Material.ARROW, "Disable Arrow Shooting", new Material[]{Material.ARROW}, "Players can't shoot this", "item using a bow."),
|
||||
DISABLE_ATTACK_PASSIVE = new DisableStat("ATTACK_PASSIVE", Material.BARRIER, "Disable Attack Passive", new String[]{"piercing", "slashing", "blunt"}, "Disables the blunt/slashing/piercing", "passive effects on attacks."),
|
||||
DISABLE_DROP = new DisableStat("DROPING", Material.LAVA_BUCKET, "Disable Item Dropping", new String[]{"all"}, "Disables the dropping of this item!"),
|
||||
DISABLE_ARROW_CONSUMPTION = new DisableStat("ARROW_CONSUMPTION", Material.ARROW, "Disable Arrow Consumption", new String[]{"crossbow"}, "Disable arrow requirement and consumption."),
|
||||
DISABLE_ATTACK_PASSIVE = new DisableStat("ATTACK_PASSIVE", Material.BARRIER, "Disable Attack Passive", new String[]{"piercing", "slashing", "blunt"}, "Disable blunt/slashing/piercing", "passive attack effects."),
|
||||
|
||||
// RPG Stats
|
||||
REQUIRED_LEVEL = new RequiredLevel(),
|
||||
@ -205,5 +206,4 @@ public class ItemStats {
|
||||
*/
|
||||
@Deprecated
|
||||
public static final ItemStat DURABILITY = ITEM_DAMAGE;
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -11,8 +11,6 @@ import net.Indyuce.mmoitems.api.event.GenerateLoreEvent;
|
||||
import net.Indyuce.mmoitems.api.event.ItemBuildEvent;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
||||
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
|
||||
import net.Indyuce.mmoitems.stat.DisplayName;
|
||||
import net.Indyuce.mmoitems.stat.Enchants;
|
||||
import net.Indyuce.mmoitems.stat.data.MaterialData;
|
||||
import net.Indyuce.mmoitems.stat.data.StringListData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
@ -137,16 +135,24 @@ public class ItemStackBuilder {
|
||||
* the basis for when an item is 'old'
|
||||
*/
|
||||
if (!builtMMOItem.hasData(ItemStats.ENCHANTS)) {
|
||||
builtMMOItem.setData(ItemStats.ENCHANTS, ItemStats.ENCHANTS.getClearStatData());
|
||||
}
|
||||
builtMMOItem.setData(ItemStats.ENCHANTS, ItemStats.ENCHANTS.getClearStatData()); }
|
||||
//GEM// else {MMOItems.log("\u00a73 -?- \u00a77Apparently found enchantment data \u00a7b" + (mmoitem.getData(ItemStats.ENCHANTS) == null ? "null" : ((EnchantListData) mmoitem.getData(ItemStats.ENCHANTS)).getEnchants().size())); }
|
||||
|
||||
/*
|
||||
* Similar to how enchantments are saved because they can be modified
|
||||
* through non-MMOItems supported sources, the name can be changed in
|
||||
* an anvil, so the very original name must be saved.
|
||||
*/
|
||||
if (!builtMMOItem.hasData(ItemStats.NAME)) {
|
||||
builtMMOItem.setData(ItemStats.NAME, ItemStats.NAME.getClearStatData()); }
|
||||
if (builtMMOItem.getStatHistory(ItemStats.NAME) == null) {
|
||||
StatHistory.from(builtMMOItem, ItemStats.NAME); }
|
||||
|
||||
// For every stat within this item
|
||||
for (ItemStat stat : builtMMOItem.getStats())
|
||||
|
||||
// Attempt to add
|
||||
try {
|
||||
|
||||
//GEM//MMOItems.log("\u00a7e -+- \u00a77Applying \u00a76" + stat.getNBTPath());
|
||||
|
||||
// Does the item have any stat history regarding thay?
|
||||
@ -159,11 +165,11 @@ public class ItemStackBuilder {
|
||||
//GEM//s.log();
|
||||
|
||||
// Recalculate
|
||||
//HSY//MMOItems.log(" \u00a73-\u00a7a- \u00a77ItemStack Building Recalculation \u00a73-\u00a7a-\u00a73-\u00a7a-\u00a73-\u00a7a-\u00a73-\u00a7a-");
|
||||
//GEM//MMOItems.log(" \u00a73-\u00a7a- \u00a77ItemStack Building Recalculation \u00a73-\u00a7a-\u00a73-\u00a7a-\u00a73-\u00a7a-\u00a73-\u00a7a-");
|
||||
builtMMOItem.setData(stat, s.recalculate(l));
|
||||
|
||||
// Add to NBT, if the gemstones were not purged
|
||||
if ((!s.isClear() || stat instanceof Enchants || stat instanceof DisplayName)) {
|
||||
if (!s.isClear()) {
|
||||
|
||||
//GEM//MMOItems.log("\u00a7a -+- \u00a77Recording History");
|
||||
addItemTag(new ItemTag(history_keyword + stat.getId(), s.toNBTString()));
|
||||
|
@ -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) {
|
||||
|
@ -22,6 +22,7 @@ public class MMOItemsBukkit {
|
||||
Bukkit.getPluginManager().registerEvents(new DurabilityListener(), plugin);
|
||||
Bukkit.getPluginManager().registerEvents(new DisableInteractions(), plugin);
|
||||
Bukkit.getPluginManager().registerEvents(new GuiListener(), plugin);
|
||||
Bukkit.getPluginManager().registerEvents(new BiomeChangeListener(), plugin);
|
||||
Bukkit.getPluginManager().registerEvents(new CustomBlockListener(), plugin);
|
||||
if (Bukkit.getPluginManager().getPlugin("PhatLoots") != null)
|
||||
Bukkit.getPluginManager().registerEvents(new PhatLootsHook(), plugin);
|
||||
|
@ -0,0 +1,33 @@
|
||||
package net.Indyuce.mmoitems.listener;
|
||||
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
/**
|
||||
* mmoitems
|
||||
* 19/03/2023
|
||||
*
|
||||
* @author Roch Blondiaux (Kiwix).
|
||||
*/
|
||||
public class BiomeChangeListener implements Listener {
|
||||
|
||||
|
||||
/**
|
||||
* This listener goal is to update the player inventory when he changes biome.
|
||||
*
|
||||
* @param e
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerMove(PlayerMoveEvent e) {
|
||||
if (e.isCancelled() || !PlayerData.has(e.getPlayer()) || (e.getFrom().getBlockX() == e.getTo().getBlockX() && e.getFrom().getBlockZ() == e.getTo().getBlockZ()))
|
||||
return;
|
||||
final Biome lastBiome = e.getFrom().getBlock().getBiome();
|
||||
final Biome biome = e.getTo().getBlock().getBiome();
|
||||
if (biome != lastBiome)
|
||||
PlayerData.get(e.getPlayer()).getInventory().scheduleUpdate();
|
||||
}
|
||||
}
|
@ -22,6 +22,7 @@ import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.inventory.InventoryType.SlotType;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
@ -31,6 +32,15 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class DisableInteractions implements Listener {
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void itemDropping(PlayerDropItemEvent event){
|
||||
ItemStack itemStack = event.getItemDrop().getItemStack();
|
||||
|
||||
if (isDisabled(NBTItem.get(itemStack),"drop")){
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
}
|
||||
@EventHandler
|
||||
public void anvilInteractions(InventoryClickEvent event) {
|
||||
Inventory inv = event.getClickedInventory();
|
||||
|
Loading…
Reference in New Issue
Block a user