本文整理汇总了Java中org.bukkit.event.server.ServerCommandEvent类的典型用法代码示例。如果您正苦于以下问题:Java ServerCommandEvent类的具体用法?Java ServerCommandEvent怎么用?Java ServerCommandEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ServerCommandEvent类属于org.bukkit.event.server包,在下文中一共展示了ServerCommandEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onServerCmd
import org.bukkit.event.server.ServerCommandEvent; //导入依赖的package包/类
@EventHandler
public void onServerCmd(ServerCommandEvent e){
String[] args = e.getCommand().replace("/", "").split(" ");
String msg = null;
if (e.getCommand().length() > args[0].length()+1){
msg = e.getCommand().substring(args[0].length()+1);
}
if (UChat.get().getUCConfig().getTellAliases().contains(args[0])){
if (args.length >= 3){
Player p = UChat.get().getServer().getPlayer(args[1]);
if (p == null || !p.isOnline()){
UChat.get().getLang().sendMessage(e.getSender(), "listener.invalidplayer");
return;
}
msg = msg.substring(args[1].length()+1);
UChat.get().tempTellPlayers.put("CONSOLE", p.getName());
UChat.get().command.add("CONSOLE");
sendPreTell(UChat.get().getServer().getConsoleSender(), p, msg);
e.setCancelled(true);
}
}
}
示例2: onServerCommand
import org.bukkit.event.server.ServerCommandEvent; //导入依赖的package包/类
@SuppressWarnings("null")
@EventHandler(priority = EventPriority.HIGHEST)
public void onServerCommand(final ServerCommandEvent e) {
if (e.getCommand() == null || e.getCommand().isEmpty())
return;
if (SkriptConfig.enableEffectCommands.value() && e.getCommand().startsWith(SkriptConfig.effectCommandToken.value())) {
if (handleEffectCommand(e.getSender(), e.getCommand())) {
e.setCommand("");
suppressUnknownCommandMessage = true;
}
return;
}
if (handleCommand(e.getSender(), e.getCommand())) {
e.setCommand("");
suppressUnknownCommandMessage = true;
}
}
示例3: onCommand
import org.bukkit.event.server.ServerCommandEvent; //导入依赖的package包/类
@HookHandler(priority = Priority.CRITICAL)
public void onCommand(final ConsoleCommandHook hook) {
String command = "";
for (String s : hook.getCommand()) {
command += s + " ";
}
server.getPluginManager().callEvent(new ServerCommandEvent(new CanaryCommandSender(hook.getCaller()), command) {
@Override
public void setCommand(String msg) {
super.setCommand(msg);
// Set command
}
});
if (server.dispatchCommand(new CanaryCommandSender(hook.getCaller()), command)) {
hook.setCanceled();
}
}
示例4: aB
import org.bukkit.event.server.ServerCommandEvent; //导入依赖的package包/类
public void aB() {
SpigotTimings.serverCommandTimer.startTiming(); // Spigot
while (!this.j.isEmpty()) {
ServerCommand servercommand = (ServerCommand) this.j.remove(0);
// CraftBukkit start - ServerCommand for preprocessing
ServerCommandEvent event = new ServerCommandEvent(this.console, servercommand.command);
this.server.getPluginManager().callEvent(event);
servercommand = new ServerCommand(event.getCommand(), servercommand.source);
// this.getCommandHandler().a(servercommand.source, servercommand.command); // Called in dispatchServerCommand
this.server.dispatchServerCommand(this.console, servercommand);
// CraftBukkit end
}
SpigotTimings.serverCommandTimer.stopTiming(); // Spigot
}
示例5: onAction
import org.bukkit.event.server.ServerCommandEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onAction(ServerCommandEvent e) {
boolean isAction = false;
String commandUsed = "";
for (String start : Config.actionAliases) {
start = start.substring(1);
if (!e.getCommand().startsWith(start)) continue;
commandUsed = start;
isAction = true;
break;
}
if (!isAction) return;
String message = Config.btiAction;
message = message.replace("{name}", e.getSender().getName());
message = message.replace("{message}", e.getCommand().substring(commandUsed.length()));
plugin.bh.sendMessage(message);
}
示例6: onSay
import org.bukkit.event.server.ServerCommandEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onSay(ServerCommandEvent e) {
boolean isAction = false;
String commandUsed = "";
for (String start : Config.sayAliases) {
start = start.substring(1);
if (!e.getCommand().startsWith(start)) continue;
commandUsed = start;
isAction = true;
break;
}
if (!isAction) return;
String message = Config.btiSay;
message = message.replace("{name}", e.getSender().getName());
message = message.replace("{message}", e.getCommand().substring(commandUsed.length()));
plugin.bh.sendMessage(message);
}
示例7: aL
import org.bukkit.event.server.ServerCommandEvent; //导入依赖的package包/类
public void aL() {
SpigotTimings.serverCommandTimer.startTiming(); // Spigot
while (!this.serverCommandQueue.isEmpty()) {
ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0);
// CraftBukkit start - ServerCommand for preprocessing
ServerCommandEvent event = new ServerCommandEvent(console, servercommand.command);
server.getPluginManager().callEvent(event);
if (event.isCancelled()) continue;
servercommand = new ServerCommand(event.getCommand(), servercommand.source);
// this.getCommandHandler().a(servercommand.source, servercommand.command); // Called in dispatchServerCommand
server.dispatchServerCommand(console, servercommand);
// CraftBukkit end
}
SpigotTimings.serverCommandTimer.stopTiming(); // Spigot
}
示例8: onCommand
import org.bukkit.event.server.ServerCommandEvent; //导入依赖的package包/类
@EventHandler
public final void onCommand(ServerCommandEvent e) {
String[] array = e.getCommand().split(" ");
String[] args = new String[array.length-1];
for(int i = 0; i < args.length; i++) {
args[i] = array[i+1];
}
String cmd = array[0].replaceFirst("/", "");
if(commands.containsKey(cmd.toLowerCase())) {
commands.get(cmd.toLowerCase()).execute(e.getSender(), cmd, args);
e.setCommand("emptycommand");
}
}
示例9: onServerCommand
import org.bukkit.event.server.ServerCommandEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onServerCommand (ServerCommandEvent event)
{
String command = event.getCommand().toLowerCase();
if (command.equals("/p reload") || command.equals("/bp reload")
|| command.equals("/perm reload")
|| command.equals("/permissions reload"))
{
final CommandSender sender = event.getSender();
plugin.getServer().getScheduler()
.scheduleSyncDelayedTask(plugin, new Runnable()
{
public void run ()
{
plugin.refreshCache(sender);
}
}, 1L);
return;
}
}
示例10: onServerCommand
import org.bukkit.event.server.ServerCommandEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onServerCommand(ServerCommandEvent evt) {
evt.setCancelled(handleCommand(evt.getSender(), CommandType.SLASH, CommandType.SLASH.getPrefix() + evt.getCommand()) // Handle console commands.
|| handleCommand(evt.getSender(), CommandType.COMMAND_BLOCK, evt.getCommand())); // Command Block commands.
if (evt.getCommand().startsWith("/ ")) {
sendStaffChat(evt.getSender(), evt.getCommand().substring(2));
evt.setCancelled(true);
}
}
示例11: onCommand
import org.bukkit.event.server.ServerCommandEvent; //导入依赖的package包/类
@EventHandler
public void onCommand(ServerCommandEvent event) {
String msg = "/" + event.getCommand();
CommandSender sender = event.getSender();
this.handle(msg, sender, event);
}
示例12: processCommands
import org.bukkit.event.server.ServerCommandEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void processCommands(ServerCommandEvent evt) {
if (evt.isCancelled() || evt.isAsynchronous()) return;
Command cmd = CommandFactory.commands.get(evt.getCommand());
if (cmd == null || cmd instanceof PlayerOnly) return;
cmd.run(evt.getSender());
}
示例13: onBroadcastCommand
import org.bukkit.event.server.ServerCommandEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onBroadcastCommand(ServerCommandEvent event) {
String cmd = ChatColor.stripColor(event.getCommand());
if (cmd.equals("broadcast ") || cmd.equals("bc ")) {
String msg = cmd.split(" ", 2)[1];
messenger.sendMessageToAllBoundChannel("\uD83D\uDCE2 " + msg);
boolean seeBc = configsManager.getModChannelConfig().getBoolean("See_Broadcast");
if(seeBc) {
messenger.sendMessageToAllModChannel("\uD83D\uDCE2 " + msg );
}
}
}
示例14: on
import org.bukkit.event.server.ServerCommandEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void on(ServerCommandEvent event)
{
String command = event.getCommand();
if (intercept(event.getSender(), command, event))
{
event.setCommand(collapse(command));
}
}
示例15: init
import org.bukkit.event.server.ServerCommandEvent; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) {
what = matchedPattern;
if (!ScriptLoader.isCurrentEvent(PlayerCommandPreprocessEvent.class, ServerCommandEvent.class)) {
if (what != ARGS) // ExprArgument has the same syntax
Skript.error("The 'command' expression can only be used in a command event");
return false;
}
return true;
}