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


Java AsyncPlayerChatEvent.setFormat方法代码示例

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


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

示例1: handle

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler
public void handle(AsyncPlayerChatEvent e)
{
    PermissionGroup permissionGroup = permissionService ? CloudServer.getInstance()
            .getCachedPlayer(e.getPlayer().getUniqueId()).getPermissionEntity().getHighestPermissionGroup(CloudAPI.getInstance().getPermissionPool())
            :
            null;

    e.setFormat(
            ChatPlugin.getPlugin(ChatPlugin.class).getConfig().getString("format")
                    .replace("%display%", ChatColor.translateAlternateColorCodes('&', (permissionService ? permissionGroup.getDisplay() : "")))
                    .replace("%prefix%", ChatColor.translateAlternateColorCodes('&', (permissionService ? permissionGroup.getPrefix() : "")))
                    .replace("%group%", (permissionService ? permissionGroup.getName() : ""))
                    .replace("%player%", e.getPlayer().getName())
                    .replace("%message%", e.getPlayer().hasPermission("cloudnet.chat.color") ?
                            ChatColor.translateAlternateColorCodes('&', e.getMessage())
                            :
                            e.getMessage())
    );
}
 
开发者ID:Dytanic,项目名称:CloudNet,代码行数:21,代码来源:ChatListener.java

示例2: onPlayerChat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event) {
	Player p = event.getPlayer();
	Gamer g = Hive.getInstance().getGamer(p);
	
	String prefix = "";
	String name = p.getName();
	String msg = event.getMessage();
	
	if (g.getRank() != null)
		prefix = g.getRank().getType().getPrefix();
	
	String result = Chat.colors(prefix + "&7" + name + "&f: ") + msg;
	if (g.getRank().getType().getLevel() >= 5)
		result = Chat.colors(result);
	
	// Symbol % has formatting issues
	event.setFormat(result.replace("%", "%%"));
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:20,代码来源:GeneralEvents.java

示例3: 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

示例4: 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

示例5: forFormat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
public void forFormat(AsyncPlayerChatEvent e) {
	String format = "";
	e.setFormat(format);
	/*
	 * 
	 * Add the following to the parser:
	 * {PLAYERNAME}
	 * {DISPLAYNAME}
	 * {RANK}
	 * {BALANCE} (This will be implemented later)
	 * {DATE}
	 * {TIME}
	 * {RANKLADDER}
	 * 
	 */
}
 
开发者ID:NJDaeger,项目名称:EssentialCommands,代码行数:17,代码来源:ChatEvent.java

示例6: onAsyncPlayerChatEvent

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event)
{
	Player player = event.getPlayer();
	
	ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionContainer().createQuery().getApplicableRegions(player.getLocation());
	
	String prefix = regions.queryValue(WorldGuardUtils.wrapPlayer(player), FlagUtils.CHAT_PREFIX); //Not sure should we add bypass for this
	String suffix = regions.queryValue(WorldGuardUtils.wrapPlayer(player), FlagUtils.CHAT_SUFFIX); //Not sure should we add bypass for this
	
	if (prefix != null)
	{
		event.setFormat(prefix + event.getFormat());
	}
	
	if (suffix != null)
	{
		event.setFormat(event.getFormat() + suffix);
	}
}
 
开发者ID:isokissa3,项目名称:WorldGuardExtraFlagsPlugin,代码行数:21,代码来源:PlayerListener.java

示例7: AnniPlayersInit

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void AnniPlayersInit(AsyncPlayerChatEvent event)
{
	if(event.isAsynchronous())
	{
		AnniPlayer p = AnniPlayer.getPlayer(event.getPlayer().getUniqueId());
		if(p.getTeam() == null)
			event.setFormat(g+"(All) ["+ChatColor.DARK_PURPLE+"Lobby"+g+"] %s"+ChatColor.WHITE+": %s");
		else if(event.getMessage().startsWith("!"))
		{
			event.setMessage(event.getMessage().substring(1));
			event.setFormat(g+"(All) ["+p.getTeam().getColor()+p.getTeam().toString()+g+"] %s"+ChatColor.WHITE+": %s");
		}
		else
		{
			event.setFormat(g+"(Team) ["+p.getTeam().getColor()+p.getTeam().toString()+g+"] %s"+ChatColor.WHITE+": %s");
			event.getRecipients().clear();
			for(AnniPlayer pl : p.getTeam().getPlayers())
				if(pl.isOnline())
					event.getRecipients().add(pl.getPlayer());
		}
	}
}
 
开发者ID:MrLittleKitty,项目名称:AnnihilationPro,代码行数:24,代码来源:GameListeners.java

