@EventHandler
public void onCommandProcess(PlayerCommandPreprocessEvent e) {
String entryLabel = e.getMessage().split(" ")[0].replace("/", "");
String[] entryArgs = e.getMessage().replace(entryLabel, "").split(" ");
if (!commands.containsKey(entryLabel))
return;
CommandMethod commandMethod = commands.get(entryLabel);
if (entryArgs.length < commandMethod.getCommand().minimumArgs())
return;
if (entryLabel.equals(commandMethod.getCommand().commandLabel()))
try {
commandMethod.getMethod().invoke(commandMethod.getObject(), e.getPlayer(), entryArgs);
} catch (IllegalAccessException | InvocationTargetException ex) {
Bukkit.getLogger().log(Level.SEVERE, String.format("Couldn't invoke %s method.", commandMethod.getMethod().getName()), ex);
}
}
CommandHandler.java 文件源码
java
阅读 212
收藏 0
点赞 0
评论 0
项目:pine-commons
作者:
评论列表
文章目录