Skip to content

Commit

Permalink
Fixed enchantments in 1.16 extending EnchantmentWrapper causing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBenGera committed Jan 6, 2022
1 parent cab4383 commit 845708d
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 88 deletions.
1 change: 1 addition & 0 deletions settings.gradle
Expand Up @@ -35,4 +35,5 @@ include 'v1_17_R1'
include 'v1_17_R1-Spigot'
include 'v1_18_R1'
include 'v1_18_R1-Spigot'
include 'v1_16_R3-Spigot'

11 changes: 11 additions & 0 deletions v1_16_R3-Spigot/build.gradle
@@ -0,0 +1,11 @@
group 'v1_16_R3'

dependencies {
compileOnly "org.spigotmc:v1_16_R3:latest"
compileOnly project(":API")
compileOnly parent
}

if (project.hasProperty('nms.compile_v1_16') && !Boolean.valueOf(project.findProperty("nms.compile_v1_16").toString())) {
project.tasks.all { task -> task.enabled = false }
}
@@ -0,0 +1,51 @@
package com.bgsoftware.superiorskyblock.nms.v1_16_R3.algorithms;

import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentTarget;

public class SpigotGlowEnchantment extends Enchantment {

public SpigotGlowEnchantment(String name) {
super(NamespacedKey.minecraft(name));
}

@Override
public String getName() {
return "SuperiorSkyblockGlow";
}

@Override
public int getMaxLevel() {
return 1;
}

@Override
public int getStartLevel() {
return 0;
}

@Override
public EnchantmentTarget getItemTarget() {
return null;
}

public boolean isTreasure() {
return false;
}

public boolean isCursed() {
return false;
}

@Override
public boolean conflictsWith(Enchantment enchantment) {
return false;
}

@Override
public boolean canEnchantItem(org.bukkit.inventory.ItemStack itemStack) {
return true;
}

}
1 change: 1 addition & 0 deletions v1_16_R3/build.gradle
Expand Up @@ -2,6 +2,7 @@ group 'v1_16_R3'

dependencies {
compileOnly "org.spigotmc:v1_16_R3-Tuinity:latest"
compileOnly project(":v1_16_R3-Spigot")
compileOnly project(":API")
compileOnly parent
}
Expand Down
@@ -1,17 +1,7 @@
package com.bgsoftware.superiorskyblock.nms.v1_16_R3.algorithms;

import io.papermc.paper.enchantments.EnchantmentRarity;
import net.kyori.adventure.text.Component;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.enchantments.EnchantmentWrapper;
import org.bukkit.entity.EntityCategory;
import org.bukkit.inventory.EquipmentSlot;

import java.util.HashSet;
import java.util.Set;

@SuppressWarnings("NullableProblems")
public final class GlowEnchantmentFactory {

public static Enchantment createEnchantment() {
Expand All @@ -22,82 +12,4 @@ public static Enchantment createEnchantment() {
}
}

static class SpigotGlowEnchantment extends EnchantmentWrapper {

protected SpigotGlowEnchantment(String name) {
super(name);
}

@Override
public int getMaxLevel() {
return 1;
}

@Override
public int getStartLevel() {
return 0;
}

@Override
public EnchantmentTarget getItemTarget() {
return null;
}

@Override
public boolean canEnchantItem(org.bukkit.inventory.ItemStack itemStack) {
return true;
}

@Override
public String getName() {
return "SuperiorSkyblockGlow";
}

public boolean isTreasure() {
return false;
}

public boolean isCursed() {
return false;
}

@Override
public boolean conflictsWith(Enchantment enchantment) {
return false;
}

}

static class PaperGlowEnchantment extends SpigotGlowEnchantment {

PaperGlowEnchantment(String name) {
super(name);
}

public Component displayName(int i) {
return Component.empty();
}

public boolean isTradeable() {
return false;
}

public boolean isDiscoverable() {
return false;
}

public EnchantmentRarity getRarity() {
return EnchantmentRarity.COMMON;
}

public float getDamageIncrease(int i, EntityCategory entityCategory) {
return 0;
}

public Set<EquipmentSlot> getActiveSlots() {
return new HashSet<>();
}

}

}
@@ -0,0 +1,47 @@
package com.bgsoftware.superiorskyblock.nms.v1_16_R3.algorithms;

import io.papermc.paper.enchantments.EnchantmentRarity;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.EntityCategory;
import org.bukkit.inventory.EquipmentSlot;

import java.util.HashSet;
import java.util.Set;

public final class PaperGlowEnchantment extends SpigotGlowEnchantment {

public PaperGlowEnchantment(String name) {
super(name);
}

@Override
public Component displayName(int i) {
return Component.empty();
}

@Override
public boolean isTradeable() {
return false;
}

@Override
public boolean isDiscoverable() {
return false;
}

@Override
public EnchantmentRarity getRarity() {
return EnchantmentRarity.COMMON;
}

@Override
public float getDamageIncrease(int i, EntityCategory entityCategory) {
return 0;
}

@Override
public Set<EquipmentSlot> getActiveSlots() {
return new HashSet<>();
}

}

0 comments on commit 845708d

Please sign in to comment.