private void handleChatMessage(PlayerChatEvent event) {
if (this.namingPlayers.contains(event.getPlayer()) || this.namingSkull.contains(event.getPlayer()))
event.setCancelled(true);
final PetBlock petBlock;
if ((petBlock = this.getPetBlock(event.getPlayer())) != null) {
if (this.namingSkull.contains(event.getPlayer())) {
this.renameSkull(event.getPlayer(), event.getMessage(), petBlock.getMeta(), petBlock);
} else if (this.namingPlayers.contains(event.getPlayer())) {
this.renameName(event.getPlayer(), event.getMessage(), petBlock.getMeta(), petBlock);
}
} else {
this.plugin.getServer().getScheduler().runTaskAsynchronously(this.plugin, () -> {
final com.github.shynixn.petblocks.api.persistence.entity.PetMeta petMeta = this.manager.getPetMetaController().getByPlayer(event.getPlayer());
if (this.namingSkull.contains(event.getPlayer())) {
this.plugin.getServer().getScheduler().runTask(this.plugin, () -> this.renameSkull(event.getPlayer(), event.getMessage(), petMeta, null));
} else if (this.namingPlayers.contains(event.getPlayer())) {
this.plugin.getServer().getScheduler().runTask(this.plugin, () -> this.renameName(event.getPlayer(), event.getMessage(), petMeta, null));
}
});
}
}
java类org.bukkit.event.player.PlayerChatEvent的实例源码
PetDataListener.java 文件源码
项目:PetBlocks
阅读 23
收藏 0
点赞 0
评论 0
ChatListener.java 文件源码
项目:FlexMC
阅读 26
收藏 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() ) );
}
}
}
}
}
PlayerListener.java 文件源码
项目:Pugna
阅读 28
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.NORMAL)
public void onChat(PlayerChatEvent event)
{
Player player = event.getPlayer();
PugnaPlayer play = pg.track.getPlayerData(player);
if (play.getChatState() && play.getTeamState())
{
event.setCancelled(true);
String teamName = play.getTeam();
PugnaTeam team = pg.teams.getTeam(teamName); //
team.sendMessage(player, " " + event.getMessage());
}
else if (player.getPlayerListName().equals(pg.emperor.getEmperorName()))
{
event.setFormat(ChatColor.DARK_PURPLE + pg.config.emperorTitle + " %s: %s");
}
}
FloodSpamEvent.java 文件源码
项目:xEssentials-deprecated-bukkit
阅读 20
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.LOWEST)
public void playerChatTime(PlayerChatEvent e) {
if(chatTime.containsKey(e.getPlayer().getName())) {
if(System.currentTimeMillis() - chatTime.get(e.getPlayer().getName()) < 300) {
e.setCancelled(true);
XPlayer xp = pl.getManagers().getPlayerManager().getPlayer(e.getPlayer().getName());
Date date = new Date(System.currentTimeMillis());
date.setDate(date.getDate() + 1);
xp.setTempbanned(date.getTime(), pl.getConfiguration().getBanConfig().getFloodSpamBanMessage(), "CONSOLE");
} else {
chatTime.put(e.getPlayer().getName(), System.currentTimeMillis());
}
} else {
chatTime.put(e.getPlayer().getName(), System.currentTimeMillis());
}
}
SilenceChatEvent.java 文件源码
项目:xEssentials-deprecated-bukkit
阅读 21
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.LOW)
public void onChat(PlayerChatEvent e) {
if(pl.getConfiguration().isChatSillenced()) {
sendMessage(e.getPlayer(), ChatColor.GREEN + "all chat activity has been halted!, please wait a few minuts.");
e.setCancelled(true);
} else {
XPlayer xp = pl.getManagers().getPlayerManager().getPlayer(e.getPlayer().getName());
if(xp.isSilenced()) {
sendMessage(e.getPlayer(), ChatColor.GREEN + "you have silenced your chat, so you cannot chat unless you unmute your self with /silence");
e.setCancelled(true);
return;
}
//credits to feildmaster his silence source
Iterator<Player> it = e.getRecipients().iterator();
for(Player p = (it.hasNext() ? it.next() : null); it.hasNext(); p=it.next()) {
XPlayer xp2 = pl.getManagers().getPlayerManager().getPlayer(p.getName());
if(xp2.isSilenced()) {
it.remove();
}
}
}
}
CallPlayerChatSmilleyEvent.java 文件源码
项目:xEssentials-deprecated-bukkit
阅读 23
收藏 0
点赞 0
评论 0
@EventHandler
public void onChatSmilleyEvent(PlayerChatEvent e) {
List<String> SmilleyList = new ArrayList<String>();
String[] args = e.getMessage().split(" ");
for(int i = 0; i < args.length; i++) {
if(args[i].equalsIgnoreCase(":D")) {
SmilleyList.add(args[i]);
} else if(args[i].equalsIgnoreCase(":@")) {
SmilleyList.add(args[i]);
} else if(args[i].equalsIgnoreCase("<3")) {
SmilleyList.add(args[i]);
} else if(args[i].equalsIgnoreCase(":)")) {
SmilleyList.add(args[i]);
}
}
String[] SmilleyNames = SmilleyList.toArray(new String[SmilleyList.size()]);
if(SmilleyNames.length > 0) {
Bukkit.getPluginManager().callEvent(new PlayerChatSmilleyEvent(e, SmilleyNames, pl));
}
}
afkChat.java 文件源码
项目:xEssentials_old_Source
阅读 26
收藏 0
点赞 0
评论 0
@EventHandler
public void afkCheckChat(PlayerChatEvent e) {
for(Player p : Bukkit.getOnlinePlayers()) {
if(e.getMessage().contains(p.getName())) {
if(afkCheck.afkList.contains(p.getName())) {
if(afkCheck.afkMessage.containsKey(p.getName())) {
e.getPlayer().sendMessage(ChatColor.GREEN + p.getName() + " has been afk [ " + afkCheck.afkMessage.get(p.getName()) + " ]");
//e.setCancelled(true);
} else {
e.getPlayer().sendMessage(ChatColor.GREEN + p.getName() + " has been afk");
//e.setCancelled(true);
}
}
}
}
}
Chatter.java 文件源码
项目:Chatter
阅读 42
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerChatEvent(PlayerChatEvent event) {
Player player = event.getPlayer();
// replace message color codes
if (player.hasPermission("chatter.colour")) {
String message = event.getMessage();
message = replaceColorCodes(message);
event.setMessage(message);
}
// set the format
String format = config.getString("chat.format");
format = replacePlayerPlaceholders(player, format);
format = replaceColorCodes(format);
event.setFormat(format);
}
PetDataListener.java 文件源码
项目:PetBlocks
阅读 28
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.HIGHEST)
public void playerChatEvent3(final AsyncPlayerChatEvent event) {
if (Config.getInstance().isChat_async() && Config.getInstance().isChatHighestPriority()) {
if (this.namingPlayers.contains(event.getPlayer()) || this.namingSkull.contains(event.getPlayer()))
event.setCancelled(true);
this.plugin.getServer().getScheduler().runTaskLater(this.plugin, () -> PetDataListener.this.handleChatMessage(new PlayerChatEvent(event.getPlayer(), event.getMessage())), 1L);
}
}
PetDataListener.java 文件源码
项目:PetBlocks
阅读 28
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.LOW)
public void playerChatEvent4(final AsyncPlayerChatEvent event) {
if (Config.getInstance().isChat_async() && !Config.getInstance().isChatHighestPriority()) {
if (this.namingPlayers.contains(event.getPlayer()) || this.namingSkull.contains(event.getPlayer()))
event.setCancelled(true);
this.plugin.getServer().getScheduler().runTaskLater(this.plugin, () -> PetDataListener.this.handleChatMessage(new PlayerChatEvent(event.getPlayer(), event.getMessage())), 1L);
}
}
SChatMenuManager.java 文件源码
项目:BlockBall
阅读 22
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerAsyncChatEvent2(PlayerChatEvent event) {
if (!Config.getInstance().isAsyncChat() && !Config.getInstance().isHighpriority()) {
if (this.pages.containsKey(event.getPlayer())) {
event.setCancelled(true);
final String message = ChatColor.stripColor(event.getMessage());
this.handleChatMessage(event.getPlayer(), message);
}
}
}
SChatMenuManager.java 文件源码
项目:BlockBall
阅读 20
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerAsyncChatEvent(PlayerChatEvent event) {
if (!Config.getInstance().isAsyncChat() && Config.getInstance().isHighpriority()) {
if (this.pages.containsKey(event.getPlayer())) {
event.setCancelled(true);
final String message = ChatColor.stripColor(event.getMessage());
this.handleChatMessage(event.getPlayer(), message);
}
}
}
ExprMessage.java 文件源码
项目:Skript
阅读 38
收藏 0
点赞 0
评论 0
@Override
@Nullable
String get(final Event e) {
if (PlayerChatEventHandler.usesAsyncEvent)
return ((AsyncPlayerChatEvent) e).getMessage();
else
return ((PlayerChatEvent) e).getMessage();
}
ExprMessage.java 文件源码
项目:Skript
阅读 26
收藏 0
点赞 0
评论 0
@Override
void set(final Event e, final String message) {
if (PlayerChatEventHandler.usesAsyncEvent)
((AsyncPlayerChatEvent) e).setMessage(message);
else
((PlayerChatEvent) e).setMessage(message);
}
Commands.java 文件源码
项目:Skript
阅读 25
收藏 0
点赞 0
评论 0
@SuppressWarnings("null")
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerChat(final PlayerChatEvent e) {
if (!SkriptConfig.enableEffectCommands.value() || !e.getMessage().startsWith(SkriptConfig.effectCommandToken.value()))
return;
if (handleEffectCommand(e.getPlayer(), e.getMessage()))
e.setCancelled(true);
}
Blockode.java 文件源码
项目:CraftPlugins
阅读 32
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.NORMAL,ignoreCancelled = true)
public void onPlayerChat(PlayerChatEvent event) {
if(this.isQuoteBlocked(event.getMessage())){
event.getPlayer().sendMessage(ChatColor.RED+"这话你可不能说啊。。。!");
event.setCancelled(true);
}
}
Banner.java 文件源码
项目:CraftPlugins
阅读 36
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.NORMAL,ignoreCancelled = true)
public void onPlayerChat(PlayerChatEvent event) {
if(this.isQuoteBlocked(event.getMessage()) && !event.getPlayer().isOp()){
event.getPlayer().sendMessage(ChatColor.RED+"这话你可不能说啊。。。!");
event.setCancelled(true);
}
}
Blockode.java 文件源码
项目:CraftPlugins
阅读 26
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.NORMAL,ignoreCancelled = true)
public void onPlayerChat(PlayerChatEvent event) {
if(this.isQuoteBlocked(event.getMessage())){
event.getPlayer().sendMessage(ChatColor.RED+"这话你可不能说啊。。。!");
event.setCancelled(true);
}
}
Mentions.java 文件源码
项目:JAATP
阅读 24
收藏 0
点赞 0
评论 0
@EventHandler
public void onChat(PlayerChatEvent e){
if(!e.getMessage().contains("@")) return;
ArrayList<String> words = new ArrayList<>(Arrays.asList(e.getMessage().split(" ")));
ArrayList<String> mentions = new ArrayList<>();
for(String word : words){
if(word.contains("@")){
mentions.add(word.split("@")[1]);
}
}
for(String pname : mentions){
String before = new String(pname);
Player p = Bukkit.getPlayer(pname);
if(p == null){
e.getPlayer().sendMessage(MessageConfig.ERROR_PLAYER_MENTION_NOT_ONLINE);
return;
}
pname = ChatColor.AQUA + pname;
e.setMessage(e.getMessage().replaceAll("@" + before,ChatColor.AQUA + "@" + pname + ChatColor.RESET));
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_PLING, 1F, 1F);
}
}
BChatListener.java 文件源码
项目:RoyalIRC
阅读 30
收藏 0
点赞 0
评论 0
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.MONITOR)
public void syncOnChat(PlayerChatEvent e) {
if (!Config.useSyncChat) return;
if (e.isCancelled() || e.getRecipients().isEmpty()) return;
String message = Config.btiMessage;
message = replaceVars(e, message);
message = message.replace("{message}", e.getMessage());
plugin.bh.sendMessage(message);
}
HumanSpamEvent.java 文件源码
项目:xEssentials-deprecated-bukkit
阅读 24
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.LOWEST)
public void slowSpamCheck(PlayerChatEvent e) {
final Player p = (Player) e.getPlayer();
if(message2.containsKey(e.getPlayer().getName())) {
if(message2.get(e.getPlayer().getName()).equalsIgnoreCase(e.getMessage())) {
e.getPlayer().kickPlayer(pl.getConfiguration().getBanConfig().getHumanSpamBanMessage());
message2.remove(e.getPlayer().getName());
} else {
message2.remove(e.getPlayer().getName());
}
} else if(message1.containsKey(e.getPlayer().getName())) {
if(message1.get(e.getPlayer().getName()).equalsIgnoreCase(e.getMessage())) {
message1.remove(e.getPlayer().getName());
message2.put(e.getPlayer().getName(), e.getMessage());
sendMessage(e.getPlayer(), ChatColor.RED + "Warning if you post one more time the same message you will be kicked!");
} else {
message1.put(e.getPlayer().getName(), e.getMessage());
}
} else {
message1.put(e.getPlayer().getName(), e.getMessage());
}
Bukkit.getScheduler().scheduleSyncDelayedTask(pl, new Runnable() {
@Override
public void run() {
if(message1.containsKey(p.getPlayer().getName())) {
message1.remove(p.getPlayer().getName());
} else if(message2.containsKey(p.getPlayer().getName())) {
message2.remove(p.getPlayer().getName());
}
}
}, 300);
}
PlayerIgnorePlayerChatEvent.java 文件源码
项目:xEssentials-deprecated-bukkit
阅读 23
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.LOWEST)
public void onIgnoreChat(PlayerChatEvent e) {
for(XPlayer xp : pl.getManagers().getPlayerManager().getPlayers()) {
if(xp.hasIgnoredPlayers()) {
if(xp.getIgnoredPlayers().contains(e.getPlayer().getName())) {
e.getRecipients().remove(xp.getBukkitPlayer());
}
}
}
}
ChatFormatEvent.java 文件源码
项目:xEssentials-deprecated-bukkit
阅读 18
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.HIGHEST)
public void onChat(PlayerChatEvent e) {
if(e.isCancelled()) {
return;
}
String prefix = pl.getConfiguration().getChatConfig().getPrefixByPlayer(e.getPlayer());
String suffix = pl.getConfiguration().getChatConfig().getSuffixByPlayer(e.getPlayer());
Player p = e.getPlayer();
e.setFormat(prefix + p.getName() + ": " + suffix + e.getMessage());
}
MuteEvent.java 文件源码
项目:xEssentials-deprecated-bukkit
阅读 22
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.HIGHEST)
public void onMute(PlayerChatEvent e) {
if(pl.getManagers().getPlayerManager().isOnline(e.getPlayer().getName())) {
XPlayer xp = pl.getManagers().getPlayerManager().getPlayer(e.getPlayer().getName());
if(xp.isMuted()) {
if(System.currentTimeMillis() > xp.getMutedTime()) {
sendMessage(e.getPlayer(), ChatColor.GREEN + "you are now allowed to talk again!");
xp.unmute();
} else {
sendMessage(e.getPlayer(), ChatColor.GREEN + "you are muted! till: " + new Date(xp.getMutedTime()).toString());
e.setCancelled(true);
}
}
}
}
DrunkChatEvent.java 文件源码
项目:xEssentials-deprecated-bukkit
阅读 22
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.HIGH)
public void onDrunk(PlayerChatEvent e) {
if(e.isCancelled()) {
return;
}
XPlayer xp = pl.getManagers().getPlayerManager().getPlayer(e.getPlayer().getName());
if(xp.isDrunk()) {
String derp = xp.getDrunkMessageFrom(e.getMessage(), false);
e.setMessage(derp);
}
}
CallPlayerHighLightEvent.java 文件源码
项目:xEssentials-deprecated-bukkit
阅读 22
收藏 0
点赞 0
评论 0
@EventHandler
public void onChatHighLightEvent(PlayerChatEvent e) {
List<String> playerList = new ArrayList<String>();
String[] args = e.getMessage().split(" ");
for(int i = 0; i < args.length; i++) {
String name = args[i].replace("?", "").replace(",", "").replace(":", "").replace("=", "").replace("!", "").replace(".", "");
if(pl.getManagers().getPlayerManager().isEssentialsPlayer(name)) {
playerList.add(name);
}
}
String[] PlayerNames = playerList.toArray(new String[playerList.size()]);
if(PlayerNames.length > 0) {
Bukkit.getPluginManager().callEvent(new PlayerChatHighLightEvent(e, PlayerNames, pl));
}
}
AfkCheckEvent.java 文件源码
项目:xEssentials-deprecated-bukkit
阅读 26
收藏 0
点赞 0
评论 0
@EventHandler
public void chatAfk(PlayerChatEvent e) {
for(XPlayer xp : pl.getManagers().getPlayerManager().getPlayers()) {
if(e.getMessage().contains(xp.getBukkitPlayer().getName())) {
if(xp.isAfk()) {
sendMessage(e.getPlayer(), ChatColor.GREEN + xp.getBukkitPlayer().getName() + " has been afk [ " + xp.getAfkReason() + " ]");
}
}
}
}
muteManager.java 文件源码
项目:xEssentials_old_Source
阅读 23
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void getMutes(PlayerChatEvent e) {
if(isMuted(e.getPlayer())) {
Long time = (Long) xEssentialsMemory.returnPlayer(e.getPlayer()).get("muted");
if(timeunits.isOverTime(time)) {
xEssentialsMemory.returnPlayer(e.getPlayer()).put("muted", 0);
xEssentialsMemory.updatePlayerConfig(e.getPlayer());
} else {
e.setCancelled(true);
}
}
}
AntiFloodSpam.java 文件源码
项目:xEssentials_old_Source
阅读 25
收藏 0
点赞 0
评论 0
@EventHandler
public void playerChatTime(PlayerChatEvent e) {
if(chatTime.containsKey(e.getPlayer().getName())) {
if(System.currentTimeMillis() < chatTime.get(e.getPlayer().getName())) {
cmdban.setBanned(xEssentialsMemory.antiFloodSpamMessage, e.getPlayer(), banType.floodspam);
} else {
chatTime.remove(e.getPlayer().getName());
}
} else {
chatTime.put(e.getPlayer().getName(), System.currentTimeMillis());
}
}
PetDataListener.java 文件源码
项目:PetBlocks
阅读 25
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.HIGHEST)
public void playerChatEvent(PlayerChatEvent event) {
if (!Config.getInstance().isChat_async() && Config.getInstance().isChatHighestPriority()) {
this.handleChatMessage(event);
}
}