1.14 Item Glow

Discussion in 'Spigot Plugin Development' started by MrAxeTv, May 7, 2019.

  1. Hey I have problem with adding glow to items in 1.14 version I have toyed to use this method which works in 1.13 but not in 1.14
    Code (Text):
        public ItemMeta setGlow(ItemMeta im) {
            NamespacedKey nsk = new NamespacedKey(pl, "glow");
            Glow glow = new Glow(nsk);
            im.addEnchant(glow, 1, true);

            return im;
        }

        public void registerGlow() {
            try {
                Field f = Enchantment.class.getDeclaredField("acceptingNew");
                f.setAccessible(true);
                f.set(null, true);
            }
            catch (Exception e) {
                e.printStackTrace();
            }
            try {
                NamespacedKey nsk = new NamespacedKey(this, "glow");
                Glow glow = new Glow(nsk);
                Enchantment.registerEnchantment(glow);
            }
            catch (IllegalArgumentException e){
            }
            catch(Exception e){
                e.printStackTrace();
            }
        }
    But this wont work with 1.14
    Thanks
     
  2. Pretty sure enchants changed in the way they were registered? Not too sure, but why not add like unbreaking 1 to the item via addUnsafeEnchant and then set a flag to hide enchants?
     
  3. Why are you creating a new instance of Glow everytime you want set it to an item meta? Create a singleton and always use that.