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


Java AsyncPlayerChatEvent.getPlayer方法代码示例

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


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

示例1: onChat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@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);
	}
}
 
开发者ID:DiscowZombie,项目名称:UltimateTs,代码行数:21,代码来源:TypeYesOrNo.java

示例2: onPlayerChat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@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);
			}
		}
	}
}
 
开发者ID:RcExtract,项目名称:ChatAssets,代码行数:18,代码来源:AntiCaseSpam.java

示例3: checkDirty

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@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);
			}
		}
	}
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:23,代码来源:AntiSpam.java

示例4: onPrivateTag

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@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))));
			}
		}
	}
}
 
开发者ID:RcExtract,项目名称:ChatAssets,代码行数:27,代码来源:PrivateMessenger.java

示例5: onChat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@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);
        }
    }
}
 
开发者ID:Warvale,项目名称:Ace,代码行数:18,代码来源:RankListener.java

示例6: onChat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@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);

}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:27,代码来源:CommandAndChatCooldown.java

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

示例8: onChat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onChat(final AsyncPlayerChatEvent event) {
    // Team chat
    if (getBeaconzWorld() == null || event.getPlayer() == null) {
        return;
    }
    if (Settings.teamChat && event.getPlayer().getWorld().equals(getBeaconzWorld())) {
        // Cancel the event
        event.setCancelled(true);
        // Queue the sync task because you cannot use HashMaps asynchronously. Delaying to the next tick
        // won't be a major issue for synch events either.
        Bukkit.getScheduler().runTask(plugin, new Runnable() {
            @Override
            public void run() {
                teamChat(event,event.getMessage());
            }});
    }
}
 
开发者ID:tastybento,项目名称:beaconz,代码行数:19,代码来源:ChatListener.java

示例9: chatProcess

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
public void chatProcess(AsyncPlayerChatEvent e) {
    Player player = e.getPlayer();
    PlayerInfo pi = players.get(player.getName().toLowerCase());
    if (pi != null) {
        long now = new Date().getTime();
        if (pi.lastTimeChatCmd != 0) {
            int delay = plugin.config.getChatDelay(player);
            int timeToWait = (int) ((pi.lastTimeChatCmd + delay) - now) / 1000;
            if (timeToWait > 0) {
                e.setCancelled(true);
                player.sendMessage(plugin.getPrefix() + ChatColor.RED
                        + "Debido a tu rango debes esperar " + timeToWait + " segundos para hablar.");
            } else {
                pi.lastTimeChatCmd = now;
            }
        } else {
            pi.lastTimeChatCmd = now;
        }
    }
    if (!e.isCancelled()) {
        plugin.chat.processChat(e);
    }
}
 
开发者ID:ddonofrio,项目名称:libelula,代码行数:24,代码来源:PlayerManager.java

示例10: onChat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onChat(final AsyncPlayerChatEvent event) {
    final VaultMagic vm = this.vaultHook.getVaultMagic();
    if (vm == null) return;
    if (!vm.hasPermission()) return;
    final Permission permission = vm.getPermission();
    final Player player = event.getPlayer();
    final Titles titles = this.vaultHook.getChatterbox().getAPI().getTitleAPI().getTitles(player.getUniqueId());
    if (permission.hasGroupSupport()) {
        final String group = permission.getPrimaryGroup(player);
        if (group != null) {
            this.addChatterboxTitles(titles, group);
            if (vm.hasChat()) {
                this.addOtherGroupTitles(titles, group, vm.getChat(), player);
            }
        }
    }
    if (vm.hasChat()) {
        this.addOtherPlayerTitles(titles, vm.getChat(), player);
    }
}
 
开发者ID:Chatterbox,项目名称:Chatterbox,代码行数:22,代码来源:PlayerListener.java

示例11: onPlayerChat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPlayerChat(AsyncPlayerChatEvent playerChatEvent) {
    Player sender = playerChatEvent.getPlayer();
    String message = playerChatEvent.getMessage();
    String format = playerChatEvent.getFormat();
    String chatMessage = String.format(format, sender.getDisplayName(), message);

    Subscriber subscriber = plugin.getSubscribers().get(sender.getUniqueId());
    Channel messageChannel = subscriber.getCurrentChannel();
    messageChannel.addMessage(chatMessage);

    notifyChanges(messageChannel);

    //remove the recipients from normal chats without hiding log messages
    playerChatEvent.getRecipients().clear();
}
 
开发者ID:games647,项目名称:TabChannels,代码行数:17,代码来源:ChatListener.java

示例12: onRepeat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler
public void onRepeat(AsyncPlayerChatEvent event) {
	Player player = event.getPlayer();
	for(String msg : recent.get(player.getName())) {
		if(ChatColor.stripColor(event.getMessage()).equalsIgnoreCase(msg)) {
			if(!player.hasPermission(Permission.SPAM_BYPASS)) {
				event.setCancelled(true);
				player.sendMessage(ChatColor.RED + "Your message is too similar to your last five messages!");
			} else {
				player.sendMessage(ChatColor.YELLOW + "(Would've gotten a \"maybe you shouldn't spam\" message.)");
			}
		}
	}
	String old4 = recent.get(player.getName())[3];
	String old3 = recent.get(player.getName())[2];
	String old2 = recent.get(player.getName())[1];
	String old1 = recent.get(player.getName())[0];
	String[] recentnew = new String[0];
	recentnew[0] = event.getMessage();
	recentnew[1] = old1;
	recentnew[2] = old2;
	recentnew[3] = old3;
	recentnew[4] = old4;
	recent.put(player.getName(), recentnew);
}
 
开发者ID:McSheepMaster,项目名称:sNoHax,代码行数:26,代码来源:Spam.java

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

示例14: onPlayerChat

import org.bukkit.event.player.AsyncPlayerChatEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerChat(final AsyncPlayerChatEvent e) {
    Player sender = e.getPlayer();
    PlayerMeta meta = PlayerMeta.getMeta(sender);
    GameTeam team = meta.getTeam();
    boolean isAll = false;
    boolean dead = !meta.isAlive() && plugin.getPhase() > 0;
    String msg = e.getMessage();

    if (e.getMessage().startsWith("!") && !e.getMessage().equalsIgnoreCase("!")) {
        isAll = true;
        msg = msg.substring(1);
    }

    if (team == GameTeam.NONE)
        isAll = true;

    if (isAll)
        ChatUtil.allMessage(team, sender, msg, dead);
    else
        ChatUtil.teamMessage(team, sender, msg, dead);

    e.setCancelled(true);
}
 
开发者ID:cancabron,项目名称:Annihilation,代码行数:25,代码来源:ChatListener.java

示例15: 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);
            }
        }
    }
}
 
开发者ID:DSH105,项目名称:HoloAPI,代码行数:20,代码来源:IndicatorListener.java


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