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


Java AsyncPlayerChatEvent.isCancelled方法代码示例

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


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

示例1: onChatHighPriority

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onChatHighPriority(AsyncPlayerChatEvent event) {
    PlayerContext playerContext = TGM.get().getPlayerManager().getPlayerContext(event.getPlayer());
    if (!event.isCancelled())  {
        Bukkit.getOnlinePlayers().forEach(player -> {
            TextComponent message = new TextComponent(event.getFormat().replaceAll("%%", "%"));
            BaseComponent[] stats = new BaseComponent[]{new TextComponent(ChatColor.AQUA + "Level: " + playerContext.getLevelString().replace("[", "").replace("]", "")),
                    new TextComponent("\n"),
                    new TextComponent("\n" + ChatColor.AQUA + "Kills: " + ChatColor.RESET + playerContext.getUserProfile().getKills()),
                    new TextComponent("\n" + ChatColor.AQUA + "Deaths: " + ChatColor.RESET + playerContext.getUserProfile().getDeaths()),
                    new TextComponent("\n" + ChatColor.AQUA + "K/D: " + ChatColor.RESET + playerContext.getUserProfile().getKDR()),
                    new TextComponent("\n"),
                    new TextComponent("\n" + ChatColor.AQUA + "Wins: " + ChatColor.RESET + playerContext.getUserProfile().getWins()),
                    new TextComponent("\n" + ChatColor.AQUA + "Losses: " + ChatColor.RESET + playerContext.getUserProfile().getLosses()),
                    new TextComponent("\n" + ChatColor.AQUA + "W/L: " + ChatColor.RESET + playerContext.getUserProfile().getWLR())};
            message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, stats));
            player.spigot().sendMessage(message);
        });
        Bukkit.getConsoleSender().sendMessage(event.getFormat().replace("%%", "%"));
    }
    event.setCancelled(true);
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:23,代码来源:ChatModule.java

示例2: onChat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW) // Filter should happen after commands.
public void onChat(AsyncPlayerChatEvent evt) {

    // Handle mutes.
    KCPlayer pw = KCPlayer.getWrapper(evt.getPlayer());
    if (pw.isMuted() && !evt.isCancelled()) {
        evt.setCancelled(true);
        evt.getPlayer().sendMessage(ChatColor.RED + "You are muted for "  + pw.getMute().untilExpiry()+ ".");
        evt.getPlayer().sendMessage(ChatColor.RED + "Reason: " + ChatColor.YELLOW + pw.getMute().getReason());
        evt.getPlayer().sendMessage(ChatColor.RED + "Source: " + ChatColor.YELLOW + pw.getMute().getSource());
        return;
    }

    evt.setMessage(applyAllFilters(evt.getPlayer(), evt.getMessage())); // Apply all filters.
    evt.setFormat(KCPlayer.getWrapper(evt.getPlayer()).getDisplayPrefix() + " %s:" + ChatColor.WHITE + " %s");

    // Handle ignored players.
    if (!pw.getRank().isStaff())
        new ArrayList<>(evt.getRecipients()).stream()
                .filter(p -> KCPlayer.getWrapper(p).getIgnored().containsIgnoreCase(evt.getPlayer().getName()))
                .forEach(evt.getRecipients()::remove);
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:23,代码来源:Chat.java

示例3: handle

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@SuppressWarnings( "deprecation" )
@Override
public void handle( ConnectionHandler connectionHandler, MessageC02ChatMessage message ) {
    FlexPlayer player = connectionHandler.getPlayer();
    if( player != null && message.getMessage().length() < 256 ) {
        if( message.getMessage().startsWith( "/" ) ) {
            String commandLine = message.getMessage().length() == 1 ? "" : message.getMessage().substring( 1 );
            if( !Flex.getServer().getCommandMap().dispatch( player, commandLine ) ) {
                player.sendMessage( "Unknown command. Type /help for help" );
            }
            return;
        }
        PlayerChatEvent oldEvent = EventFactory.call( new PlayerChatEvent( player, message.getMessage(), "<%1$s> %2$s", new HashSet<>( Flex.getServer().getPlayerManager().getOnlinePlayers() ) ) );
        AsyncPlayerChatEvent event = new AsyncPlayerChatEvent( true, player, oldEvent.getMessage(), oldEvent.getRecipients() );
        event.setFormat( oldEvent.getFormat() );
        EventFactory.call( event );
        if( !event.isCancelled() ) {
            for( Player target : event.getRecipients() ) {
                if( target.isOnline() ) {
                    target.sendMessage( String.format( event.getFormat(), player.getDisplayName(), message.getMessage() ) );
                }
            }
        }
    }
}
 
开发者ID:lukas81298,项目名称:FlexMC,代码行数:26,代码来源:ChatListener.java

示例4: onAsyncPlayerChat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
    if (event.isCancelled()) {
        return;
    }

    ArcadePlayer player = this.game.getPlugin().getPlayer(event.getPlayer());
    ChatChannel channel = this.game.getChannel(player);

    if (!player.getChatState().chat()) {
        player.sendError("You may not chat because your chat is disabled.");
        event.setCancelled(true);
        return;
    }

    String message = event.getMessage();
    if (message.startsWith(GlobalChatChannel.GLOBAL_CHANNEL_KEY)) { // global
        channel = this.game.getGlobalChannel();
        message = message.substring(1);
    }

    channel.sendChatMessage(player, message.trim());
    event.setCancelled(true); // this breaks other plugins :/
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:25,代码来源:ChannelListeners.java

示例5: onChat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler
public void onChat(AsyncPlayerChatEvent e) {
	if (e.isCancelled()) {
		return;
	}
	
	if (!QuestManagerPlugin.questManagerPlugin.getPluginConfiguration().getChatTitle()) {
		//if no, check worlds
		if (!QuestManagerPlugin.questManagerPlugin.getPluginConfiguration().getWorlds()
				.contains(e.getPlayer().getWorld().getName())) {
			return;
		}
	}
	
	QuestPlayer qp = QuestManagerPlugin.questManagerPlugin.getPlayerManager().getPlayer(e.getPlayer());
	if (qp.getTitle() == null || qp.getTitle().trim().isEmpty() || qp.getTitle().trim().equalsIgnoreCase("The Unknown")) {
		return;
	}
	
	String msg = "[" + qp.getTitle() + "] " + e.getMessage();
	e.setMessage(msg);
}
 
开发者ID:Dove-Bren,项目名称:QuestManager,代码行数:23,代码来源:QuestManager.java

示例6: chat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void chat(AsyncPlayerChatEvent e) {
	if (Vars.adminChat.contains(e.getPlayer()) || e.getMessage().startsWith(",") && e.getPlayer().hasPermission("izenith.adminchat") && (e.getMessage().length() != 1)) {
		e.setCancelled(true);
		Util.sendAdminMessage(e.getMessage().startsWith(",") ? e.getMessage().substring(1) : e.getMessage(), e.getPlayer());
		return;
	}
	
	try {
		if (!e.isCancelled()) {
			e.setCancelled(true);
			IPlayerHandler.getPlayer(e.getPlayer()).sendChatMessage(e.getMessage());
		}
	} catch (Exception ex) {
		ex.printStackTrace();
	}
}
 
开发者ID:bobmandude9889,项目名称:iZenith-PVP,代码行数:18,代码来源:ChatHandler.java

示例7: onReply

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onReply(AsyncPlayerChatEvent event) {
	if (event.isCancelled())
		return;
	if (!event.getPlayer().equals(player))
		return;
	String message = event.getMessage().trim();
	for (int i : options.keySet()) {
		if (message.equals(Integer.toString(i))) {
			player.sendMessage(replace(answerFormat + options.get(i)));
			conv.passPlayerAnswer(i);
			event.setCancelled(true);
			return;
		}
	}
	new BukkitRunnable() {
		@Override
		public void run() {
			display();
		}
	}.runTask(BetonQuest.getInstance());
}
 
开发者ID:Co0sh,项目名称:ClassicConversations,代码行数:23,代码来源:ClassicConv.java

示例8: chatProcess

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
public void chatProcess(AsyncPlayerChatEvent e) {
    Player player = e.getPlayer();
    PlayerInfo pi = players.get(player.getName().toLowerCase());
    if (pi != null) {
        long now = new Date().getTime();
        if (pi.lastTimeChatCmd != 0) {
            int delay = plugin.config.getChatDelay(player);
            int timeToWait = (int) ((pi.lastTimeChatCmd + delay) - now) / 1000;
            if (timeToWait > 0) {
                e.setCancelled(true);
                player.sendMessage(plugin.getPrefix() + ChatColor.RED
                        + "Debido a tu rango debes esperar " + timeToWait + " segundos para hablar.");
            } else {
                pi.lastTimeChatCmd = now;
            }
        } else {
            pi.lastTimeChatCmd = now;
        }
    }
    if (!e.isCancelled()) {
        plugin.chat.processChat(e);
    }
}
 
开发者ID:ddonofrio,项目名称:libelula,代码行数:24,代码来源:PlayerManager.java

示例9: setLogChat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler( priority = EventPriority.MONITOR )
public void setLogChat( AsyncPlayerChatEvent e ) {
    if ( e.isCancelled() ) {
        return;
    }
    BSPlayer p = PlayerManager.getPlayer( e.getPlayer() );
    if ( p == null ) {
        e.setCancelled( true );
        return;
    }
    if ( ChannelManager.isGlobal( p.getChannel() ) ) {
        e.setFormat( e.getFormat().replaceAll( ServerData.getGlobalRegex(), "" ) );
        ChannelManager.sendGlobalChat( e.getPlayer().getName(), String.format( e.getFormat(), p.getDisplayingName(), e.getMessage() ) );
    } else if ( ChannelManager.isAdmin( p.getChannel() ) ) {
        ChannelManager.sendAdminChat( String.format( e.getFormat(), p.getDisplayingName(), e.getMessage() ) );
    } else {
        e.getRecipients().addAll( PlayerManager.getChatSpies( e.getPlayer(), e.getRecipients() ) );
        Utilities.logChat( String.format( e.getFormat(), p.getDisplayingName(), e.getMessage() ) );
    }

}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:22,代码来源:ChatListener.java

示例10: onAsyncPlayerChat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
    if (!event.isCancelled()) {
        final Player p = event.getPlayer();
        if (!HoloAPI.getVanishProvider().isVanished(p)) {
            final String msg = event.getMessage();
            if (event.isAsynchronous()) {
                HoloAPI.getCore().getServer().getScheduler().scheduleSyncDelayedTask(HoloAPI.getCore(), new BukkitRunnable() {
                    @Override
                    public void run() {
                        showChatHologram(p, msg);
                    }
                });
            } else {
                this.showChatHologram(p, msg);
            }
        }
    }
}
 
