本文整理汇总了Java中org.bukkit.event.player.AsyncPlayerChatEvent.isAsynchronous方法的典型用法代码示例。如果您正苦于以下问题:Java AsyncPlayerChatEvent.isAsynchronous方法的具体用法?Java AsyncPlayerChatEvent.isAsynchronous怎么用?Java AsyncPlayerChatEvent.isAsynchronous使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.AsyncPlayerChatEvent
的用法示例。
在下文中一共展示了AsyncPlayerChatEvent.isAsynchronous方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
}
}
}
示例2: 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);
}
}
}
}
示例3: onPlayerChat
import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent e) {
/*
* NON-STAFF CHAT RULES
* Non-staff in any room do not receive normal chat
* Non-staff receive chat from anyone else in their room as normal chat
* Non-staff do not receive chat from those in other rooms
*
* STAFF CHAT RULES
* Staff receives formatted chat from newbies in their room
* Staff receives formatted chat from other staff in their room
* Staff talk in newbie chat rooms with normal messaging
* Staff can talk in main chat by using ! before their message
* Staff cannot see chat in other rooms
*
* GLOBAL CHAT RULES
* People not in a room cannot see newbie chat
*
*/
if (!e.isAsynchronous()) return;
boolean hasRoom = e.getPlayer().hasMetadata(meta);
int room = hasRoom ? e.getPlayer().getMetadata(meta).get(0).asInt() : -1;
//If staff is talking in a room and has ! as the first character of their message
String mainPrefix = plugin.getConfig().getString("main_prefix");
if (hasRoom && e.getPlayer().hasPermission("newbiechat.staffmember") && e.getMessage().startsWith(mainPrefix)) {
e.setMessage(e.getMessage().replaceFirst(Pattern.quote(mainPrefix), ""));
hasRoom = false;
}
for (Player player: Bukkit.getOnlinePlayers()) {
boolean playerHasRoom = player.hasMetadata(meta);
int playerRoom = playerHasRoom ? player.getMetadata(meta).get(0).asInt() : -1;
//Player is in a chat room
if (playerHasRoom) {
//Player is not staff
if (!player.hasPermission("newbiechat.staffmember")) {
//Event is from main chat OR event is from someone in a different chat room
if (!hasRoom || room != playerRoom) {
e.getRecipients().remove(player);
}
}
//Player is staff
else {
//The event player is in a chat room
if (hasRoom) {
//The event player is in the same chat room as this staff
if (room == playerRoom) {
e.getRecipients().remove(player);
HashMap<String, String> vars = new HashMap<String, String>();
vars.put("MESSAGE", e.getMessage());
vars.put("NAME", e.getPlayer().getName());
vars.put("DNAME", e.getPlayer().getDisplayName());
String format = plugin.getConfig().getString("format").replace("&", "�");
for (String var: vars.keySet()) {
format = format.replace("{" + var + "}", vars.get(var));
}
player.sendMessage(format);
}
//The event player is in a different chat room than this staff
else {
e.getRecipients().remove(player);
}
}
}
}
//Player is in global chat and event player is not
else if (hasRoom && !playerHasRoom) {
e.getRecipients().remove(player);
}
}
}