This repository was archived by the owner on Feb 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
186 additions
and
24 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/main/java/dev/efnilite/witp/util/inventory/enchantment/EnchantmentWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package dev.efnilite.witp.util.inventory.enchantment; | ||
|
||
import dev.efnilite.witp.util.Verbose; | ||
import org.bukkit.NamespacedKey; | ||
import org.bukkit.enchantments.Enchantment; | ||
import org.bukkit.plugin.Plugin; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.lang.reflect.Field; | ||
|
||
/** | ||
* Wrapper for enchantments | ||
*/ | ||
public abstract class EnchantmentWrapper extends Enchantment { | ||
|
||
protected String name; | ||
protected static Enchantment enchantment; | ||
|
||
public EnchantmentWrapper(String name, Plugin plugin) { | ||
super(new NamespacedKey(plugin, name)); | ||
this.name = name; | ||
|
||
enchantment = this; | ||
|
||
register(); | ||
} | ||
|
||
public void register() { | ||
if (!Enchantment.isAcceptingRegistrations()) { | ||
try { | ||
Field field = Enchantment.class.getDeclaredField("acceptingNew"); | ||
field.setAccessible(true); | ||
field.set(null, true); | ||
} catch (NoSuchFieldException | IllegalAccessException e) { | ||
e.printStackTrace(); | ||
Verbose.error("Couldn't init Enchantment"); | ||
return; | ||
} | ||
|
||
} | ||
Enchantment.registerEnchantment(this); | ||
} | ||
|
||
@Override | ||
public @NotNull String getName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public boolean isTreasure() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isCursed() { | ||
return false; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/dev/efnilite/witp/util/inventory/enchantment/GlowEnchant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package dev.efnilite.witp.util.inventory.enchantment; | ||
|
||
import dev.efnilite.witp.WITP; | ||
import org.bukkit.enchantments.Enchantment; | ||
import org.bukkit.enchantments.EnchantmentTarget; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class GlowEnchant extends EnchantmentWrapper { | ||
|
||
public GlowEnchant() { | ||
super("glow", WITP.getInstance()); | ||
} | ||
|
||
@Override | ||
public int getMaxLevel() { | ||
return 1; | ||
} | ||
|
||
@Override | ||
public int getStartLevel() { | ||
return 1; | ||
} | ||
|
||
@Override | ||
public @NotNull EnchantmentTarget getItemTarget() { | ||
return EnchantmentTarget.ALL; | ||
} | ||
|
||
@Override | ||
public boolean conflictsWith(@NotNull Enchantment enchantment) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean canEnchantItem(@NotNull ItemStack itemStack) { | ||
return true; | ||
} | ||
|
||
public static Enchantment getEnchantment() { | ||
return enchantment; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters