mirror of
https://e.coding.net/circlecloud/SimpleEssential.git
synced 2024-11-17 01:18:47 +00:00
fix Plugin Command handle error...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
parent
6c4009a0ce
commit
a821285ac3
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>cn.citycraft</groupId>
|
<groupId>cn.citycraft</groupId>
|
||||||
<artifactId>SimpleEssential</artifactId>
|
<artifactId>SimpleEssential</artifactId>
|
||||||
<version>1.4</version>
|
<version>1.4.1</version>
|
||||||
<name>SimpleEssential</name>
|
<name>SimpleEssential</name>
|
||||||
<description>轻量级基础插件</description>
|
<description>轻量级基础插件</description>
|
||||||
<build>
|
<build>
|
||||||
|
@ -3,17 +3,12 @@
|
|||||||
*/
|
*/
|
||||||
package cn.citycraft.SimpleEssential;
|
package cn.citycraft.SimpleEssential;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandException;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import cn.citycraft.PluginHelper.commands.BaseCommand;
|
import cn.citycraft.PluginHelper.commands.HandlerMainCommand;
|
||||||
import cn.citycraft.PluginHelper.config.FileConfig;
|
import cn.citycraft.PluginHelper.config.FileConfig;
|
||||||
import cn.citycraft.PluginHelper.utils.VersionChecker;
|
import cn.citycraft.PluginHelper.utils.VersionChecker;
|
||||||
import cn.citycraft.SimpleEssential.command.CommandBack;
|
import cn.citycraft.SimpleEssential.command.CommandBack;
|
||||||
@ -47,42 +42,30 @@ public class SimpleEssential extends JavaPlugin {
|
|||||||
* 传送控制
|
* 传送控制
|
||||||
*/
|
*/
|
||||||
public TeleportControl tpcontrol;
|
public TeleportControl tpcontrol;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 命令监听列表
|
* 命令监听列表
|
||||||
*/
|
*/
|
||||||
private List<BaseCommand> commandlist;
|
|
||||||
FileConfig config;
|
FileConfig config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 命令处理
|
||||||
|
*/
|
||||||
|
HandlerMainCommand hmc;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
|
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
|
||||||
for (final BaseCommand command : commandlist) {
|
if (!hmc.onCommand(sender, cmd, label, args)) {
|
||||||
if (command.isValidTrigger(label)) {
|
hmc.sendHelp(sender);
|
||||||
if (!command.hasPermission(sender)) {
|
}
|
||||||
sender.sendMessage(I18n.p("Base.no-permission"));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (command.isOnlyPlayerExecutable() && !(sender instanceof Player)) {
|
|
||||||
sender.sendMessage(I18n.p("Base.playercommand"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length >= command.getMinimumArguments()) {
|
|
||||||
try {
|
|
||||||
command.execute(sender, cmd, label, args);
|
|
||||||
return true;
|
|
||||||
} catch (final CommandException e) {
|
|
||||||
sender.sendMessage(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
this.initTeleportControl();
|
this.initTeleportControl();
|
||||||
this.registerCommands();
|
|
||||||
this.registerEvents();
|
this.registerEvents();
|
||||||
|
this.registerCommands();
|
||||||
new VersionChecker(this);
|
new VersionChecker(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,37 +76,27 @@ public class SimpleEssential extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册命令
|
* 注册插件主要命令
|
||||||
*
|
|
||||||
* @param command
|
|
||||||
* - 被注册的命令类
|
|
||||||
*/
|
|
||||||
public void registerCommand(final BaseCommand command) {
|
|
||||||
commandlist.add(command);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 注册命令
|
|
||||||
*/
|
*/
|
||||||
public void registerCommands() {
|
public void registerCommands() {
|
||||||
commandlist = new ArrayList<BaseCommand>();
|
hmc = new HandlerMainCommand(this);
|
||||||
registerCommand(new CommandTpa(this));
|
hmc.registerCommand(new CommandTpa(this));
|
||||||
registerCommand(new CommandTop(this));
|
hmc.registerCommand(new CommandTop(this));
|
||||||
registerCommand(new CommandTpaccept(this));
|
hmc.registerCommand(new CommandTpaccept(this));
|
||||||
registerCommand(new CommandTpdeny(this));
|
hmc.registerCommand(new CommandTpdeny(this));
|
||||||
registerCommand(new CommandTphere(this));
|
hmc.registerCommand(new CommandTphere(this));
|
||||||
registerCommand(new CommandBack(this));
|
hmc.registerCommand(new CommandBack(this));
|
||||||
registerCommand(new CommandSetHome(this));
|
hmc.registerCommand(new CommandSetHome(this));
|
||||||
registerCommand(new CommandHome(this));
|
hmc.registerCommand(new CommandHome(this));
|
||||||
registerCommand(new CommandHat(this));
|
hmc.registerCommand(new CommandHat(this));
|
||||||
registerCommand(new CommandSuicide(this));
|
hmc.registerCommand(new CommandSuicide(this));
|
||||||
registerCommand(new CommandEnchantBench(this));
|
hmc.registerCommand(new CommandEnchantBench(this));
|
||||||
registerCommand(new CommandWorkBench(this));
|
hmc.registerCommand(new CommandWorkBench(this));
|
||||||
registerCommand(new CommandSetSpawn(this));
|
hmc.registerCommand(new CommandSetSpawn(this));
|
||||||
registerCommand(new CommandSpawn(this));
|
hmc.registerCommand(new CommandSpawn(this));
|
||||||
registerCommand(new CommandGc(this));
|
hmc.registerCommand(new CommandGc(this));
|
||||||
registerCommand(new CommandWorld(this));
|
hmc.registerCommand(new CommandWorld(this));
|
||||||
registerCommand(new CommandPing(this));
|
hmc.registerCommand(new CommandPing(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user