Merge remote-tracking branch 'origin/master'

This commit is contained in:
Auxilor 2021-11-30 18:55:58 +00:00
commit 7dc1bbbf6b
5 changed files with 81 additions and 0 deletions

View File

@ -0,0 +1,6 @@
group 'com.willfp'
version rootProject.version
dependencies {
compileOnly 'org.spigotmc:spigot:1.18-rc3-R0.1-SNAPSHOT'
}

View File

@ -0,0 +1,25 @@
package com.willfp.ecoenchants.proxy.v1_18_R1;
import com.willfp.ecoenchants.enchantments.support.vanilla.VanillaEnchantmentMetadata;
import com.willfp.ecoenchants.enchantments.support.vanilla.VanillaEnchantments;
import com.willfp.ecoenchants.proxy.proxies.EcoCraftEnchantmentManagerProxy;
import com.willfp.ecoenchants.proxy.v1_18_R1.enchants.EcoCraftEnchantment;
import net.minecraft.core.IRegistry;
import net.minecraft.world.item.enchantment.Enchantment;
import org.bukkit.NamespacedKey;
import org.bukkit.craftbukkit.v1_18_R1.util.CraftNamespacedKey;
import java.util.Map;
public final class EcoCraftEnchantmentManager implements EcoCraftEnchantmentManagerProxy {
@Override
public void registerNewCraftEnchantments() {
Map<org.bukkit.enchantments.Enchantment, VanillaEnchantmentMetadata> metadataMap = VanillaEnchantments.getMetadataMap();
for (Enchantment enchantment : IRegistry.Y) {
NamespacedKey key = CraftNamespacedKey.fromMinecraft(IRegistry.Y.b(enchantment));
VanillaEnchantmentMetadata metadata = metadataMap.get(org.bukkit.enchantments.Enchantment.getByKey(key));
new EcoCraftEnchantment(enchantment, metadata).register();
}
}
}

View File

@ -0,0 +1,13 @@
package com.willfp.ecoenchants.proxy.v1_18_R1;
import com.willfp.ecoenchants.proxy.proxies.OpenInventoryProxy;
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public final class OpenInventory implements OpenInventoryProxy {
@Override
public Object getOpenInventory(@NotNull final Player player) {
return ((CraftPlayer) player).getHandle().bW;
}
}

View File

@ -0,0 +1,36 @@
package com.willfp.ecoenchants.proxy.v1_18_R1.enchants;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.support.vanilla.VanillaEnchantmentMetadata;
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
import net.minecraft.world.item.enchantment.Enchantment;
import org.bukkit.craftbukkit.v1_18_R1.enchantments.CraftEnchantment;
import org.jetbrains.annotations.NotNull;
public class EcoCraftEnchantment extends CraftEnchantment {
private final VanillaEnchantmentMetadata metadata;
public EcoCraftEnchantment(@NotNull final Enchantment target,
@NotNull final VanillaEnchantmentMetadata metadata) {
super(target);
this.metadata = metadata;
}
@Override
public int getMaxLevel() {
return metadata.maxLevel() == null ? this.getHandle().a() : metadata.maxLevel();
}
@Override
public boolean conflictsWith(@NotNull final org.bukkit.enchantments.Enchantment other) {
if (other instanceof EcoEnchant) {
return other.conflictsWith(this);
}
return metadata.conflicts() == null ? super.conflictsWith(other) : metadata.conflicts().contains(other.getKey());
}
public void register() {
EnchantmentUtils.register(this);
}
}

View File

@ -5,6 +5,7 @@ include ':eco-core'
include ':eco-core:core-nms'
include ':eco-core:core-nms:v1_16_R3'
include ':eco-core:core-nms:v1_17_R1'
include ':eco-core:core-nms:v1_18_R1'
include ':eco-core:core-proxy'
include ':eco-core:core-plugin'
include ':eco-core:core-stub'