因此,我正在尝试制作一个标签插件,说实话,这主要是出于无聊,但也出于实践目的。我在设置用户标签时出错,将不胜感激,可以在下面找到所有我认为相关的代码(伴随控制台错误),但是如果您需要更多,请问问,谢谢你提前。
注意:除了设置后缀(“主页”中的“ 56”行)外,其他所有方法都正常运行
控制台错误:
25.07 22:17:46 [Server] ERROR Could not pass event InventoryClickEvent to Tags v1.0
25.07 22:17:46 [Server] INFO org.bukkit.event.EventException: null
25.07 22:17:46 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot.jar:git-Spigot-2086bb0-2f3ed3b]
25.07 22:17:46 [Server] INFO at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-2086bb0-2f3ed3b]
25.07 22:17:46 [Server] INFO at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:500) [spigot.jar:git-Spigot-2086bb0-2f3ed3b]
25.07 22:17:46 [Server] INFO at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:485) [spigot.jar:git-Spigot-2086bb0-2f3ed3b]
25.07 22:17:46 [Server] INFO at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1889) [spigot.jar:git-Spigot-2086bb0-2f3ed3b]
25.07 22:17:46 [Server] INFO at net.minecraft.server.v1_12_R1.PacketPlayInWindowClick.a(SourceFile:33) [spigot.jar:git-Spigot-2086bb0-2f3ed3b]
25.07 22:17:46 [Server] INFO at net.minecraft.server.v1_12_R1.PacketPlayInWindowClick.a(SourceFile:10) [spigot.jar:git-Spigot-2086bb0-2f3ed3b]
25.07 22:17:46 [Server] INFO at net.minecraft.server.v1_12_R1.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-2086bb0-2f3ed3b]
25.07 22:17:46 [Server] INFO at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_161]
25.07 22:17:46 [Server] INFO at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_161]
25.07 22:17:46 [Server] INFO at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [spigot.jar:git-Spigot-2086bb0-2f3ed3b]
25.07 22:17:46 [Server] INFO at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:748) [spigot.jar:git-Spigot-2086bb0-2f3ed3b]
25.07 22:17:46 [Server] INFO at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:406) [spigot.jar:git-Spigot-2086bb0-2f3ed3b]
25.07 22:17:46 [Server] INFO at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [spigot.jar:git-Spigot-2086bb0-2f3ed3b]
25.07 22:17:46 [Server] INFO at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [spigot.jar:git-Spigot-2086bb0-2f3ed3b]
25.07 22:17:46 [Server] INFO at java.lang.Thread.run(Unknown Source) [?:1.8.0_161]
25.07 22:17:46 [Server] INFO Caused by: java.lang.NoClassDefFoundError: net/milkbowl/vault/chat/Chat
25.07 22:17:46 [Server] INFO at me.askingg.gui.HomePage.HomePageClick(HomePage.java:56) ~[?:?]
25.07 22:17:46 [Server] INFO at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_161]
25.07 22:17:46 [Server] INFO at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_161]
25.07 22:17:46 [Server] INFO at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_161]
25.07 22:17:46 [Server] INFO at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_161]
25.07 22:17:46 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigot.jar:git-Spigot-2086bb0-2f3ed3b]
25.07 22:17:46 [Server] INFO ... 15 more
主班: 打包me.askingg.tags;
import java.io.File;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import me.askingg.commands.CommandsClass;
import me.askingg.gui.HomePage;
import me.askingg.utils.FileControl;
import net.milkbowl.vault.chat.Chat;
public class Main extends JavaPlugin {
@SuppressWarnings("unused")
private CommandsClass cmds;
public static Main pl;
public Main main;
private FileControl fc;
public static Chat chat = null;
public static String prefix = "&8(&bTags&8) &3&l» ";
public void onEnable() {
pl = this;
fc = new FileControl(new File(getDataFolder(), "config.yml"));
getServer().getPluginManager().registerEvents(new HomePage(), this);
cmds = new CommandsClass(this);
}
public FileControl getFileControl() {
return this.fc;
}
@SuppressWarnings("unused")
private boolean setupChat()
{
RegisteredServiceProvider<Chat> chatProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.chat.Chat.class);
if (chatProvider != null) {
chat = chatProvider.getProvider();
}
return (chat != null);
}
}
首页类(广告资源):
package me.askingg.gui;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import me.askingg.tags.Main;
import me.askingg.utils.ItemCreator;
import me.askingg.utils.Utils;
public class HomePage implements Listener {
public static String homePageName = Utils.chat(Main.pl.getFileControl().getConfig().getString("Pages.HomePage.Title"));
public static String homePageSizeString = Main.pl.getFileControl().getConfig().getString("Pages.HomePage.Size");
public static Integer homePageSize = Integer.parseInt(homePageSizeString);
public static List<Player> homePageOpened = new ArrayList<>();
public static Inventory HomePageInventory(Player p) {
Inventory homePg = Bukkit.createInventory(null, homePageSize, (homePageName));
homePg.setItem(10, new ItemCreator(Material.NAME_TAG).setDisplayname("&b&ki&9Cunt&b&ki&f").getItem());
return homePg;
}
@EventHandler
public static void HomePageClick(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
ItemStack clicked = event.getCurrentItem();
String inventory = event.getInventory().getTitle();
if (inventory.equals(homePageName)) {
if (!(homePageOpened.contains(player))) return;
if (clicked.getType().equals(Material.AIR)) return;
event.setCancelled(true);
if (clicked.getType().equals(Material.NAME_TAG)) {
if (clicked.getItemMeta().getDisplayName().equals(Utils.chat("&b&ki&9Cunt&b&ki&f"))) {
player.sendMessage(Utils.chat(Main.prefix + "&fYou applied the &b&ki&9Teste&b&ki&f tag"));
Main.chat.setPlayerSuffix(player, Utils.chat("&b&ki&9Teste&b&ki&f"));
return;
}
}
}
}
@EventHandler
public static void HomePageClosed(InventoryCloseEvent event) {
Player player = (Player) event.getPlayer();
String inventory = event.getInventory().getTitle();
if (inventory.equals(homePageName)) {
if (homePageOpened.contains(player)) {
homePageOpened.remove(player);
}
}
}
}