0

I has an error if players use ShopGUI+ Plugin to buy or sell, it will error in consoler! Plugin ShopGUI+: https://www.spigotmc.org/resources/shopgui.6515/ Error console: http://pastebin.com/Q1Hjssfm Please help me. Thanks!

class: package com.andrewyunt.townygui.listeners;   
import com.andrewyunt.townygui.Menu; 
import com.andrewyunt.townygui.TownyGUI; 
import com.andrewyunt.townygui.utilities.CommandBuilder; 
import com.gmail.filoghost.hiddenstring.HiddenStringUtils; 
import org.bukkit.command.CommandSender; 
import org.bukkit.entity.Player; 
import org.bukkit.event.EventHandler; 
import org.bukkit.event.Listener; 
import org.bukkit.event.inventory.InventoryClickEvent; 
import org.bukkit.inventory.ItemStack; 
import org.bukkit.inventory.meta.ItemMeta;   
import java.util.List; 
import java.util.Set;   

public class InventoryListener implements Listener {

@EventHandler
public void onInventoryClick(InventoryClickEvent sukien) {

    ItemStack item = sukien.getCurrentItem();

    Player player = (Player) sukien.getWhoClicked();

    if(!(sukien.getInventory().getHolder() == null))
        return;

    if(item == null || !item.hasItemMeta())
        return;

    ItemMeta meta = item.getItemMeta();
    List<String> lore = meta.getLore();

    if(!HiddenStringUtils.hasHiddenString(lore.get(0)))
        return;

    String action = HiddenStringUtils.extractHiddenString(lore.get(0));

    boolean command;

    command = action.startsWith("/");

    if(!command)
        new Menu(player, action);
    else {
        player.closeInventory();

        Set<String> arguments;
        try {
            arguments = TownyGUI.plugin.commandConfig.getConfig().getConfigurationSection("commands."+ action + ".arguments").getKeys(false);
        } catch(NullPointerException e) {
            action = action.replace("/", "");
            TownyGUI.plugin.server.dispatchCommand(player, action);
            sukien.setCancelled(true);
            return;
        }

        new CommandBuilder(arguments, action).beginConversation((CommandSender) player);
    }

    sukien.setCancelled(true);
} }
tmthydvnprt
  • 10,398
  • 8
  • 52
  • 72

1 Answers1

0

As far as the NullPointerException you provided goes, this is the line that causes the error:

String action = HiddenStringUtils.extractHiddenString(lore.get(0));

You should be able to check why it results in a NullPointerException.

I guess the event-error you get will be resolved as soon as you fix your code.

Also the first link you provided does not work without being logged in.

Meik Vtune
  • 450
  • 8
  • 25