亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

嘗試在我的服務器上運行腳本時發生錯誤

嘗試在我的服務器上運行腳本時發生錯誤

墨色風雨 2023-08-04 15:47:13
我正在嘗試開發一個派系插件,它為每個運行的命令運行一個腳本。因此,我有一個 CommandListner 腳本,它由 onEnable 中的 Main.java 激活,并且偵聽器使用參數來確定運行哪個命令并運行執行該命令的腳本。我已經嘗試了很多東西來解決這個問題,我記得錯誤更嚴重/更大,但我已經解決了其中的一部分。但我似乎無法找到解決方案。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;? ? }}
查看完整描述

1 回答

?
蕭十郎

TA貢獻1815條經驗 獲得超13個贊

您忘記將命令添加到您的plugin.yml(這會導致getCommand("f")返回null):


main: ...

version: ...

name: ...


commands:

? f:

查看完整回答
反對 回復 2023-08-04
  • 1 回答
  • 0 關注
  • 173 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號