1.15.2 getMaterial().toString() doesn't work

Discussion in 'Spigot Plugin Development' started by SamBkamp, Jan 24, 2020.

  1. Hey guys,

    Im re writing one of my old plugins from 1.14 in 1.15 and for some reason, the getMaterial().toString() method can't be resolved.

    Code (Java):

    import org.bukkit.Material;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;


    public class chairEvent implements Listener {
        @EventHandler
        public void chairSit(PlayerInteractEvent e){
            if(e.getAction() == Action.RIGHT_CLICK_BLOCK){
                Material T = e.getMaterial().toString();
            }
        }
    }
     
    my IDE here immediately lights up and tells me 'Cannot resolve method toString in Material'

    Thanks
     

  2. You are trying to set a material to a string. Which won't work.
    This is what I'm guessing you're going for.

    Code (Java):

    String T = e.getMaterial().toString();
     
     
  3. Why .toString in the first place? You should use the enum's value. If you think you need to compare to a string chances are you are already doing something wrong.