Packet fixes

This commit is contained in:
BuildTools 2023-08-26 16:57:45 +05:00
parent e48e76e503
commit 2cec377dfd
3 changed files with 22 additions and 12 deletions

View File

@ -55,6 +55,16 @@ public class ExcellentEnchants extends NexPlugin<ExcellentEnchants> {
this.enchantManager = new EnchantManager(this);
this.enchantManager.setup();
if (Config.ENCHANTMENTS_DISPLAY_MODE.get() == 2) {
if (EngineUtils.hasPlugin(HookId.PROTOCOL_LIB)) {
ProtocolHook.setup();
}
else {
this.warn(HookId.PROTOCOL_LIB + " is not installed. Set display mode to Plain lore.");
Config.ENCHANTMENTS_DISPLAY_MODE.set(1);
}
}
}
@Override
@ -104,15 +114,6 @@ public class ExcellentEnchants extends NexPlugin<ExcellentEnchants> {
@Override
public void registerHooks() {
if (Config.ENCHANTMENTS_DISPLAY_MODE.get() == 2) {
if (EngineUtils.hasPlugin(HookId.PROTOCOL_LIB)) {
ProtocolHook.setup();
}
else {
this.warn(HookId.PROTOCOL_LIB + " is not installed. Set display mode to Plain lore.");
Config.ENCHANTMENTS_DISPLAY_MODE.set(1);
}
}
if (EngineUtils.hasPlaceholderAPI()) {
PlaceholderHook.setup();
}

View File

@ -1,5 +1,7 @@
package su.nightexpress.excellentenchants.enchantment.impl.universal;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.Player;
@ -40,6 +42,8 @@ public class SoulboundEnchant extends ExcellentEnchant {
if (deathEvent.getKeepInventory()) return;
List<ItemStack> saveList = new ArrayList<>();
Location location = player.getLocation();
World world = player.getWorld();
deathEvent.getDrops().removeIf(drop -> {
if (EnchantUtils.getLevel(drop, this) > 0) {
@ -55,8 +59,13 @@ public class SoulboundEnchant extends ExcellentEnchant {
this.plugin.runTask(task -> {
saveList.forEach(save -> {
this.consumeCharges(save, EnchantUtils.getLevel(save, this));
player.getInventory().addItem(save);
if (player.getInventory().firstEmpty() == -1) {
world.dropItemNaturally(location, save);
}
else {
this.consumeCharges(save, EnchantUtils.getLevel(save, this));
player.getInventory().addItem(save);
}
});
});
}

View File

@ -78,7 +78,7 @@ public class ProtocolHook {
}
@Nullable
private static ItemStack update(@Nullable ItemStack item, boolean isCreative) {
public static ItemStack update(@Nullable ItemStack item, boolean isCreative) {
if (item == null || item.getType().isAir()) return item;
ItemStack copy = new ItemStack(item);