1.12.2 Multiple version support

Discussion in 'Spigot Plugin Development' started by MMC2019, Feb 27, 2020.

  1. Hi let me make it short and tell main point.
    All of my plugin is based on this method.
    Code (Java):

        public static void showStatics(Player player, UUID target, String name) {
            List<String> players = PluginMain.usersDatabase.getUsers();

            if (!players.contains(target.toString())) {
                PluginMain.PlayerSend(player, name + "'s database not found");
                return;
            }

            Inventory inventory = Bukkit.createInventory(player, 54, "AGMOR Statics");
            for (int i=45;i<54;i++)
                if (PluginMain.isLegacy()) {
                    inventory.setItem(i, GUI(Material.STAINED_GLASS, (short) 4, "§r"));
                } else {
                    inventory.setItem(i, GUI(Material.YELLOW_STAINED_GLASS_PANE, (short) 4, "§r"));
                }
            }
        }

    It's not completed since I'm stuck. I can't build this since "YELLOW_STAINED_GLASS_PANE" can not be found in spigot 1.12, But I don't want to specify MC version and allow to use it on both Legacy and New versions (1.12 - 1.15.2)

    Please help !!!

    HTML:

       <dependencies>
            <dependency>
                <groupId>org.spigotmc</groupId>
                <artifactId>spigot-api</artifactId>
                <version>1.12.2-R0.1-SNAPSHOT</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.spigotmc</groupId>
                <artifactId>spigot</artifactId>
                <version>1.12.2-R0.1-SNAPSHOT</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>
     
    Code (Java):
        private static ItemStack GUI(Material material, short data, String name, List<String> lore) {
            ItemStack itemStack = new ItemStack(material, 1, data);
            ItemMeta itemMeta = itemStack.getItemMeta();
            itemMeta.setDisplayName(name);
            itemMeta.setLore(lore);
            itemStack.setItemMeta(itemMeta);
            return itemStack;
        }

        private static ItemStack GUI(Material material, short data, String name) {
            ItemStack itemStack = new ItemStack(material, 1, data);
            ItemMeta itemMeta = itemStack.getItemMeta();
            itemMeta.setDisplayName(name);
            itemStack.setItemMeta(itemMeta);
            return itemStack;
        }

        private static ItemStack GUI(Material material, String name, List<String> lore) {
            ItemStack itemStack = new ItemStack(material, 1);
            ItemMeta itemMeta = itemStack.getItemMeta();
            itemMeta.setDisplayName(name);
            itemMeta.setLore(lore);
            itemStack.setItemMeta(itemMeta);
            return itemStack;
        }

        private static ItemStack GUI(Material material, String name) {
            ItemStack itemStack = new ItemStack(material, 1);
            ItemMeta itemMeta = itemStack.getItemMeta();
            itemMeta.setDisplayName(name);
            itemStack.setItemMeta(itemMeta);
            return itemStack;
        }
     
    • Funny Funny x 1
  2. Does LEGACY_YELLOW_STAINED_GLASS_PANE exist?
     
  3. No there is no "LEGACY_YELLOW_STAINED_GLASS_PANE"
     
  4. Glass panes aren't separated by color pre flattening.