示例8: onChat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler
public void onChat(AsyncPlayerChatEvent event) {
	try {
	Player player = event.getPlayer();
	PartyRank rank = plugin.getStorage().rank.get(player.getUniqueId());
	PartyClass clazz = plugin.getStorage().clazz.get(player.getUniqueId());

	ChatColor color = clazz.getColor();
	String prefix = rank.getChatPrefix();
	String message = event.getMessage();

	event.setFormat(format(player, rank, clazz, prefix, message, color));
	} catch (Exception e) {
		handleCrash(e);
		event.setFormat(event.getPlayer().getName()+": "+event.getMessage());
	}
}
 
开发者ID:skavrx,项目名称:PartyLobby,代码行数:18,代码来源:ChatFormat.java

示例9: onPlayerChat

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

    Member member = provider.getMember(event.getPlayer().getUniqueId());

    String format = event.getFormat();
    Group group = member.getGroup();

    String tag = group == null ? "" : group.getTag();
    String name = group == null ? "" : group.getName();
    String uuid = group == null ? "" : group.getUUID().toString();

    format = format.replace("{group-tag}", tag);
    format = format.replace("{group-name}", name);
    format = format.replace("{group-uuid}", uuid);

    event.setFormat(format);
}
 
开发者ID:mc-societies,项目名称:societies,代码行数:22,代码来源:ChatListener.java

示例10: 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

示例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: chat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler
public void chat(AsyncPlayerChatEvent e) {
	Player user = e.getPlayer();
	List<String> donors = plugin.getConfig().getStringList("groups.donors");
	for (String person : donors) {
		if (user.getName().equalsIgnoreCase("monofuel")) {
			e.setFormat("<" + ChatColor.YELLOW +"%s" + ChatColor.WHITE + "> %s");
			return;
		} else if (user.getName().equalsIgnoreCase(person)){
			e.setFormat("<" + ChatColor.BLUE +"%s" + ChatColor.WHITE + "> %s");
			return;
		}

	}

	//else if they are normal players
	e.setFormat(ChatColor.GRAY +"<%s> %s");
}
 
开发者ID:monofuel,项目名称:MonoMods,代码行数:19,代码来源:PermListener.java

示例13: onAsyncPlayerChatEvent

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
/**
 * Triggered when a player send a chat message. Used to color usernames according to teams.
 * @param e
 */
@EventHandler
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent e)
{
	Player p = e.getPlayer();
	
	if (p.getName().equals("Elarcis"))
	{
		if (SGOnline.getType(p.getUniqueId()) == PlayerType.SPECTATOR)
			e.setFormat("�r<�6E�alarcis�r> " + e.getMessage());
		else
			e.setFormat("�r<�6E�rlarcis> " + e.getMessage());
	}
	else
	{
		Team pTeam = p.getScoreboard().getPlayerTeam(p);
		String prefix = (pTeam != null) ? pTeam.getPrefix() : "";
		String format = "�r<" + prefix + e.getPlayer().getName() + "�r> " + e.getMessage();
		e.setFormat(format.replaceAll("%", "\\%"));
	}	
}
 
开发者ID:Elarcis,项目名称:Scapegoat,代码行数:25,代码来源:GameState.java

示例14: onChat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler
public void onChat(AsyncPlayerChatEvent e)
{
	String message = ChatUtil.permFormatMessage(e.getPlayer(), e.getMessage());
	e.setMessage(message);
	String format = ChatUtil.formatMessage(e.getPlayer(), plugin.getConfig().getString("chat.format"));
	String[] splitFormat = format.split("%message");
	message = message.replace("%", "%%");
	if(splitFormat.length > 1)
	{
		splitFormat[0] = splitFormat[0].replace("%", "%%");
		splitFormat[1] = splitFormat[1].replace("%", "%%");
		e.setFormat(splitFormat[0] + message + splitFormat[1]);
	}
	else
	{
		splitFormat[0] = splitFormat[0].replace("%", "%%");
		e.setFormat(splitFormat[0] + message);
	}
}
 
开发者ID:Zingalicious,项目名称:Songlantern,代码行数:21,代码来源:ChatListener.java

示例15: formatChat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
protected void formatChat(final AsyncPlayerChatEvent event, final ChatStore chatStore)
{
	final IUser user = chatStore.getUser();
	event.setMessage(FormatUtil.formatMessage(user, Permissions.CHAT, event.getMessage()));
	String group = ess.getRanks().getMainGroup(user);
	String world = user.getPlayer().getWorld().getName();

	IRanks groupSettings = ess.getRanks();
	MessageFormat format = groupSettings.getChatFormat(user);
	synchronized (format)
	{
		event.setFormat(
				format.format(
				new Object[]
				{
					group, world, world.substring(0, 1).toUpperCase(Locale.ENGLISH)
				}));
	}
}
 
开发者ID:Curtis3321,项目名称:Essentials,代码行数:20,代码来源:EssentialsChatPlayer.java


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