Skip to content

Instantly share code, notes, and snippets.

@WizardlyBump17
Last active July 7, 2019 15:13
Show Gist options
  • Save WizardlyBump17/da216252f5e814aac59afae55cfe4dc6 to your computer and use it in GitHub Desktop.
Save WizardlyBump17/da216252f5e814aac59afae55cfe4dc6 to your computer and use it in GitHub Desktop.
Invisible minecraft enchantments
/*
* File name: Glow.java
*/
import java.lang.reflect.Field;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.inventory.ItemStack;
public class Glow extends Enchantment {
public Glow(int id) {
super(id);
}
@Override
public boolean canEnchantItem(ItemStack arg0) {
return false;
}
@Override
public boolean conflictsWith(Enchantment arg0) {
return false;
}
@Override
public EnchantmentTarget getItemTarget() {
return null;
}
@Override
public int getMaxLevel() {
return 0;
}
@Override
public String getName() {
return null;
}
@Override
public int getStartLevel() {
return 0;
}
public void registerGlow() {
try {
Field f = Enchantment.class.getDeclaredField("acceptingNew");
f.setAccessible(true);
f.set(null, true);
}
catch (Exception e) {
e.printStackTrace();
}
try {
Glow glow = new Glow(70);
Enchantment.registerEnchantment(glow);
}
catch (IllegalArgumentException e){
}
catch(Exception e){
e.printStackTrace();
}
}
}
/*
* Put this in the file that extends JavaPlugin
*/
public void onEnable() {
Glow glow = new Glow(70);
glow.registerGlow();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment