- 欢迎来到Minecraft插件百科!
- 对百科编辑一脸懵逼?帮助:快速入门带您快速熟悉百科编辑!
- 因近日遭受攻击,百科现已限制编辑,有意编辑请加入插件百科企鹅群:223812289
PlotSquared/Dev:修订间差异
跳转到导航
跳转到搜索
第65行: | 第65行: | ||
} | } | ||
} | } | ||
</pre> | |||
===增加一个子命令=== | |||
当玩家输入 /plot help <category> 时会展示你增加的子命令。 | |||
CATEGORY 为你添加子命令时选择的类型 | |||
====增加命令==== | |||
下面是一个例子 | |||
<pre> | |||
@CommandDeclaration( | |||
// 你所添加命令的名字 | |||
command = "test", | |||
// 若要运行你所添加的命令,你需要的权限 | |||
permission = "plots.music", | |||
// 你所添加的命令的描述 | |||
description = "Player music in a plot", | |||
// 你所添加的命令的使用方法 | |||
usage = "/plot music", | |||
// 你所添加的命令的类型 | |||
category = CommandCategory.ACTIONS, | |||
// 需要的命令执行者 (NONE 允许控制台执行) | |||
requiredType = RequiredType.NONE | |||
) | |||
public class TestCommand extends SubCommand { | |||
public TestCommand() { | |||
// 你可以在这儿或者其他地方自定义命令 | |||
MainCommand.getInstance().addCommand(this); | |||
// Then just call: | |||
// new TestCommand(); | |||
// 在游戏中使用 : /plot test | |||
} | |||
// 下面是这个指令是干嘛的 | |||
@Override | |||
public boolean onCommand(final PlotPlayer player, final String[] args) { | |||
Location loc = player.getLocation(); | |||
Plot plot = Plot plot1 = MainUtil.getPlot(loc); | |||
if (plot1 == null) { | |||
sendMessage(player, C.NOT_IN_PLOT); | |||
return false; | |||
} | |||
Plot plot = MainUtil.getCurrentPlot(plr); | |||
MainUtil.sendMessage(player, "You are in plot " + plot.getId()); | |||
return true; | |||
} | |||
} | |||
====动态命令添加==== | |||
<pre> | |||
Command<PlotPlayer> cmd = new Command<PlotPlayer>(String command, String usage, String description, String permission, String[] aliases, RequiredType requiredType) { | |||
@Override | |||
public boolean onCommand(PlotPlayer plr, String[] arguments) { | |||
Location loc = player.getLocation(); | |||
Plot plot = Plot plot1 = MainUtil.getPlot(loc); | |||
if (plot1 == null) { | |||
sendMessage(player, C.NOT_IN_PLOT); | |||
return false; | |||
} | |||
Plot plot = MainUtil.getCurrentPlot(plr); | |||
MainUtil.sendMessage(player, "You are in plot " + plot.getId()); | |||
return true; | |||
} | |||
}; | |||
MainCommand.getInstance().addCommand(cmd); | |||
</pre> | </pre> | ||
2016年10月24日 (一) 11:50的版本
这里是PlotSquared的开发文档界面~
[原文地址]
有用的类
教程
使用Java语言编码
总览
- 脚本放到 PlotSquared/scripts 目录下
- 语言请使用Java语言
指令
- /plot debugexec run <script> [args...]
- /plot debugexec runasync <script> [args...]
- /plot debugexec
示例脚本
其他脚本
写了你自己的脚本?想发到这里?[欢迎!]
一个PlotSquared的附属插件实例
import com.intellectualcrafters.plot.api.PlotAPI;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.PluginManager;
public class Main extends JavaPlugin {
public PlotAPI api;
@Override
public void onEnable() {
PluginManager manager = Bukkit.getServer().getPluginManager();
final Plugin plotsquared = manager.getPlugin("PlotSquared");
// 如果插件没有安装的话就关闭这个插件
// If you move any PlotSquared related tasks to en external class you
// wouldn't have to disable the plugin if PlotSquared wasn't installed
if(plotsquared != null && !plotsquared.isEnabled()) {
PS.log(null, "&c[ExamplePlugin] Could not find PlotSquared! Disabling plugin...");
manager.disablePlugin(this);
return;
}
// Do PlotSquared related stuff
api = new PlotAPI();
// 现在你就可以使用这个API了
}
}
增加一个子命令
当玩家输入 /plot help <category> 时会展示你增加的子命令。
CATEGORY 为你添加子命令时选择的类型
增加命令
下面是一个例子
@CommandDeclaration(
// 你所添加命令的名字
command = "test",
// 若要运行你所添加的命令,你需要的权限
permission = "plots.music",
// 你所添加的命令的描述
description = "Player music in a plot",
// 你所添加的命令的使用方法
usage = "/plot music",
// 你所添加的命令的类型
category = CommandCategory.ACTIONS,
// 需要的命令执行者 (NONE 允许控制台执行)
requiredType = RequiredType.NONE
)
public class TestCommand extends SubCommand {
public TestCommand() {
// 你可以在这儿或者其他地方自定义命令
MainCommand.getInstance().addCommand(this);
// Then just call:
// new TestCommand();
// 在游戏中使用 : /plot test
}
// 下面是这个指令是干嘛的
@Override
public boolean onCommand(final PlotPlayer player, final String[] args) {
Location loc = player.getLocation();
Plot plot = Plot plot1 = MainUtil.getPlot(loc);
if (plot1 == null) {
sendMessage(player, C.NOT_IN_PLOT);
return false;
}
Plot plot = MainUtil.getCurrentPlot(plr);
MainUtil.sendMessage(player, "You are in plot " + plot.getId());
return true;
}
}
====动态命令添加====
<pre>
Command<PlotPlayer> cmd = new Command<PlotPlayer>(String command, String usage, String description, String permission, String[] aliases, RequiredType requiredType) {
@Override
public boolean onCommand(PlotPlayer plr, String[] arguments) {
Location loc = player.getLocation();
Plot plot = Plot plot1 = MainUtil.getPlot(loc);
if (plot1 == null) {
sendMessage(player, C.NOT_IN_PLOT);
return false;
}
Plot plot = MainUtil.getCurrentPlot(plr);
MainUtil.sendMessage(player, "You are in plot " + plot.getId());
return true;
}
};
MainCommand.getInstance().addCommand(cmd);
开发的东西
[源代码]
特有词汇