Material is null

Discussion in 'Plugin Development' started by ctrichardson2, Oct 27, 2019.

  1. Offline

    ctrichardson2

    I am currently Stuck on Material cannot be Null. I am currently Developing a SignShop Plugin. I am Learning this type of stuff.
    Code:
    package main;
    
    import net.milkbowl.vault.economy.Economy;
    import net.milkbowl.vault.economy.EconomyResponse;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.Server;
    import org.bukkit.block.Block;
    import org.bukkit.block.Sign;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.ItemStack;
    import me.idlibrary.main.IDLibrary;
    
    public class SignUse
      implements Listener
    {
        @EventHandler
      public void SignClick(PlayerInteractEvent event) {
        Player p = event.getPlayer();
        if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
            if (event.getClickedBlock().getState() instanceof Sign) {
                Sign sign = (Sign) event.getClickedBlock().getState();
               
                String line1 = sign.getLine(1);
                String[] splited1 = line1.split("(?<=\\D)(?=\\d)");
                //int number = Integer.valueOf(splited1[1]);
               
               
    
               
                if (sign.getLine(0).equalsIgnoreCase(ChatColor.BLUE + "[Admin]")) {
                    //p.sendMessage(splited1[1]);
                    int cost = Integer.valueOf(splited1[1]);
                      if (sign.getLine(1).contains("B $" +cost)) {
                          p.sendMessage(String.valueOf(cost));
                          p.sendMessage("RightClicked");
                         
                         
                            int amount = Integer.valueOf(sign.getLine(2));
                            //String isu = sign.getLine(1).replace("$", "");
                            //double i = Double.parseDouble(isu);
                           
                            EconomyResponse r = main.r.econ.withdrawPlayer(p.getName(), cost);
                            if (r.transactionSuccess())
                            {
                              p.sendMessage(ChatColor.GREEN + main.c.getString("TXT1") + " " + ChatColor.GOLD + "$"+cost);
                             
                              //String IDData = IDLibrary.getIDData(Material.valueOf(sign.getLine(3)));
                              //String.valueOf(sign.getLine(3))
                             // This part 
                              Material M = IDLibrary.getMaterial(String.valueOf(sign.getLine(3)));
                              ItemStack item = new ItemStack(M, amount);
                              p.getInventory().addItem(item);
    
                            }
                            else
                            {
                              p.sendMessage(ChatColor.RED + main.c.getString("TXT2"));
                            }
                                             
                          }                     
                      }   
                }       
            }   
        }
      }
     
  2. Online

    timtower Moderator Moderator

Share This Page