mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-22 15:05:18 +01:00
Added 1.18.2 support
This commit is contained in:
parent
9f392074eb
commit
bf135755c6
6
eco-core/core-nms/v1_18_R2/build.gradle
Normal file
6
eco-core/core-nms/v1_18_R2/build.gradle
Normal file
@ -0,0 +1,6 @@
|
||||
group 'com.willfp'
|
||||
version rootProject.version
|
||||
|
||||
dependencies {
|
||||
compileOnly 'org.spigotmc:spigot:1.18.2-R0.1-SNAPSHOT'
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.willfp.ecoenchants.proxy.v1_18_R2;
|
||||
|
||||
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_R2.enchants.EcoCraftEnchantment;
|
||||
import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.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();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.willfp.ecoenchants.proxy.v1_18_R2;
|
||||
|
||||
import com.willfp.ecoenchants.proxy.proxies.OpenInventoryProxy;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.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().bV;
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.willfp.ecoenchants.proxy.v1_18_R2.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_R2.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);
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ include ':eco-core'
|
||||
include ':eco-core:core-nms'
|
||||
include ':eco-core:core-nms:v1_17_R1'
|
||||
include ':eco-core:core-nms:v1_18_R1'
|
||||
include ':eco-core:core-nms:v1_18_R2'
|
||||
include ':eco-core:core-proxy'
|
||||
include ':eco-core:core-plugin'
|
||||
include ':eco-core:core-stub'
|
||||
|
Loading…
Reference in New Issue
Block a user