当前位置: 首页>>代码示例>>Java>>正文


Java PlayerChatEvent.setCancelled方法代码示例

本文整理汇总了Java中cn.nukkit.event.player.PlayerChatEvent.setCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerChatEvent.setCancelled方法的具体用法?Java PlayerChatEvent.setCancelled怎么用?Java PlayerChatEvent.setCancelled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cn.nukkit.event.player.PlayerChatEvent的用法示例。


在下文中一共展示了PlayerChatEvent.setCancelled方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onChat

import cn.nukkit.event.player.PlayerChatEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onChat(final PlayerChatEvent event) {
    // Substitute variable - thread safe
    String level = "";
    if (playerLevels.containsKey(event.getPlayer())) {
        level = playerLevels.get(event.getPlayer());
    }
    String format = event.getFormat().replace("{ISLAND_LEVEL}", level);
    event.setFormat(format);
    if (Settings.teamChat && teamChatUsers.containsKey(event.getPlayer())) {
        // Cancel the event
        event.setCancelled(true);
        // Queue the sync task because you cannot use HashMaps asynchronously. Delaying to the next tick
        // won't be a major issue for synch events either.
        Server.getInstance().getScheduler().scheduleTask(plugin, () -> {
            teamChat(event, event.getMessage());
        });
    }
}
 
开发者ID:TheSolidCrafter,项目名称:ASkyBlock-Nukkit,代码行数:20,代码来源:ChatHandler.java

示例2: onPlayerChat

import cn.nukkit.event.player.PlayerChatEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true,priority = EventPriority.LOWEST)
public void onPlayerChat(PlayerChatEvent event) {
    String message = event.getMessage();
    if (message.charAt(0) == '.') {
        String[] split = event.getMessage().split(" ");
        if (split.length > 0) {
            split[0] = split[0].substring(1).replace('.', '/');
            CommandManager cmdMan = WorldEdit.getInstance().getPlatformManager().getCommandManager();
            split = cmdMan.commandDetection(split);
            CommandEvent cmdEvent = new CommandEvent(plugin.wrapCommandSender(event.getPlayer()), Joiner.on(" ").join(Arrays.asList(split)));
            if (cmdMan.getDispatcher().contains(split[0])) {
                WorldEdit.getInstance().getEventBus().post(cmdEvent);
                event.setCancelled(true);
            }
        }
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:18,代码来源:WorldEditListener.java

示例3: onChat

import cn.nukkit.event.player.PlayerChatEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onChat(PlayerChatEvent event) {
    Player player = event.getPlayer();
    String msg = event.getMessage();
    CheckChat checkChat = new CheckChat(player, msg);
    CheckWords checkWords = new CheckWords(player, msg);
    if (AntiCheatAPI.getInstance().getMasterConfig().getCheckChat() && checkChat.isCheat()) {
        AntiCheatAPI.getInstance().addRecord(player, checkChat.getCheatType());
        player.sendMessage(TextFormat.RED + "You chat faster than predetermined value.");
        event.setCancelled();
    }
    if (AntiCheatAPI.getInstance().getMasterConfig().getCheckChatWord() && checkWords.isCheat()) {
        event.setMessage(checkWords.ChangeMessage());
    }
}
 
开发者ID:WetABQ,项目名称:Nukkit-AntiCheat,代码行数:16,代码来源:EventListener.java

示例4: onChat

import cn.nukkit.event.player.PlayerChatEvent; //导入方法依赖的package包/类
@EventHandler
public void onChat(PlayerChatEvent event){
	if(!this.manager.isAuthenticated(event.getPlayer())){
		event.setCancelled();
		this.sendLoginMessage(event.getPlayer());
	}
}
 
开发者ID:onebone,项目名称:GateKeeper,代码行数:8,代码来源:GateKeeper.java

示例5: onChat

import cn.nukkit.event.player.PlayerChatEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onChat(PlayerChatEvent event) {
    PlotPlayer plotPlayer = NukkitUtil.getPlayer(event.getPlayer());
    Location location = plotPlayer.getLocation();
    PlotArea area = location.getPlotArea();
    if (area == null || (area.PLOT_CHAT == plotPlayer.getAttribute("chat"))) {
        return;
    }
    Plot plot = area.getPlot(location);
    if (plot == null) {
        return;
    }
    event.setCancelled(true);
    String message = event.getMessage();
    String format = C.PLOT_CHAT_FORMAT.s();
    String sender = event.getPlayer().getDisplayName();
    PlotId id = plot.getId();
    Set<CommandSender> recipients = event.getRecipients();
    recipients.clear();
    for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
        PlotPlayer pp = entry.getValue();
        if (pp.getAttribute("chatspy")) {
            String spy = event.getFormat();
            spy = String.format(spy, sender, message);
            pp.sendMessage(spy);
        } else {
            Plot current = pp.getCurrentPlot();
            if (current != null && current.getBasePlot(false).equals(plot)) {
                recipients.add(((NukkitPlayer) pp).player);
            }
        }
    }
    String partial = C.color(format.replace("%plot_id%", id.x + ";" + id.y).replace("%sender%", sender));
    String full = partial.replace("%msg%", message);
    for (CommandSender receiver : recipients) {
        receiver.sendMessage(full);
    }
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:39,代码来源:PlayerEvents.java


注:本文中的cn.nukkit.event.player.PlayerChatEvent.setCancelled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。