@Override
public void call(Event event) {
final Player player = profile.getPlayer();
if (event instanceof PlayerMoveEvent) {
if ((player.isSprinting() || player.isBlocking() || player.isConversing()) && player.isSneaking()) {
callback(true);
return;
}
callback(false);
} else if (event instanceof AsyncPlayerChatEvent) {
if ((player.isBlocking() || player.isSprinting() || player.isSneaking())) {
callback(true);
return;
}
callback(false);
}
}
java类org.bukkit.event.player.AsyncPlayerChatEvent的实例源码
ImpossibleA.java 文件源码
项目:Crescent
阅读 22
收藏 0
点赞 0
评论 0
ChatListener.java 文件源码
项目:CloudNet
阅读 27
收藏 0
点赞 0
评论 0
@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())
);
}
ChatModule.java 文件源码
项目:Warzone
阅读 21
收藏 0
点赞 0
评论 0
@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);
}
AntiCrashChat.java 文件源码
项目:EscapeLag
阅读 23
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.HIGH)
public void ChatCheckCrash(AsyncPlayerChatEvent event){
if (!ConfigPatch.noCrashChat) return;
Player player = event.getPlayer();
String message = event.getMessage();
if(message.contains("İ")){
event.setCancelled(true);
AzureAPI.log(player, ConfigPatch.AntiCrashChatSpecialStringWarnMessage);
}
if(HasEss == true){
if(message.contains("&")){
event.setCancelled(true);
AzureAPI.log(player, ConfigPatch.AntiCrashChatSpecialStringWarnMessage);
}
}
}
AntiSpam.java 文件源码
项目:EscapeLag
阅读 19
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void spamChecker(AsyncPlayerChatEvent evt) {
if (!ConfigFunction.AntiSpamenable)
return;
Player player = evt.getPlayer();
if (AzureAPI.hasPerm(player, "EscapeLag.bypass.Spam")) {
return;
}
long now = System.currentTimeMillis();
if (isSpamming(player, now)) {
evt.setCancelled(true);
AzureAPI.log(player, ConfigFunction.AntiSpamPeriodWarnMessage);
} else {
timeRecord.put(player, now);
}
}
AntiSpam.java 文件源码
项目:EscapeLag
阅读 20
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void checkDirty(AsyncPlayerChatEvent evt) {
if (ConfigFunction.AntiSpamenable && ConfigFunction.enableAntiDirty) {
Player player = evt.getPlayer();
String message = evt.getMessage().toLowerCase();
if (AzureAPI.hasPerm(player, "EscapeLag.bypass.Spam")) {
return;
}
for (String each : ConfigFunction.AntiSpamDirtyList) {
boolean deny = true;
for (char c : each.toLowerCase().toCharArray()) {
if (!StringUtils.contains(message, c))
deny = false;
}
if (deny) {
evt.setCancelled(true);
AzureAPI.log(player, ConfigFunction.AntiSpamDirtyWarnMessage);
}
}
}
}
Events.java 文件源码
项目:mczone
阅读 23
收藏 0
点赞 0
评论 0
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event) {
//event.getRecipients().clear();
if (!chatTimes.containsKey(event.getPlayer().getName())) {
chatTimes.put(event.getPlayer().getName(), new Date());
return;
}
if (Gamer.get(event.getPlayer()).getRank().getLevel() >= 5)
return;
Date now = new Date();
Date before = chatTimes.get(event.getPlayer().getName());
if (now.getTime() - before.getTime() < 5000) {
Chat.player(event.getPlayer(), "&cPlease wait 5 seconds between sending messages.");
event.getRecipients().clear();
event.setCancelled(true);
return;
}
chatTimes.put(event.getPlayer().getName(), now);
}
GeneralEvents.java 文件源码
项目:mczone
阅读 20
收藏 0
点赞 0
评论 0
@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("%", "%%"));
}
RankListener.java 文件源码
项目:Ace
阅读 24
收藏 0
点赞 0
评论 0
@EventHandler
public void onChat(AsyncPlayerChatEvent event){
if(plugin.getConfig().getString("chatformat").equals("true")){
Player player = event.getPlayer();
String message = event.getMessage();
event.setCancelled(true);
String playerNameWithPrefixSuffix = player.getName() + ": ";
try {
playerNameWithPrefixSuffix = ChatColor.translateAlternateColorCodes('&', (!RankManager.getRankPrefix(player).equals(" ")?RankManager.getRankPrefix(player) : "") + RankManager.getRankNameColor(player) +" "+ player.getName() +(!RankManager.getRankSuffix(player).equals(" ")? " "+ RankManager.getRankSuffix(player) : "") + ChatColor.GRAY + ": ");
} catch (SQLException e) {
e.printStackTrace();
}
for(Player p : event.getRecipients()){
p.sendMessage(playerNameWithPrefixSuffix + ChatColor.WHITE + message);
}
}
}
Chat.java 文件源码
项目:Kineticraft
阅读 17
收藏 0
点赞 0
评论 0
@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);
}
EmojiChatListener.java 文件源码
项目:EmojiChat
阅读 20
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.HIGH)
void onChat(AsyncPlayerChatEvent event) {
if (!event.getPlayer().hasPermission("emojichat.use") || !event.getPlayer().hasPermission("emojichat.use.chat"))
return; // Don't do anything if they don't have permission
String message = event.getMessage();
// Checks if the user disabled shortcuts via /emojichat toggle
if (!plugin.getEmojiHandler().hasShortcutsOff(event.getPlayer())) {
message = plugin.getEmojiHandler().translateShorthand(message);
}
// Replace shortcuts with emojis
message = plugin.getEmojiHandler().toEmojiFromChat(message);
// If the message contains a disabled character
if (plugin.getEmojiHandler().containsDisabledCharacter(message)) {
event.setCancelled(true);
event.getPlayer().sendMessage(ChatColor.RED + "Oops! You can't use disabled emoji characters!");
return;
}
event.setMessage(message);
}
CommandAndChatCooldown.java 文件源码
项目:NeverLag
阅读 18
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onChat(AsyncPlayerChatEvent e) {
// 忽略OP
Player p = e.getPlayer();
if (p.isOp()) {
return;
}
// 忽略免检权限
if (p.hasPermission("neverlag.bypass.cooldown.chat")) {
return;
}
// 判断间隔时间
String username = p.getName();
long now = System.currentTimeMillis();
Long lastChatTime;
if ((lastChatTime = chatCoolDown.get(username)) != null) {
long remain = cm.commandCooldownTime - (now - lastChatTime);
if (remain > 0) {
e.setCancelled(true);
p.sendMessage(i18n.tr("chat", Math.ceil(remain / 1000)));
return;
}
}
chatCoolDown.put(username, now);
}
PrivateMessenger.java 文件源码
项目:ChatAssets
阅读 14
收藏 0
点赞 0
评论 0
@EventHandler
public void onPrivateTag(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
boolean enablation = config.getBoolean("enable.private-messenger");
String message = event.getMessage();
if (!(Main.chatHoldOn(player, "")) && enablation && message.startsWith("@")) {
event.setCancelled(true);
if (!(player.hasPermission("chatassets.msg"))) {
Main.sendMessage(Main.noPermError("chat privately!"), player);
} else {
List<String> messagewords = new ArrayList<String>();
for (String x : message.split(" ")) {
messagewords.add(x);
}
String targetname = messagewords.get(0).substring(1);
Player target = Bukkit.getPlayer(targetname);
if (target == null) {
Main.sendMessage(ChatColor.RED + "Player cannot be found!", player);
} else {
messagewords.remove(0);
target.sendMessage("[" + player.getDisplayName() + " -> You] " + AntiCurse.replaceBadWords(ChatAutoModifier.autoModifyString(String.join(" ", messagewords))));
player.sendMessage("[You -> " + target.getDisplayName() + "] " + AntiCurse.replaceBadWords(ChatAutoModifier.autoModifyString(String.join(" ", messagewords))));
}
}
}
}
AntiCaseSpam.java 文件源码
项目:ChatAssets
阅读 23
收藏 0
点赞 0
评论 0
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
boolean enablation = config.getBoolean("enable.anticasespam");
String message = event.getMessage();
if (!(Main.chatHoldOn(player, "")) && enablation && (getUpperCases(message) > getMaxUpperCases())) {
if (!(player.hasPermission("chatassets.anticasespam.bypass"))) {
if (autolowercase) {
event.setMessage(message.toLowerCase());
Main.sendMessage(ChatColor.YELLOW + "Your message is lower cased becuase the original amount of upper cased characters is beyond the maximum.", player);
} else {
event.setCancelled(true);
Main.sendMessage(ChatColor.YELLOW + "Your message is blocked becuase the original amount of upper cased characters is beyond the maximum.", player);
}
}
}
}
LogHandler.java 文件源码
项目:ChatAssets
阅读 33
收藏 0
点赞 0
评论 0
@EventHandler
public void setLine(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
String line = event.getMessage();
if (Commander.setjoinmessage.contains(player) || Commander.setquitmessage.contains(player) || Commander.setmotd.contains(player)) {
if (!(Main.chatHoldOn(player, "setjoinmessage"))) {
event.setCancelled(true);
Commander.joinmessages.add(line);
Main.sendMessage(line + ChatColor.GREEN + " has been added. " + ChatColor.YELLOW + "To stop adding lines to player join message, issue /chatassets loghandler done", player);
} else if (!(Main.chatHoldOn(player, "setquitmessage"))) {
event.setCancelled(true);
Commander.quitmessages.add(line);
Main.sendMessage(line + ChatColor.GREEN + " has been added. " + ChatColor.YELLOW + "To stop adding lines to player quit message, issue /chatassets loghandler done", player);
} else if (!(Main.chatHoldOn(player, "setmotd"))) {
event.setCancelled(true);
Commander.motd.add(line);
Main.sendMessage(line + ChatColor.GREEN + " has been added. " + ChatColor.YELLOW + "To stop adding lines to motd on join, issue /chatassets loghandler done", player);
}
}
}
MessageShortener.java 文件源码
项目:ChatAssets
阅读 18
收藏 0
点赞 0
评论 0
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
String message = event.getMessage();
if (!(Main.chatHoldOn(player, "addshortenmessagelist"))) {
if (Commander.addshortenmessagelist.contains(player)) {
event.setCancelled(true);
Commander.addshortenmessagemessage = message;
String addmessage = message, addkey = Commander.addshortenmessagekey;
Commander.addshortenmessagelist.remove(player);
setMessage(addkey, addmessage, true);
Main.sendMessage(ChatColor.GREEN + "You have successfully added a new shorten message!", player);
player.sendMessage("Key: " + Main.colorcode(addkey));
player.sendMessage("Message: " + Main.colorcode(addmessage));
} else {
if (player.hasPermission("chatassets.messageshortener.use")) {
event.setMessage(Main.colorcode(replaceKey(message)));
}
}
}
String output = String.join(" ", messagewords);
return output;
}
TypeYesOrNo.java 文件源码
项目:UltimateTs
阅读 21
收藏 0
点赞 0
评论 0
@EventHandler
public void onChat(AsyncPlayerChatEvent e){
Player p = e.getPlayer();
if(PlayerManager.confirmationReady.contains(p)){
String message = e.getMessage();
if(message == null) return;
String rep = UltimateTs.main().getConfig().getString("config.yesReponse");
if(rep == null) rep = "YES";
if(message.equalsIgnoreCase(rep.toString())){
BotManager.getBot().editClient(PlayerManager.convertDatabaseIdToClientId(PlayerManager.getLinkedWithDbId(p)), Collections.singletonMap(ClientProperty.CLIENT_DESCRIPTION, ""));
p.sendMessage(UltimateTs.messages.getString("messages.unlinked.confirmation.yes").replace('&', '�'));
PlayerManager.unlink(p);
}else{
p.sendMessage(UltimateTs.messages.getString("messages.unlinked.confirmation.no").replace('&', '�'));
}
PlayerManager.confirmationReady.remove(p);
e.setCancelled(true);
}
}
TypeYesOrNo.java 文件源码
项目:UltimateTs
阅读 35
收藏 0
点赞 0
评论 0
@EventHandler
public void onChat(AsyncPlayerChatEvent e){
Player p = e.getPlayer();
if(PlayerManager.confirmationReady.contains(p)){
String message = e.getMessage();
if(message == null) return;
String rep = UltimateTs.main().getConfig().getString("config.yesReponse");
if(rep == null) rep = "YES";
if(message.equalsIgnoreCase(rep.toString())){
BotManager.getBot().editClient(PlayerManager.convertDatabaseIdToClientId(PlayerManager.getLinkedWithDbId(p)), Collections.singletonMap(ClientProperty.CLIENT_DESCRIPTION, ""));
p.sendMessage(UltimateTs.messages.getString("messages.unlinked.confirmation.yes").replace('&', '�'));
PlayerManager.unlink(p);
}else{
p.sendMessage(UltimateTs.messages.getString("messages.unlinked.confirmation.no").replace('&', '�'));
}
PlayerManager.confirmationReady.remove(p);
e.setCancelled(true);
}
}
ChatListener.java 文件源码
项目:FlexMC
阅读 29
收藏 0
点赞 0
评论 0
@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() ) );
}
}
}
}
}
RankListener.java 文件源码
项目:Locked
阅读 20
收藏 0
点赞 0
评论 0
@EventHandler
public void onChat(AsyncPlayerChatEvent event) {
event.setCancelled(true);
Player player = event.getPlayer();
String message = event.getMessage();
String playerNameWithPrefixSuffix = ChatColor.RED + "(ERROR FORMATTING NAME) " + ChatColor.WHITE + player.getName() + ": ";
try {
if (RankManager.isPrisoner(player)) {
RankManager.updateWantedLevel(player);
} else if (RankManager.isGuard(player) || RankManager.isWarden(player)) {
RankManager.setWantedLevel(player, 0);
}
playerNameWithPrefixSuffix = ChatColor.translateAlternateColorCodes('&', (!RankManager.getRankPrefix(player).equals(" ") ? RankManager.getRankPrefix(player) : "") + ChatColor.GRAY + RankManager.wantedLevelParser(RankManager.getWantedLevel(player)) + ChatColor.GOLD + RankManager.guardLevelParser(RankManager.getGuardLevel(player)) + RankManager.getRankNameColor(player) + " " + player.getName() + (!RankManager.getRankSuffix(player).equals(" ") ? " " + RankManager.getRankSuffix(player) : "") + ChatColor.GRAY + ": ");
} catch (SQLException e) {
e.printStackTrace();
}
for (Player p : event.getRecipients()) {
p.sendMessage(playerNameWithPrefixSuffix + ChatColor.WHITE + message);
}
}
SkinListener.java 文件源码
项目:ProtocolSupportPocketStuff
阅读 21
收藏 0
点赞 0
评论 0
@EventHandler
public void onChat(AsyncPlayerChatEvent e) {
if(e.getMessage().contains(".meep")) {
e.getPlayer().sendMessage("Meep!");
for(Connection con : PocketCon.getPocketConnections()) {
e.getPlayer().sendMessage("MEEEEEP!!");
PocketCon.sendModal(con,
new SimpleForm("hoi", "hallo")
.addButton(new ModalButton("Magbot").setImage(new ModalImage(ModalImageType.EXTERNAL_IMAGE, "http://magbot.nl/img/MagBot.png")))
.addButton(new ModalButton("Awesome").setImage(new ModalImage(ModalImageType.EXTERNAL_IMAGE, "http://yumamom.com/wp-content/uploads/2015/05/LEGO.jpg"))),
new SimpleFormCallback() {
@Override
public void onSimpleFormResponse(Player player, String modalJSON, boolean isClosedByClient, int clickedButton) {
player.sendMessage("Thanks for clicking! :wave:");
}
});
}
}
}
ChatHandleListener.java 文件源码
项目:SamaGamesCore
阅读 15
收藏 0
点赞 0
评论 0
/**
* Spectator's chat
*
* @param event Event
*/
@EventHandler(ignoreCancelled = true)
public void onPlayerChat(AsyncPlayerChatEvent event)
{
if (SamaGamesAPI.get().getGameManager().getGame() == null)
return;
else if (!SamaGamesAPI.get().getGameManager().getGame().getStatus().equals(Status.IN_GAME))
return;
else if (!SamaGamesAPI.get().getGameManager().getGame().isSpectator(event.getPlayer()))
return;
else if (SamaGamesAPI.get().getGameManager().getGame().isModerator(event.getPlayer()))
return;
event.setCancelled(true);
String finalMessage = ChatColor.GRAY + "[Spectateur] " + event.getPlayer().getName() + ": " + event.getMessage();
SamaGamesAPI.get().getGameManager().getGame().getSpectatorPlayers().values().stream().filter(spectator -> ((GamePlayer) spectator).getPlayerIfOnline() != null).forEach(spectator -> ((GamePlayer) spectator).getPlayerIfOnline().sendMessage(finalMessage));
Bukkit.getOnlinePlayers().stream().filter(player -> !SamaGamesAPI.get().getGameManager().getGame().hasPlayer(player)).forEach(player -> player.sendMessage(finalMessage));
}
ChatEvent.java 文件源码
项目:EssentialCommands
阅读 121
收藏 0
点赞 0
评论 0
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}
*
*/
}
ChatModule.java 文件源码
项目:AthenaGM
阅读 23
收藏 0
点赞 0
评论 0
/**
* Intercept chat and apply changes.
* 1. Limit messages to the current world, so they don't across arenas or the hub
* 2. Apply team color to names if applicable
*/
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event) {
event.setCancelled(true);
String tag;
Team team = PlayerUtil.getTeamForPlayer(plugin.getArenaHandler(), event.getPlayer());
if (team != null) {
tag = String.format("<%s%s%s> ", team.getChatColor(), event.getPlayer().getName(), ChatColor.RESET);
} else {
tag = String.format("<%s%s%s> ", ChatColor.GRAY, event.getPlayer().getName(), ChatColor.RESET);
}
for (Player player : event.getPlayer().getWorld().getPlayers()) {
player.sendMessage(tag + event.getMessage());
}
}
UCChannel.java 文件源码
项目:UltimateChat
阅读 19
收藏 0
点赞 0
评论 0
/** Send a message from a channel as player.
* @param sender {@code Player}
* @param message {@code FancyMessage} - Message to send.
* @param direct {@code boolean} - Send message direct to players on channel.
*/
public void sendMessage(Player sender, UltimateFancy message, boolean direct){
if (direct){
for (Player p:Bukkit.getOnlinePlayers()){
UCChannel chp = UChat.get().getPlayerChannel(p);
if (UCPerms.channelReadPerm(p, this) && !this.isIgnoring(p.getName()) && (!this.neeFocus() || chp.equals(this))){
UChat.get().getUCLogger().timings(timingType.START, "UCChannel#sendMessage()|Direct Message");
message.send(p);
}
}
message.send(sender);
} else {
Set<Player> pls = new HashSet<>(Bukkit.getOnlinePlayers());
UChat.get().tempChannels.put(sender.getName(), this.getAlias());
AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(true, sender, message.toOldFormat(), pls);
Bukkit.getScheduler().runTaskAsynchronously(UChat.get(), () -> {
UChat.get().getUCLogger().timings(timingType.START, "UCChannel#sendMessage()|Fire AsyncPlayerChatEvent");
UChat.get().getServer().getPluginManager().callEvent(event);
});
}
}
PlayerListener.java 文件源码
项目:WorldGuardExtraFlagsPlugin
阅读 21
收藏 0
点赞 0
评论 0
@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);
}
}
CallSystem.java 文件源码
项目:MCChatManager
阅读 21
收藏 0
点赞 0
评论 0
public static boolean check(AsyncPlayerChatEvent e) {
if (!e.getMessage().startsWith("@")) {
return false;
}
boolean useReason = e.getMessage().contains(" ");
String checked = useReason ? e.getMessage().split(" ")[0].substring(1)
: e.getMessage().substring(1);
Player p = Bukkit.getPlayer(checked);
Messager.sendCenterMessage(p,
"§c§l" + ChatColor.stripColor(e.getPlayer().getDisplayName())
+ "§e님이 당신을 호출했습니다.");
if (useReason)
Messager.sendCenterMessage(
p,
"§a호출 사유: "
+ e.getMessage()
.replaceFirst(e.getMessage().split(" ")[0],
"").trim());
p.playSound(p.getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR,
1.0f, 1.0f);
e.setCancelled(true);
return true;
}
ChannelListeners.java 文件源码
项目:Arcade2
阅读 20
收藏 0
点赞 0
评论 0
@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 :/
}
CTFListener.java 文件源码
项目:Breakpoint
阅读 24
收藏 0
点赞 0
评论 0
@Override
public boolean onPlayerChat(AsyncPlayerChatEvent event, BPPlayer bpPlayer)
{
CTFProperties props = (CTFProperties) bpPlayer.getGameProperties();
Team team = props.getTeam();
if(team != null)
{
String message = event.getMessage();
if(message.charAt(0) == '@')
{
CTFGame game = getGame();
Player player = bpPlayer.getPlayer();
event.setCancelled(true);
String playerName = player.getName();
game.sendTeamMessage(playerName, message, team);
Breakpoint.info("Team chat: " + playerName + ": " + message);
return false;
}
}
return true;
}
GameListeners.java 文件源码
项目:AnnihilationPro
阅读 21
收藏 0
点赞 0
评论 0
@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());
}
}
}