开发者ID:DSH105,项目名称:HoloAPI,代码行数:20,代码来源:IndicatorListener.java

示例11: onPlayerChat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerChat(AsyncPlayerChatEvent event)
{
	if (event.isCancelled())
		return;

	Player player = event.getPlayer();
	String msg = event.getMessage();

	try
	{
		String format = plugin.getChatHandler().formatChat(player, msg);
		if (format != null)
			event.setFormat(format);
	}
	catch (Throwable ex)
	{
		plugin.getLogHandler().log(Level.SEVERE, Util.getUsefulStack(ex, "parsing " + player.getName() + "''s chat"));
	}
}
 
开发者ID:dmulloy2,项目名称:SwornPermissions,代码行数:21,代码来源:ChatListener.java

示例12: onReply

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onReply(AsyncPlayerChatEvent event) {
	if (event.isCancelled())
		return;
	if (!event.getPlayer().equals(player))
		return;
	String message = event.getMessage().trim();
	for (int i : options.keySet()) {
		if (message.equals(Integer.toString(i))) {
			player.sendMessage(answerFormat + options.get(i));
			conv.passPlayerAnswer(i);
			event.setCancelled(true);
			return;
		}
	}
	// redisplay the conversation after player's message so he can see it
	new BukkitRunnable() {
		@Override
		public void run() {
			display();
		}
	}.runTask(BetonQuest.getInstance());
}
 
开发者ID:Co0sh,项目名称:BetonQuest,代码行数:24,代码来源:ChatConvIO.java

示例13: onChat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler
public void onChat(AsyncPlayerChatEvent event) {
	if (event.isCancelled()) {
		return;
	}
	String playerID = PlayerConverter.getID(event.getPlayer());
	if (!containsPlayer(playerID)) {
		return;
	}
	if (event.getMessage().matches("[a-zA-Z]*: .*")) {
		event.setCancelled(true);
		String message = event.getMessage();
		int index = message.indexOf(':');
		String key = message.substring(0, index).trim();
		String value = message.substring(index + 1).trim();
		((VariableData) dataMap.get(playerID)).add(key, value);
		event.getPlayer().sendMessage("§2§l\u2713");
	}
}
 
开发者ID:Co0sh,项目名称:BetonQuest,代码行数:20,代码来源:VariableObjective.java

示例14: onPlayerChat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerChat(final AsyncPlayerChatEvent event) {
	if (!event.isCancelled()) {
		if (this.alsoChatConversation && event.getPlayer().getUniqueId().equals(this.uuid)) {
			this.applyInput(event.getMessage());
			event.setCancelled(true);
		}
		else {
			final Optional<Player> player = this.getPlayer();
			if (player.isPresent() && !player.get().isOnline() || this.time + Conversation.MAX_CONVERSATION_DURATION < System.currentTimeMillis()) {
				// Cancel conversation if player is not online or the conversation already takes longer than 5 minutes.
				this.disable();
			}
		}
	}
}
 
开发者ID:Craftolution,项目名称:CraftoPlugin,代码行数:17,代码来源:Conversation.java

示例15: onPlayerChat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerChat(AsyncPlayerChatEvent event) {
   if(event.isCancelled()) {
      return;
   } else if(!event.getPlayer().hasPermission(PermissionNode.USE.getNode())) {
      return;
   }
   String source = event.getMessage();
   if(!(source.contains("/sarcasm"))) {
      return;
   }
   String prefix = ChatColor.translateAlternateColorCodes('&', plugin.getRootConfig().getString(RootConfigNode.PREFIX));
   String suffix = ChatColor.translateAlternateColorCodes('&', plugin.getRootConfig().getString(RootConfigNode.SUFFIX));
   String replace = ChatColor.translateAlternateColorCodes('&', plugin.getRootConfig().getString(RootConfigNode.REPLACE));
   Matcher matcher = sarcasm.matcher(source);
   StringBuilder builder = new StringBuilder();
   if(!prefix.isEmpty()) {
      builder.append(prefix);
   }
   builder.append(matcher.replaceAll(replace));
   if(!suffix.isEmpty()) {
      builder.append(suffix);
   }
   event.setMessage(builder.toString());
}
 
开发者ID:Mitsugaru,项目名称:Sarcasm,代码行数:26,代码来源:ChatListener.java


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