org.bukkit.event.server.ServerCommandEvent#setCancelled ( )源码实例Demo

下面列出了org.bukkit.event.server.ServerCommandEvent#setCancelled ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: mcspring-boot   文件: CommandInterceptor.java
@EventHandler
void onServerCommand(ServerCommandEvent event) {
    if (event.isCancelled() || commandService.isRegistered()) return;
    val sender = context.getSender();
    val result = commandExecutor.execute(event.getCommand().split(" "));
    event.setCancelled(result.isExists());
    result.getOutput().forEach(sender::sendMessage);
}
 
源代码2 项目: TrMenu   文件: ListenerTabooLibUpdateCommand.java
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onCommand(ServerCommandEvent e) {
    if ("tlibupdate".equalsIgnoreCase(e.getCommand())) {
        e.setCancelled(true);
        e.getSender().sendMessage("§8[§fTabooLib§8] §cWARNING §7| §4Update TabooLib will force to restart your server. Please confirm this action by type §c/tlibupdateConfirm");
    } else if ("tlibupdateConfirm".equalsIgnoreCase(e.getCommand()) || "tlibupdate confirm".equalsIgnoreCase(e.getCommand())) {
        e.setCommand("tlibupdatebbb");
        update(e.getSender());
    }
}
 
源代码3 项目: TabooLib   文件: ListenerCommand.java
@EventHandler(priority = EventPriority.LOWEST)
public void cmd(ServerCommandEvent e) {
    if (e.getCommand().equalsIgnoreCase("saveFiles")) {
        Local.saveFiles();
        LocalPlayer.saveFiles();
        TLogger.getGlobalLogger().info("Successfully.");
    } else if (e.getCommand().equalsIgnoreCase("tDebug")) {
        if (TabooLibAPI.isDebug()) {
            TabooLibAPI.debug(false);
            TLogger.getGlobalLogger().info("&cDisabled.");
        } else {
            TabooLibAPI.debug(true);
            TLogger.getGlobalLogger().info("&aEnabled.");
        }
    } else if (e.getCommand().equalsIgnoreCase("libUpdate")) {
        e.setCancelled(true);
        e.getSender().sendMessage("§8[§fTabooLib§8] §cWARNING §7| §4Update TabooLib will force to restart your server. Please confirm this action by type §c/libupdateconfirm");
    } else if (e.getCommand().equalsIgnoreCase("libUpdateConfirm") || e.getCommand().equalsIgnoreCase("libUpdate confirm")) {
        e.getSender().sendMessage("§8[§fTabooLib§8] §7Downloading TabooLib file...");
        Files.downloadFile("https://skymc.oss-cn-shanghai.aliyuncs.com/plugins/TabooLib.jar", new File("libs/TabooLib.jar"));
        e.getSender().sendMessage("§8[§fTabooLib§8] §2Download completed, the server will restart in 3 secs");
        try {
            Thread.sleep(3000L);
        } catch (InterruptedException e1) {
            e1.printStackTrace();
        }
        Bukkit.shutdown();
    }
}
 
源代码4 项目: Skript   文件: Commands.java
@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.setCancelled(true);
		}
		return;
	}
}
 
源代码5 项目: UltimateChat   文件: UCListener.java
@EventHandler
public void onServerCmd(ServerCommandEvent e) {
    String[] args = e.getCommand().replace("/", "").split(" ");
    final String[] msg = {null};
    if (e.getCommand().length() > args[0].length() + 1) {
        msg[0] = e.getCommand().substring(args[0].length() + 1);
    }

    if (msg[0] != null && UChat.get().getUCConfig().getTellAliases().contains(args[0])) {
        if (args.length >= 3) {

            Bukkit.getScheduler().runTaskAsynchronously(UChat.get(), () -> {
                Player p = UChat.get().getServer().getPlayer(args[1]);

                if (p == null || !p.isOnline()) {
                    UChat.get().getLang().sendMessage(e.getSender(), "listener.invalidplayer");
                    return;
                }

                msg[0] = msg[0].substring(args[1].length() + 1);

                UChat.get().tempTellPlayers.put("CONSOLE", p.getName());
                UChat.get().command.add("CONSOLE");
                sendPreTell(UChat.get().getServer().getConsoleSender(), p, msg[0]);
            });

            e.setCancelled(true);
        }
    }
}
 
源代码6 项目: ProtocolSupport   文件: ReloadCommandBlocker.java
@EventHandler
public void onConsoleCommand(ServerCommandEvent event) {
	String command = event.getCommand().toLowerCase();
	if (command.startsWith("/")) {
		command = command.substring(1);
	}
	if (blacklist.contains(command)) {
		event.setCancelled(true);
		event.getSender().sendMessage(ChatColor.DARK_RED + "The reload command has been disabled by ProtocolSupport");
	}
}