java - 从 BungeeCord 中的 Spigot 执行命令
问题描述
我需要从 BungeeCord 的 Spigot 执行命令,但我不知道该怎么做。我使用了更多功能……例如 Forward Channel、Message Channel、BungeeCord.getInstance().dispatchCommand、ProxyServer.getInstance().dispatchCommand。这些选项都不起作用。顺便说一下 BungeeCord[..].dispatchCommand i ProxyServer 在控制台中发送错误。我第一次使用 BungeeCord API。我正在寻找更多选择,也许我使用了一个糟糕的 api。
解决方案
You will have to use the Messaging Channels directly from Spigot and send information to BungeeCord with that.
Here is a little example on how you want to do this :
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
try {
out.writeUTF("Message");
out.writeUTF("ALL");
out.writeUTF("/alert Testing command distance");
} catch(Exception e) {
e.printStackTrace();
}
p.sendPluginMessage(getPlugin(), "BungeeCord", b.toByteArray());
You can of course change the information you want to send, here is the official wiki about messaging channels : https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/#message
PS: You have to register the Channel in your onEnable()
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
推荐阅读
- ag-grid - ag-grid-vue:是否有保证在 onGridReady 和 onFirstDataRendered 之前触发的事件?
- python - 对于大型数据库,在 sqlite 中更新 NULL 太慢了
- vue.js - 如何在主 JS 包加载之前加载 Sentry?
- reactjs - 试图在反应js中将值从子组件传递给父组件
- c# - 如何从托管在 iis 上的 Asp.net 项目运行 Exe 文件
- node.js - 当我尝试安装角度错误时
- ruby-on-rails - rails-latex gem: ActionView::Template::Error (rails-latex failed ...) with Heroku
- java - 运行 Spark 的 Google Cloud Platform 抛出错误 - 未找到数据库“默认”
- flutter - 如何在 Flutter 中缓存 API 调用的响应?
- r - 如何读取 .tar.xz 文件?