本文整理汇总了Java中org.bukkit.event.player.AsyncPlayerChatEvent类的典型用法代码示例。如果您正苦于以下问题:Java AsyncPlayerChatEvent类的具体用法?Java AsyncPlayerChatEvent怎么用?Java AsyncPlayerChatEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AsyncPlayerChatEvent类属于org.bukkit.event.player包,在下文中一共展示了AsyncPlayerChatEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onChatHighPriority
import org.bukkit.event.player.AsyncPlayerChatEvent; //导入依赖的package包/类
@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);
}
示例2: spamChecker
import org.bukkit.event.player.AsyncPlayerChatEvent; //导入依赖的package包/类
@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);
}
}
示例3: call
import org.bukkit.event.player.AsyncPlayerChatEvent; //导入依赖的package包/类
@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);
}
}
示例4: 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())
);
}
示例5: ChatCheckCrash
import org.bukkit.event.player.AsyncPlayerChatEvent; //导入依赖的package包/类
@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);
}
}
}
示例6: 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);
}
}
}
}
示例7: onPlayerChat
import org.bukkit.event.player.AsyncPlayerChatEvent; //导入依赖的package包/类
@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);
}
示例8: 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("%", "%%"));
}
示例9: 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);
}
}
}
示例10: 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);
}
示例11: onChat
import org.bukkit.event.player.AsyncPlayerChatEvent; //导入依赖的package包/类
@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);
}
示例12: 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);
}
示例13: 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))));
}
}
}
}
示例14: 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);
}
}
}
}
示例15: setLine
import org.bukkit.event.player.AsyncPlayerChatEvent; //导入依赖的package包/类
@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);
}
}
}