1.15.2 UpgradeSpawners fix error help

Discussion in 'Spigot Plugin Development' started by RetroOhGames, Apr 2, 2020.

  1. hello people, I am decoding a plugin that tries to level up the spawners, but I have a problem as I compiled it in 1.8 I do not have much knowledge about the new spigot API 1.15.2, since I have not used the API for 3 years I hope someone can help me solve my problem.

    postscript: what is in red is where it gives me the error



    public void onDisable() {
    for (Player p : Bukkit.getOnlinePlayers()) {
    if (p.getOpenInventory().getTitle()
    .equalsIgnoreCase(getConfig().getString("gui-title").replaceAll("&", ")))
    p.closeInventory();
    }
    }






    @EventHandler
    public void Break(BlockBreakEvent s) {
    if (s.getBlock().getType().equals(Material.SPAWNER) &&
    getConfig().contains("Spawns." + loc2str(s.getBlock().getLocation()))) {
    s.getPlayer().sendMessage(getConfig().getString("remove").replaceAll("&", "));
    BlockState state = s.getBlock().getState();
    CreatureSpawner cs = (CreatureSpawner)state;
    getConfig().set(String.valueOf(cs.getCreatureTypeName()) + ".Mobs." + loc2str(s.getBlock().getLocation()), null);
    getConfig().set("Spawns." + loc2str(s.getBlock().getLocation()), null);
    saveConfig();
    }
    }







    @EventHandler
    public void onClick(InventoryClickEvent e) {
    if (e.getInventory().getTitle().equalsIgnoreCase(getConfig().getString("gui-title").replaceAll("&", "))) {
    if (e.getCurrentItem() != null && e.getCurrentItem().getType() != Material.AIR)
    e.setCancelled(true);
    final Player p = (Player)e.getWhoClicked();
    if (this.list.contains(p.getName()))
    return;
    this.list.add(p.getName());
    (new BukkitRunnable() {
    public void run() {
    if (UpgradeSpawners.this.list.contains(p.getName()))
    UpgradeSpawners.this.list.remove(p.getName());
     
  2. There is an opening " without a closing " inside all of the replaceAll() methods.
    Also there is an explicit way to transcode alternate color codes:
    ChatColor.translateAlternateColorCodes()

    Also, Inventory.getTitle() method doest not exist in 1.15 API anymore.
    Instead event.getView().getTitle() is to be used.

    Please put your code into code brackets next time.
     
  3. You forgot 3 times to close the quotation marks.
    Code (Text):

    if (e.getInventory().getTitle().equalsIgnoreCase(getConfig().getString("gui-title").replaceAll("&", "x")))
     
    Replace the "x" with the character that will replace the &
     
  4. Doesn't your IDE take care of closing quotations and brackets?