我正在嘗試開發(fā)一個(gè)派系插件,它為每個(gè)運(yùn)行的命令運(yùn)行一個(gè)腳本。因此,我有一個(gè) CommandListner 腳本,它由 onEnable 中的 Main.java 激活,并且偵聽器使用參數(shù)來確定運(yùn)行哪個(gè)命令并運(yùn)行執(zhí)行該命令的腳本。我已經(jīng)嘗試了很多東西來解決這個(gè)問題,我記得錯(cuò)誤更嚴(yán)重/更大,但我已經(jīng)解決了其中的一部分。但我似乎無法找到解決方案。package net.evolvedmc.evolvedfactions.commands;import java.awt.Color;import org.bukkit.command.Command;import org.bukkit.command.CommandExecutor;import org.bukkit.command.CommandSender;import org.bukkit.entity.Player;import net.evolvedmc.evolvedfactions.Main;public class CommandListner implements CommandExecutor {? ??? ? private Main plugin;? ??? ? public CommandListner(Main plugin) {? ? ? ??? ? ? ? //Listens for the /f command? ? ? ? this.plugin = plugin;? ? ? ? String STRBaseCMD = "f";? ? ? ? System.out.println("[EvolvedFactions] Listning for command '" + STRBaseCMD + "' with executor " + this);? ? ? ? plugin.getCommand(STRBaseCMD).setExecutor(this);? ? ? ??? ? }? ??? ? @Override? ? public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {? ? ? ??? ? ? ? //Defines our player? ? ? ? Player player = (Player) sender;? ? ? ??? ? ? ? //checks if the player has given enough arguments? ? ? ? if(args.length == 0) {? ? ? ? ? ? player.sendMessage(Color.RED + "Correct usage: /f <arg>");? ? ? ? ? ? return false;? ? ? ? }? ? ? ??? ? ? ? //checks if our argument is help? ? ? ? if(args[0].equalsIgnoreCase("help")) {? ? ? ? ? ??? ? ? ? ? ? //checks if the player has the permission to execute this command? ? ? ? ? ? if(player.hasPermission("evolvedfactions.default.help")) {? ? ? ? ? ? ? ??? ? ? ? ? ? ? ? //loads the script which executes the command? ? ? ? ? ? ? ? player.sendMessage("BomPom");? ? ? ? ? ? ? ? new HelpCommand(this, player);? ? ? ? ? ? ? ? return true;? ? ? ? ? ? ? ??? ? ? ? ? ? } else {? ? ? ? ? ? ? ? player.sendMessage("You do not have permission to execute this command.");? ? ? ? ? ? }? ? ? ? ? ??? ? ? ? ? ??? ? ? ? }? ? ? ??? ? ? ? return false;? ? }}
嘗試在我的服務(wù)器上運(yùn)行腳本時(shí)發(fā)生錯(cuò)誤
墨色風(fēng)雨
2023-08-04 15:47:13