don't wipe all the player's enchants when using the item revision system

This commit is contained in:
Ashijin 2020-12-07 01:36:21 -07:00
parent ec4ae923d2
commit 6f040883e7
4 changed files with 11 additions and 3 deletions

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.Indyuce</groupId>
<artifactId>MMOItems</artifactId>
<version>6.5</version>
<version>6.5.1-SNAPSHOT</version>
<name>MMOItems</name>
<description>A great item solution for your RPG server.</description>

View File

@ -77,7 +77,7 @@ public class Bunny_Mode extends Ability {
this.player = player;
Bukkit.getScheduler().runTaskLater(MMOItems.plugin, (@NotNull Runnable) this::close, (long) (duration * 20));
Bukkit.getScheduler().runTaskLater(MMOItems.plugin, (Runnable) this::close, (long) (duration * 20));
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)

View File

@ -11,18 +11,25 @@ import net.Indyuce.mmoitems.api.player.RPGPlayer;
import net.Indyuce.mmoitems.stat.Soulbound;
import net.Indyuce.mmoitems.stat.data.DoubleData;
import net.mmogroup.mmolib.api.item.NBTItem;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class ItemModInstance {
private final NBTItem nbtItem;
private final int amount;
private final Map<Enchantment,Integer> enchantments;
// Not initialized at first for performance reasons
private MMOItem mmoItem;
public ItemModInstance(NBTItem nbt) {
this.nbtItem = nbt;
this.amount = nbt.getItem().getAmount();
this.enchantments = nbt.getItem().getEnchantments();
}
public void applySoulbound(Player p) {
@ -62,6 +69,7 @@ public class ItemModInstance {
public ItemStack toStack() {
ItemStack stack = mmoItem.newBuilder().build();
stack.setAmount(amount);
stack.addUnsafeEnchantments(this.enchantments);
return stack;
}

View File

@ -30,7 +30,7 @@ public abstract class TemporaryListener implements Listener {
* used to close the temporary listener after some delay
*/
public void close(long duration) {
Bukkit.getScheduler().runTaskLater(MMOItems.plugin, (@NotNull Runnable) this::close, duration);
Bukkit.getScheduler().runTaskLater(MMOItems.plugin, (Runnable) this::close, duration);
}
public void close() {