本文整理汇总了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())
);
}
示例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("%", "%%"));
}
示例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);
}
示例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() ) );
}
}
}
}
}
示例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}
*
*/
}
示例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);
}
}
示例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());
}
}
}
示例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());
}
}
示例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);
}
示例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() ) );
}
}
示例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"));
}
}
示例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");
}
示例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("%", "\\%"));
}
}
示例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);
}
}
示例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)
}));
}
}