[1.11.2] Plugin not compiling

Discussion in 'Spigot Plugin Development' started by GP40-PH2, May 3, 2017.

  1. I am updating a plugin for my server which was formerly 1.8 to the latest 1.11.2 of Spigot, and the plugin will not compile in NetBeans, despite the fact I am using Spigot 1.11.2 as a dependency. I have supplied one of the classes affected and the netbeans output. Apparently, Netbeans is saying that BLOCK_IRON_DOOR_CLOSE and BLOCK_NOTE_PLING are not valid. The code I provided is a class that reads faregates and opens an iron door when clicked with a special item. The doors are supposed to make a door opening sound and when clicked they make a ping sound to let you know you opened it. The class worked using 1.8 sounds and when I updated it it ceased to compile, depsite the fact I got no errors when updating to 1.11.2

    Class:
    Code (Text):

    package me.metrou.Listener;

    import java.util.ArrayList;
    import java.util.HashMap;
    import me.metrou.MCards.MetroPasses2;
    import me.metrou.MCards.MultiMetroPass;
    import me.metrou.MCards.TransferSlip;
    import me.metrou.MetroU;
    import me.metrou.MetroU.Global;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.Sound;
    import org.bukkit.block.Block;
    import org.bukkit.block.BlockState;
    import org.bukkit.block.Sign;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.PlayerInventory;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.material.Door;
    import org.bukkit.plugin.Plugin;

    public class SingleTFaregateListener
      implements Listener
    {
      public static Plugin plugin;
      public SingleTFaregateListener(MetroU instance)
      {
        plugin = instance;
      }
      @EventHandler
      public void signInteract2(PlayerInteractEvent event)
      {
        if ((event.getClickedBlock() != null) && ((event.getClickedBlock().getType().equals(Material.SIGN_POST)) || (event.getClickedBlock().getType().equals(Material.WALL_SIGN))))
        {
          Player player = event.getPlayer();
          Boolean LowerKey = Boolean.valueOf(true);
          ItemStack item = event.getPlayer().getItemInHand();
          Block clicked = event.getClickedBlock();
       
          Sign sign = (Sign)event.getClickedBlock().getState();
          if ((sign.getLine(0).equalsIgnoreCase(ChatColor.WHITE + "[Faregate]")) &&
            (sign.getLine(1).equalsIgnoreCase(ChatColor.GREEN + "⬅")) &&
            (sign.getLine(2).equalsIgnoreCase(ChatColor.BOLD + "Tap MetroPass")) &&
            (item.equals(MetroPasses2.getKey(1, "§6MetroPass §8| §1Single Journey", item.getAmount()))))
          {
            LowerKey = Boolean.valueOf(false);
            player.getInventory().removeItem(new ItemStack[] { MetroPasses2.getKey(1, "§6MetroPass §8| §1Single Journey", 1) });
            player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8[&bMetroPayride&8] &e$1.00 &bHas been deducted off your MetroPass."));
            player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8[&bMetroPayride&8] &bYour MetroPass has been taken by the faregate as it is a single trip card."));
            for (int x = -1; x <= 1; x++) {
              for (int y = -1; y <= 1; y++) {
                for (int z = -1; z <= 1; z++) {
                  if (event.getClickedBlock().getRelative(x, y, z).getType().equals(Material.IRON_DOOR_BLOCK))
                  {
                    BlockState state = event.getClickedBlock().getRelative(x, y, z).getState();
                    Door door = (Door)state.getData();
                    if (door.isOpen())
                    {
                      door.setOpen(false);
                      player.playSound(state.getLocation(), Sound.BLOCK_IRON_DOOR_CLOSE , 1.0F, 1.0F);
                    }
                    else
                    {
                      door.setOpen(true);
                      player.playSound(state.getLocation(), Sound.BLOCK_IRON_DOOR_OPEN , 1.0F, 1.0F);
                      player.playSound(state.getLocation(), Sound.BLOCK_NOTE_PLING, 1.0F, 1.0F);
                      MetroU.Global.ADoors.add(state.getLocation());
                      MetroU.Global.doors.put(state.getLocation(), Integer.valueOf(2));
                    }
                    state.setData(door);
                    state.update();
                  }
                }
              }
            }
            if (MultiMetroPass.getRides(player.getItemInHand()) <= 0) {
              player.sendMessage("§8[§bMetroPayride§8] §eERROR: Insufficent Balance. Please top-up your MetroPass.");
            }
          }
        }
      }
      @EventHandler
      public void signInteract4(PlayerInteractEvent event)
      {
        if ((event.getClickedBlock() != null) && ((event.getClickedBlock().getType().equals(Material.SIGN_POST)) || (event.getClickedBlock().getType().equals(Material.WALL_SIGN))))
        {
          Player player = event.getPlayer();
          Boolean LowerKey = Boolean.valueOf(true);
          ItemStack item = event.getPlayer().getItemInHand();
          Block clicked = event.getClickedBlock();
       
          Sign sign = (Sign)event.getClickedBlock().getState();
          if ((sign.getLine(0).equalsIgnoreCase(ChatColor.BLUE + "[Faregate]")) &&
            (sign.getLine(1).equalsIgnoreCase(ChatColor.GREEN + "⬅")) &&
            (sign.getLine(2).equalsIgnoreCase(ChatColor.BOLD + "Tap MetroPass")) &&
            (sign.getLine(3).equalsIgnoreCase(ChatColor.DARK_RED + "TS Accepted Here")) &&
            (item.equals(MetroPasses2.getKey(1, "§6MetroPass §8| §1Single Journey", item.getAmount()))))
          {
            LowerKey = Boolean.valueOf(false);
            player.getInventory().removeItem(new ItemStack[] { MetroPasses2.getKey(1, "§6MetroPass §8| §1Single Journey", 1) });
            player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8[&bMetroPayride&8] &e$1.00 &bHas been deducted off your MetroPass."));
            player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8[&bMetroPayride&8] &bYour MetroPass has been taken by the faregate as it is a single trip card."));
            for (int x = -1; x <= 1; x++) {
              for (int y = -1; y <= 1; y++) {
                for (int z = -1; z <= 1; z++) {
                  if (event.getClickedBlock().getRelative(x, y, z).getType().equals(Material.IRON_DOOR_BLOCK))
                  {
                    BlockState state = event.getClickedBlock().getRelative(x, y, z).getState();
                    Door door = (Door)state.getData();
                    if (door.isOpen())
                    {
                      door.setOpen(false);
                      player.playSound(state.getLocation(), Sound.BLOCK_IRON_DOOR_CLOSE, 1, 1);
                    }
                    else
                    {
                      door.setOpen(true);
                      player.playSound(state.getLocation(), Sound.BLOCK_IRON_DOOR_OPEN, 1, 1);
                      player.playSound(state.getLocation(), Sound.BLOCK_NOTE_PLING, 1, 1);
                      MetroU.Global.ADoors.add(state.getLocation());
                      MetroU.Global.doors.put(state.getLocation(), Integer.valueOf(2));
                    }
                    state.setData(door);
                    state.update();
                  }
                }
              }
            }
            if (MultiMetroPass.getRides(player.getItemInHand()) <= 0) {
              player.sendMessage("§8[§bMetroPayride§8] §eERROR: Insufficent Balance. Please top-up your MetroPass.");
            }
          }
        }
      }
      @EventHandler
      public void signInteract5(PlayerInteractEvent event)
      {
        if ((event.getClickedBlock() != null) && ((event.getClickedBlock().getType().equals(Material.SIGN_POST)) || (event.getClickedBlock().getType().equals(Material.WALL_SIGN))))
        {
          Player player = event.getPlayer();
          Boolean LowerKey = Boolean.valueOf(true);
          ItemStack item = event.getPlayer().getItemInHand();
          Block clicked = event.getClickedBlock();
       
          Sign sign = (Sign)event.getClickedBlock().getState();
          if ((sign.getLine(0).equalsIgnoreCase(ChatColor.BLUE + "[Faregate]")) &&
            (sign.getLine(1).equalsIgnoreCase(ChatColor.GREEN + "⬅")) &&
            (sign.getLine(2).equalsIgnoreCase(ChatColor.BOLD + "Tap MetroPass")) &&
            (sign.getLine(3).equalsIgnoreCase(ChatColor.DARK_RED + "TS Accepted Here")) && (
            (player.getItemInHand().getItemMeta().getDisplayName().equals(MultiMetroPass.getItem(100, "§6MetroPass §8| §1Multi-Trip", item.getAmount()))) || (MultiMetroPass.getRides(player.getItemInHand()) > 0)))
          {
            int rides = MultiMetroPass.getRides(player.getItemInHand()) - 1;
            MultiMetroPass.setRides(event.getPlayer().getItemInHand(), rides);
            player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8[&bMetroPayride&8] &e$1.00 &bHas been deducted off your MetroPass."));
            player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8[&bMetroPayride&8] &bMetroPass Balance is now&e $" + MultiMetroPass.getRides(player.getItemInHand()) + ""));
            for (int x = -1; x <= 1; x++) {
              for (int y = -1; y <= 1; y++) {
                for (int z = -1; z <= 1; z++) {
                  if (event.getClickedBlock().getRelative(x, y, z).getType().equals(Material.IRON_DOOR_BLOCK))
                  {
                    BlockState state = event.getClickedBlock().getRelative(x, y, z).getState();
                    Door door = (Door)state.getData();
                    if (door.isOpen())
                    {
                      door.setOpen(false);
                      player.playSound(state.getLocation(), Sound.BLOCK_IRON_DOOR_CLOSE, 1, 1);
                    }
                    else
                    {
                      door.setOpen(true);
                      player.playSound(state.getLocation(), Sound.BLOCK_IRON_DOOR_OPEN, 1, 1);
                      player.playSound(state.getLocation(), Sound.BLOCK_NOTE_PLING, 1, 1);
                      MetroU.Global.ADoors.add(state.getLocation());
                      MetroU.Global.doors.put(state.getLocation(), Integer.valueOf(2));
                    }
                    state.setData(door);
                    state.update();
                  }
                }
              }
            }
            if (MultiMetroPass.getRides(player.getItemInHand()) < 0) {
              player.sendMessage("§8[§bMetroPayride§8] §eERROR: Insufficent Balance. Please top-up your MetroPass.");
            }
          }
        }
      }
      @EventHandler
      public void signInteract3(PlayerInteractEvent event)
      {
        if ((event.getClickedBlock() != null) && ((event.getClickedBlock().getType().equals(Material.SIGN_POST)) || (event.getClickedBlock().getType().equals(Material.WALL_SIGN))))
        {
          Player player = event.getPlayer();
          Boolean LowerKey = Boolean.valueOf(true);
          ItemStack item = event.getPlayer().getItemInHand();
          Block clicked = event.getClickedBlock();
       
          Sign sign = (Sign)event.getClickedBlock().getState();
          if ((sign.getLine(0).equalsIgnoreCase(ChatColor.BLUE + "[Faregate]")) &&
            (sign.getLine(1).equalsIgnoreCase(ChatColor.GREEN + "⬅")) &&
            (sign.getLine(2).equalsIgnoreCase(ChatColor.BOLD + "Tap MetroPass")) &&
            (sign.getLine(3).equalsIgnoreCase(ChatColor.DARK_RED + "TS Accepted Here")) &&
            (item.equals(TransferSlip.getKey(2, "§bTransfer Slip", item.getAmount()))))
          {
            LowerKey = Boolean.valueOf(false);
            player.getInventory().removeItem(new ItemStack[] { TransferSlip.getKey(2, "§bTransfer Slip", 1) });
            player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8[&bMetroPayride&8] &eTransfer Slip used sucessfully."));
            player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8[&bMetroPayride&8] &bYour Transfer Slip has been taken by the faregate."));
            for (int x = -1; x <= 1; x++) {
              for (int y = -1; y <= 1; y++) {
                for (int z = -1; z <= 1; z++) {
                  if (event.getClickedBlock().getRelative(x, y, z).getType().equals(Material.IRON_DOOR_BLOCK))
                  {
                    BlockState state = event.getClickedBlock().getRelative(x, y, z).getState();
                    Door door = (Door)state.getData();
                    if (door.isOpen())
                    {
                      door.setOpen(false);
                      player.playSound(state.getLocation(), Sound.BLOCK_IRON_DOOR_CLOSE, 1, 1);
                    }
                    else
                    {
                      door.setOpen(true);
                      player.playSound(state.getLocation(), Sound.BLOCK_IRON_DOOR_OPEN, 1, 1);
                      player.playSound(state.getLocation(), Sound.BLOCK_NOTE_PLING, 1, 1);
                      MetroU.Global.ADoors.add(state.getLocation());
                      MetroU.Global.doors.put(state.getLocation(), Integer.valueOf(2));
                    }
                    state.setData(door);
                    state.update();
                  }
                }
              }
            }
            if (MultiMetroPass.getRides(player.getItemInHand()) < 0) {
              player.sendMessage("§8[§bMetroPayride§8] §eERROR: Insufficent Balance. Please top-up your MetroPass.");
            }
          }
        }
      }
    }
     
    Netbeans Output:
    Code (Text):

    ant -f C:\\Users\\User\\Documents\\NetBeansProjects\\MetroPayride_CURRENT_3 -Dnb.internal.action.name=build jar
    init:
    Deleting: C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\build\built-jar.properties
    deps-jar:
    Updating property file: C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\build\built-jar.properties
    Compiling 25 source files to C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\build\classes
    C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\src\me\metrou\MetroU.java:133: error: cannot find symbol
                    p.playSound(loc, Sound.BLOCK_IRON_DOOR_CLOSE, 1, 1);
      symbol:   variable BLOCK_IRON_DOOR_CLOSE
      location: class Sound
    C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\src\me\metrou\Listener\FaregateListener.java:93: error: cannot find symbol
                        player.playSound(state.getLocation(), Sound.BLOCK_IRON_DOOR_CLOSE, 1.0F, 1.0F);
      symbol:   variable BLOCK_IRON_DOOR_CLOSE
      location: class Sound
    C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\src\me\metrou\Listener\FaregateListener.java:98: error: cannot find symbol
                        player.playSound(state.getLocation(), Sound.BLOCK_IRON_DOOR_OPEN, 1.0F, 1.0F);
      symbol:   variable BLOCK_IRON_DOOR_OPEN
      location: class Sound
    C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\src\me\metrou\Listener\FaregateListener.java:99: error: cannot find symbol
                        player.playSound(state.getLocation(), Sound.BLOCK_NOTE_PLING, 1.0F, 1.0F);
      symbol:   variable BLOCK_NOTE_PLING
      location: class Sound
    C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\src\me\metrou\Listener\SPlayerListener.java:48: error: cannot find symbol
          player.playSound(state.getLocation(), Sound.BLOCK_IRON_DOOR_OPEN, 1.0F, 1.0F);
      symbol:   variable BLOCK_IRON_DOOR_OPEN
      location: class Sound
    C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\src\me\metrou\Listener\SPlayerListener.java:49: error: cannot find symbol
          player.playSound(state.getLocation(), Sound.BLOCK_NOTE_PLING, 1.0F, 1.0F);
      symbol:   variable BLOCK_NOTE_PLING
      location: class Sound
    C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\src\me\metrou\Listener\SPlayerListener.java:56: error: cannot find symbol
          player.playSound(state.getLocation(), Sound.BLOCK_IRON_DOOR_CLOSE, 1.0F, 1.0F);
      symbol:   variable BLOCK_IRON_DOOR_CLOSE
      location: class Sound
    C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\src\me\metrou\Listener\SingleTFaregateListener.java:66: error: cannot find symbol
                      player.playSound(state.getLocation(), Sound.BLOCK_IRON_DOOR_CLOSE , 1.0F, 1.0F);
      symbol:   variable BLOCK_IRON_DOOR_CLOSE
      location: class Sound
    C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\src\me\metrou\Listener\SingleTFaregateListener.java:71: error: cannot find symbol
                      player.playSound(state.getLocation(), Sound.BLOCK_IRON_DOOR_OPEN , 1.0F, 1.0F);
      symbol:   variable BLOCK_IRON_DOOR_OPEN
      location: class Sound
    C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\src\me\metrou\Listener\SingleTFaregateListener.java:72: error: cannot find symbol
                      player.playSound(state.getLocation(), Sound.BLOCK_NOTE_PLING, 1.0F, 1.0F);
      symbol:   variable BLOCK_NOTE_PLING
      location: class Sound
    C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\src\me\metrou\Listener\SingleTFaregateListener.java:120: error: cannot find symbol
                      player.playSound(state.getLocation(), Sound.BLOCK_IRON_DOOR_CLOSE, 1, 1);
      symbol:   variable BLOCK_IRON_DOOR_CLOSE
      location: class Sound
    C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\src\me\metrou\Listener\SingleTFaregateListener.java:125: error: cannot find symbol
                      player.playSound(state.getLocation(), Sound.BLOCK_IRON_DOOR_OPEN, 1, 1);
      symbol:   variable BLOCK_IRON_DOOR_OPEN
      location: class Sound
    C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\src\me\metrou\Listener\SingleTFaregateListener.java:126: error: cannot find symbol
                      player.playSound(state.getLocation(), Sound.BLOCK_NOTE_PLING, 1, 1);
      symbol:   variable BLOCK_NOTE_PLING
      location: class Sound
    C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\src\me\metrou\Listener\SingleTFaregateListener.java:174: error: cannot find symbol
                      player.playSound(state.getLocation(), Sound.BLOCK_IRON_DOOR_CLOSE, 1, 1);
      symbol:   variable BLOCK_IRON_DOOR_CLOSE
      location: class Sound
    C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\src\me\metrou\Listener\SingleTFaregateListener.java:179: error: cannot find symbol
                      player.playSound(state.getLocation(), Sound.BLOCK_IRON_DOOR_OPEN, 1, 1);
      symbol:   variable BLOCK_IRON_DOOR_OPEN
      location: class Sound
    C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\src\me\metrou\Listener\SingleTFaregateListener.java:180: error: cannot find symbol
                      player.playSound(state.getLocation(), Sound.BLOCK_NOTE_PLING, 1, 1);
      symbol:   variable BLOCK_NOTE_PLING
      location: class Sound
    C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\src\me\metrou\Listener\SingleTFaregateListener.java:228: error: cannot find symbol
                      player.playSound(state.getLocation(), Sound.BLOCK_IRON_DOOR_CLOSE, 1, 1);
      symbol:   variable BLOCK_IRON_DOOR_CLOSE
      location: class Sound
    C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\src\me\metrou\Listener\SingleTFaregateListener.java:233: error: cannot find symbol
                      player.playSound(state.getLocation(), Sound.BLOCK_IRON_DOOR_OPEN, 1, 1);
      symbol:   variable BLOCK_IRON_DOOR_OPEN
      location: class Sound
    C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\src\me\metrou\Listener\SingleTFaregateListener.java:234: error: cannot find symbol
                      player.playSound(state.getLocation(), Sound.BLOCK_NOTE_PLING, 1, 1);
      symbol:   variable BLOCK_NOTE_PLING
      location: class Sound
    Note: Some input files use or override a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    Note: C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\src\me\metrou\MetroU.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    19 errors
    C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\nbproject\build-impl.xml:931: The following error occurred while executing this line:
    C:\Users\User\Documents\NetBeansProjects\MetroPayride_CURRENT_3\nbproject\build-impl.xml:271: Compile failed; see the compiler error output for details.
    BUILD FAILED (total time: 1 second)
     
     
  2. Yep often when theirs a major update some of the enum values get changed. I assume it's mojang that does it.

    You'll need to go in and figure what those materials have changed to, the same for sounds and often particle names.

    They'll chance from things like EXPLOSION _LARGE to LARGE_EXPLOSION


    Sent from my iPhone using Tapatalk
     
  3. I tried that and everything is updated but still, it does not want to compile.
     
  4. If it's showing the cannot find symbol Sound.something you haven't changed them all. You'll need to change EVERY occurrence

    Edit I just looked at the Sound class and it looks like the current iron door sound is:

    https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html#BLOCK_IRON_DOOR_OPEN


    Check all your imports and make sure you're not building against a 1.8 jar, if it exists in your library remove it. You should only have the current 1.11 jar as a library.

    Make sure you don't also have a craftbukkit jar imported that's < 1.11

    Sent from my iPhone using Tapatalk
     
    #4 dNiym, May 4, 2017
    Last edited: May 4, 2017