mirror of
https://e.coding.net/circlecloud/SimpleEssential.git
synced 2024-11-16 01:08:46 +00:00
Merge pull request #1 from diauweb/master
add ConsoleCommandSender check...
This commit is contained in:
commit
809e6f5cec
@ -10,6 +10,7 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandException;
|
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;
|
||||||
|
|
||||||
@ -48,6 +49,8 @@ public class SimpleEssential extends JavaPlugin {
|
|||||||
if (!command.hasPermission(sender)) {
|
if (!command.hasPermission(sender)) {
|
||||||
sender.sendMessage(ChatColor.RED + "你没有此命令的权限.");
|
sender.sendMessage(ChatColor.RED + "你没有此命令的权限.");
|
||||||
return true;
|
return true;
|
||||||
|
}else if(command.isOnlyPlayerExecutable() && !(sender instanceof Player)){
|
||||||
|
sender.sendMessage(ChatColor.RED + "此命令只能由玩家执行.");
|
||||||
}
|
}
|
||||||
if (args.length >= command.getMinimumArguments()) {
|
if (args.length >= command.getMinimumArguments()) {
|
||||||
try {
|
try {
|
||||||
|
@ -23,6 +23,9 @@ public class CommandBack extends SimpleEssentialCommand {
|
|||||||
this.plugin = main;
|
this.plugin = main;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOnlyPlayerExecutable() {return true;};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||||
plugin.tpcontrol.back((Player) sender);
|
plugin.tpcontrol.back((Player) sender);
|
||||||
|
@ -24,6 +24,9 @@ public class CommandHome extends SimpleEssentialCommand {
|
|||||||
this.plugin = main;
|
this.plugin = main;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOnlyPlayerExecutable() {return true;};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
|
@ -25,6 +25,9 @@ public class CommandSetHome extends SimpleEssentialCommand {
|
|||||||
this.plugin = main;
|
this.plugin = main;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOnlyPlayerExecutable() {return true;};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
|
@ -26,6 +26,9 @@ public class CommandTop extends SimpleEssentialCommand {
|
|||||||
this.plugin = main;
|
this.plugin = main;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOnlyPlayerExecutable() {return true;};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPossibleArguments() {
|
public String getPossibleArguments() {
|
||||||
return "";
|
return "";
|
||||||
|
@ -27,6 +27,9 @@ public class CommandTpa extends SimpleEssentialCommand {
|
|||||||
this.plugin = main;
|
this.plugin = main;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOnlyPlayerExecutable() {return true;};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPossibleArguments() {
|
public String getPossibleArguments() {
|
||||||
return "<目标玩家>";
|
return "<目标玩家>";
|
||||||
|
@ -25,6 +25,9 @@ public class CommandTpaccept extends SimpleEssentialCommand {
|
|||||||
this.plugin = main;
|
this.plugin = main;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOnlyPlayerExecutable() {return true;};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPossibleArguments() {
|
public String getPossibleArguments() {
|
||||||
return "";
|
return "";
|
||||||
|
@ -25,6 +25,9 @@ public class CommandTpdeny extends SimpleEssentialCommand {
|
|||||||
this.plugin = main;
|
this.plugin = main;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOnlyPlayerExecutable() {return true;};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPossibleArguments() {
|
public String getPossibleArguments() {
|
||||||
return "";
|
return "";
|
||||||
|
@ -38,6 +38,9 @@ public class CommandTphere extends SimpleEssentialCommand {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOnlyPlayerExecutable() {return true;};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMinimumArguments() {
|
public int getMinimumArguments() {
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -94,6 +94,11 @@ public abstract class SimpleEssentialCommand {
|
|||||||
*/
|
*/
|
||||||
public abstract void execute(CommandSender sender, String label, String[] args) throws CommandException;
|
public abstract void execute(CommandSender sender, String label, String[] args) throws CommandException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否只有玩家才能执行此命令
|
||||||
|
*/
|
||||||
|
public abstract boolean isOnlyPlayerExecutable();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 命令匹配检测
|
* 命令匹配检测
|
||||||
*
|
*
|
||||||
|
@ -57,6 +57,12 @@ commands:
|
|||||||
usage: §b使用/sethome 设置当前位置为家!
|
usage: §b使用/sethome 设置当前位置为家!
|
||||||
permission: se.sethome
|
permission: se.sethome
|
||||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||||
|
suicide:
|
||||||
|
description: 自杀
|
||||||
|
aliases: [sesuicide,sd]
|
||||||
|
usage: §b使用/suicide结束自己的生命!
|
||||||
|
permission: se.suicide
|
||||||
|
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||||
permissions:
|
permissions:
|
||||||
se.*:
|
se.*:
|
||||||
description: 简单基础插件所有权限!
|
description: 简单基础插件所有权限!
|
||||||
@ -72,4 +78,5 @@ permissions:
|
|||||||
se.tpaccept: true
|
se.tpaccept: true
|
||||||
se.tpdeny: true
|
se.tpdeny: true
|
||||||
se.back: true
|
se.back: true
|
||||||
|
se.suicide: true
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user