Solved I am getting this null error

Discussion in 'Plugin Development' started by PerezHD, Jan 16, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    PerezHD

    Hey guys, I need some help on this issue with my event.

    EVENT:
    Code:
      @EventHandler
      public void onPlayerInteract(PlayerInteractEvent e)
      {
          Player p = e.getPlayer();
          ItemStack ecoin = new ItemStack(Material.MAGMA_CREAM);
          ItemMeta meta = ecoin.getItemMeta();
          meta.setDisplayName("§eEnchantment Coin §7(Right Click)");
          List<String> ecoinlore = new ArrayList();
          ecoinlore.add(ChatColor.GRAY + "Right click them and use them at /enchants.");
          meta.setLore(ecoinlore);
          ecoin.setItemMeta(meta);
         
        ItemStack air = new ItemStack(Material.AIR);
        if ((e.getAction() != Action.RIGHT_CLICK_BLOCK) && (e.getAction() != Action.RIGHT_CLICK_AIR)) {
          return;
        }
        if (e.getItem() == null) {
          return;
        }
        if (e.getItem().equals(ecoin))
        {
            plugin.addCoins(p, p.getItemInHand().getAmount());
            e.getPlayer().sendMessage("§a§l+§a§l" + e.getPlayer().getItemInHand().getAmount() + " §a§lEnchantment Coin(s)!");
            e.getPlayer().setItemInHand(air);
            e.getPlayer().updateInventory();
        }
      }
    METHOD for addCoins:
    Code:
      public void addCoins(Player p, int newCoins) {
          String prefix = getConfig().getString("prefix").replaceAll("(&([a-f0-9]))", "\u00A7$2");
          int oldCoins = getCoins(p);
          int newpoint = oldCoins + newCoins;
          getUsers().set("Users." + p.getUniqueId(), newpoint);
          saveUsers();
          p.sendMessage(prefix + " " + ChatColor.GOLD + "You now have " + ChatColor.AQUA + getCoins(p) + ChatColor.GOLD + " Coins");
      }
    CONSOLE ERROR WITH NULL:
    http://pastebin.com/Gr7cZhrk
     
  2. Offline

    SuperOriginal

    What is line 119
     
  3. Offline

    PerezHD

    Well, it is this
    Code:
          String prefix = getConfig().getString("prefix").replaceAll("(&([a-f0-9]))", "\u00A7$2");
    which I think I found the issue, Ill check back with you in a sec
     
    Last edited: Jan 16, 2015
  4. Offline

    Antybarrel

    In your code, in your main class.
     
    PerezHD likes this.
  5. Offline

    PerezHD

    Ok, that fixed the null pointer issue. Thanks!
     
    Last edited: Jan 16, 2015
Thread Status:
Not open for further replies.

Share This Page