如果玩家使用ShopGUI + Plugin购买或出售我有错误,它会在安慰中出错!插件ShopGUI +: https://www.spigotmc.org/resources/shopgui.6515/错误控制台:http://pastebin.com/Q1Hjssfm请帮帮我。谢谢!
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);
} }
答案 0 :(得分:0)
就你提供的NullPointerException而言,这是导致错误的行:
String action = HiddenStringUtils.extractHiddenString(lore.get(0));
您应该能够检查它导致NullPointerException的原因。
我猜您修复代码后会立即解决您收到的事件错误。
如果没有登录,您提供的第一个链接也无法使用。