geforkt von SteamWar/BungeeCore
Current state
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
0bf5a65850
Commit
54932f6ebc
@ -19,13 +19,11 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore;
|
package de.steamwar.bungeecore;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
import de.steamwar.messages.ChatSender;
|
||||||
import de.steamwar.messages.SteamwarResourceBundle;
|
import de.steamwar.messages.SteamwarResourceBundle;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
@ -37,26 +35,32 @@ import java.util.ResourceBundle;
|
|||||||
|
|
||||||
public class Message {
|
public class Message {
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static TextComponent parseToComponent(String message, boolean prefixed, CommandSender sender, Object... params){
|
public static TextComponent parseToComponent(String message, boolean prefixed, CommandSender sender, Object... params){
|
||||||
return new TextComponent(TextComponent.fromLegacyText(parse(message, prefixed, locale(sender), params)));
|
return new TextComponent(TextComponent.fromLegacyText(parse(message, prefixed, locale(sender), params)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static String parsePrefixed(String message, CommandSender sender, Object... params){
|
public static String parsePrefixed(String message, CommandSender sender, Object... params){
|
||||||
return parse(message, true, locale(sender), params);
|
return parse(message, true, locale(sender), params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static String parse(String message, CommandSender sender, Object... params){
|
public static String parse(String message, CommandSender sender, Object... params){
|
||||||
return parse(message, false, locale(sender), params);
|
return parse(message, false, locale(sender), params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static String parse(String message, Locale locale, Object... params){
|
public static String parse(String message, Locale locale, Object... params){
|
||||||
return parse(message, false, locale, params);
|
return parse(message, false, locale, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
private static Locale locale(CommandSender sender) {
|
private static Locale locale(CommandSender sender) {
|
||||||
return sender instanceof ProxiedPlayer ? ((ProxiedPlayer)sender).getLocale() : Locale.getDefault();
|
return sender instanceof ProxiedPlayer ? ((ProxiedPlayer)sender).getLocale() : Locale.getDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
private static String parse(String message, boolean prefixed, Locale locale, Object... params){
|
private static String parse(String message, boolean prefixed, Locale locale, Object... params){
|
||||||
if(locale == null)
|
if(locale == null)
|
||||||
locale = Locale.getDefault();
|
locale = Locale.getDefault();
|
||||||
@ -70,7 +74,7 @@ public class Message {
|
|||||||
for (int i = 0; i < params.length; i++) {
|
for (int i = 0; i < params.length; i++) {
|
||||||
if(params[i] instanceof Message) {
|
if(params[i] instanceof Message) {
|
||||||
Message msg = (Message) params[i];
|
Message msg = (Message) params[i];
|
||||||
params[i] = parse(msg.getMessage(), false, locale, msg.getParams());
|
params[i] = parse(msg.getFormat(), false, locale, msg.getParams());
|
||||||
} else if(params[i] instanceof Date) {
|
} else if(params[i] instanceof Date) {
|
||||||
params[i] = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale).format((Date) params[i]);
|
params[i] = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale).format((Date) params[i]);
|
||||||
}
|
}
|
||||||
@ -78,91 +82,61 @@ public class Message {
|
|||||||
return format.format(params);
|
return format.format(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static void send(String message, CommandSender sender, Object... params){
|
public static void send(String message, CommandSender sender, Object... params){
|
||||||
send(message, true, sender, ChatMessageType.SYSTEM, null, null, params);
|
send(message, true, sender, ChatMessageType.SYSTEM, null, null, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static void sendPrefixless(String message, CommandSender sender, Object... params){
|
public static void sendPrefixless(String message, CommandSender sender, Object... params){
|
||||||
send(message, false, sender, ChatMessageType.SYSTEM, null, null, params);
|
send(message, false, sender, ChatMessageType.SYSTEM, null, null, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void send(String message, CommandSender sender, ChatMessageType type, Object... params){
|
@Deprecated
|
||||||
send(message, true, sender, type, null, null, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendPrefixless(String message, CommandSender sender, ChatMessageType type, Object... params){
|
|
||||||
send(message, false, sender, type, null, null, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void send(String message, CommandSender sender, String onHover, ClickEvent onClick, Object... params){
|
public static void send(String message, CommandSender sender, String onHover, ClickEvent onClick, Object... params){
|
||||||
send(message, true, sender, ChatMessageType.SYSTEM, onHover, onClick, params);
|
send(message, true, sender, ChatMessageType.SYSTEM, onHover, onClick, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static void sendPrefixless(String message, CommandSender sender, String onHover, ClickEvent onClick, Object... params){
|
public static void sendPrefixless(String message, CommandSender sender, String onHover, ClickEvent onClick, Object... params){
|
||||||
send(message, false, sender, ChatMessageType.SYSTEM, onHover, onClick, params);
|
send(message, false, sender, ChatMessageType.SYSTEM, onHover, onClick, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void send(String message, boolean prefixed, CommandSender sender, ChatMessageType type, String onHover, ClickEvent onClick, Object... params){
|
@Deprecated
|
||||||
if(type == ChatMessageType.CHAT && sender instanceof ProxiedPlayer && ((ProxiedPlayer)sender).getChatMode() != ProxiedPlayer.ChatMode.SHOWN)
|
private static void send(String message, boolean prefixed, CommandSender s, ChatMessageType type, String onHover, ClickEvent onClick, Object... params){
|
||||||
|
ChatSender sender = ChatSender.of(s);
|
||||||
|
if(type == ChatMessageType.CHAT && !sender.chatShown())
|
||||||
return;
|
return;
|
||||||
TextComponent msg = parseToComponent(message, prefixed, sender, params);
|
|
||||||
if(onHover != null)
|
|
||||||
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(onHover)));
|
|
||||||
if(onClick != null)
|
|
||||||
msg.setClickEvent(onClick);
|
|
||||||
if(sender instanceof ProxiedPlayer)
|
|
||||||
((ProxiedPlayer)sender).sendMessage(type, msg);
|
|
||||||
else
|
|
||||||
sender.sendMessage(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void broadcast(String message, String onHover, ClickEvent onClick, Object... params){
|
sender.send(prefixed, type, new Message("PLAIN_STRING", onHover), onClick, new Message(message, params));
|
||||||
for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers())
|
|
||||||
send(message, player, parse(onHover, player, params), onClick, params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void broadcast(String message, Object... params) {
|
public static void broadcast(String message, Object... params) {
|
||||||
for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers())
|
broadcast(message, null, null, params);
|
||||||
send(message, player, ChatMessageType.SYSTEM, params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void chat(String message, Object... params){
|
public static void broadcast(String message, String onHover, ClickEvent onClick, Object... params) {
|
||||||
for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){
|
ChatSender.allReceivers().forEach(player -> player.prefixless(message, new Message(onHover, params), onClick, params));
|
||||||
Subserver server = Subserver.getSubserver(player);
|
|
||||||
if(server == null || server.getType() != Servertype.ARENA)
|
|
||||||
sendPrefixless(message, player, ChatMessageType.CHAT, params);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void team(String message, Object... params) {
|
public static void team(String message, Object... params) {
|
||||||
team(message, ChatMessageType.SYSTEM, params);
|
team(message, null, null, params);
|
||||||
}
|
|
||||||
|
|
||||||
public static void team(String message, ChatMessageType type, Object... params){
|
|
||||||
for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){
|
|
||||||
if(player.getGroups().contains(ConnectionListener.TEAM_GROUP)) {
|
|
||||||
sendPrefixless(message, player, type, params);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void team(String message, String onHover, ClickEvent onClick, Object... params) {
|
public static void team(String message, String onHover, ClickEvent onClick, Object... params) {
|
||||||
for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){
|
ChatSender.serverteamReceivers().filter(player -> player.user().getUserGroup().isTeamGroup()).forEach(player -> player.prefixless(message, new Message(onHover, params), onClick, params));
|
||||||
if(player.getGroups().contains(ConnectionListener.TEAM_GROUP))
|
|
||||||
sendPrefixless(message, player, Message.parse(onHover, player, params), onClick, params);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String message;
|
private final String format;
|
||||||
private final Object[] params;
|
private final Object[] params;
|
||||||
|
|
||||||
public Message(String message, Object... params) {
|
public Message(String format, Object... params) {
|
||||||
this.message = message;
|
this.format = format;
|
||||||
this.params = params;
|
this.params = params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
public String getFormat() {
|
||||||
return message;
|
return format;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] getParams() {
|
public Object[] getParams() {
|
||||||
|
@ -59,10 +59,10 @@ public class SteamwarDiscordBot {
|
|||||||
private volatile AnnouncementListener announcementListener;
|
private volatile AnnouncementListener announcementListener;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private volatile IngameChatListener ingameChatListener;
|
private volatile DiscordChatListener ingameChatListener;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private volatile ServerTeamChatListener serverTeamChatListener;
|
private volatile DiscordChatListener serverTeamChatListener;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final JDA jda;
|
private final JDA jda;
|
||||||
@ -111,8 +111,8 @@ public class SteamwarDiscordBot {
|
|||||||
new DiscordEventListener();
|
new DiscordEventListener();
|
||||||
new PrivateMessageListener();
|
new PrivateMessageListener();
|
||||||
announcementListener = new AnnouncementListener();
|
announcementListener = new AnnouncementListener();
|
||||||
ingameChatListener = new IngameChatListener();
|
ingameChatListener = new DiscordChatListener(SteamwarDiscordBotConfig.INGAME_CHANNEL, "CHAT_DISCORD_GLOBAL");
|
||||||
serverTeamChatListener = new ServerTeamChatListener();
|
serverTeamChatListener = new DiscordChatListener(SteamwarDiscordBotConfig.SERVER_TEAM_CHANNEL, "CHAT_SERVERTEAM");
|
||||||
new SlashCommandListener();
|
new SlashCommandListener();
|
||||||
jda.retrieveCommands().complete().forEach(command -> jda.deleteCommandById(command.getId()).queue());
|
jda.retrieveCommands().complete().forEach(command -> jda.deleteCommandById(command.getId()).queue());
|
||||||
|
|
||||||
|
@ -31,27 +31,32 @@ import net.dv8tion.jda.api.entities.TextChannel;
|
|||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class IngameChatListener extends BasicDiscordListener {
|
public class DiscordChatListener extends BasicDiscordListener {
|
||||||
|
|
||||||
|
private final String channel;
|
||||||
|
private final String format;
|
||||||
|
|
||||||
|
public DiscordChatListener(String channel, String format) {
|
||||||
|
this.channel = channel;
|
||||||
|
this.format = format;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) {
|
public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) {
|
||||||
if (!event.getChannel().getId().equals(SteamwarDiscordBotConfig.INGAME_CHANNEL)) {
|
if (!event.getChannel().getId().equals(channel) || event.getAuthor().isBot())
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
if (event.getAuthor().isBot()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Member member = event.getMember();
|
Member member = event.getMember();
|
||||||
SteamwarUser steamwarUser = SteamwarUser.get(member.getIdLong());
|
SteamwarUser steamwarUser = SteamwarUser.get(member.getIdLong());
|
||||||
if (steamwarUser == null || event.getMessage().getContentRaw().length() > 250 || steamwarUser.isPunished(Punishment.PunishmentType.Ban)) {
|
if (steamwarUser == null || event.getMessage().getContentRaw().length() > 250 || steamwarUser.isPunished(Punishment.PunishmentType.Ban)) {
|
||||||
event.getMessage().delete().queue();
|
event.getMessage().delete().queue();
|
||||||
} else {
|
} else {
|
||||||
ChatListener.sendChat(ChatSender.of(event.getMessage(), steamwarUser), ChatListener.globalReceivers(), "CHAT_DISCORD_GLOBAL", event.getMessage().getContentDisplay().replaceAll("§", "&").replace('\n', ' '));
|
ChatListener.sendChat(ChatSender.of(event.getMessage(), steamwarUser), ChatSender.globalReceivers(), format, event.getMessage().getContentDisplay().replace('§', '&').replace('\n', ' '));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send(String message) {
|
public void send(String message) {
|
||||||
TextChannel textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.INGAME_CHANNEL);
|
TextChannel textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(channel);
|
||||||
assert textChannel != null;
|
assert textChannel != null;
|
||||||
MessageBuilder messageBuilder = new MessageBuilder();
|
MessageBuilder messageBuilder = new MessageBuilder();
|
||||||
messageBuilder.append(message.replace("&", "").replace("@everyone", "`@everyone`").replace("@here", "`@here`").replaceAll("<[@#]!?\\d+>", "`$0`"));
|
messageBuilder.append(message.replace("&", "").replace("@everyone", "`@everyone`").replace("@here", "`@here`").replaceAll("<[@#]!?\\d+>", "`$0`"));
|
@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.bungeecore.bot.listeners;
|
|
||||||
|
|
||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
|
||||||
import de.steamwar.bungeecore.commands.ServerTeamchatCommand;
|
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
|
||||||
import net.dv8tion.jda.api.entities.TextChannel;
|
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class ServerTeamChatListener extends BasicDiscordListener {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) {
|
|
||||||
if (!event.getChannel().getId().equals(SteamwarDiscordBotConfig.SERVER_TEAM_CHANNEL)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (event.getAuthor().isBot()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Member member = event.getMember();
|
|
||||||
SteamwarUser steamwarUser = SteamwarUser.get(member.getIdLong());
|
|
||||||
if (steamwarUser == null) {
|
|
||||||
event.getMessage().delete().complete();
|
|
||||||
} else {
|
|
||||||
ServerTeamchatCommand.sendToTeam(event.getMessage().getContentRaw(), steamwarUser);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void send(String message) {
|
|
||||||
TextChannel textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.SERVER_TEAM_CHANNEL);
|
|
||||||
assert textChannel != null;
|
|
||||||
MessageBuilder messageBuilder = new MessageBuilder();
|
|
||||||
messageBuilder.append(message.replace("&", ""));
|
|
||||||
textChannel.sendMessage(messageBuilder.build()).queue();
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,16 +19,16 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.BungeeCore;
|
import de.steamwar.bungeecore.listeners.ChatListener;
|
||||||
import de.steamwar.bungeecore.Message;
|
|
||||||
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
||||||
import de.steamwar.bungeecore.sql.Punishment;
|
import de.steamwar.messages.ChatSender;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static de.steamwar.bungeecore.Storage.lastChats;
|
import static de.steamwar.bungeecore.Storage.lastChats;
|
||||||
|
|
||||||
@ -40,46 +40,33 @@ public class MsgCommand extends BasicCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(sender instanceof ProxiedPlayer){
|
if(!(sender instanceof ProxiedPlayer))
|
||||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
return;
|
||||||
|
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
Message.send("MSG_USAGE", player);
|
ChatSender.of(sender).system("MSG_USAGE");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SteamwarUser user = SteamwarUser.get(player);
|
msg((ProxiedPlayer) sender, ProxyServer.getInstance().getPlayer(args[0]), Arrays.copyOfRange(args, 1, args.length));
|
||||||
if (user.isPunishedWithMessage(player, Punishment.PunishmentType.Mute)) {
|
}
|
||||||
|
|
||||||
|
public static void msg(ProxiedPlayer player, ProxiedPlayer target, String[] args) {
|
||||||
|
ChatSender sender = ChatSender.of(player);
|
||||||
|
if(target == null || !target.isConnected()) {
|
||||||
|
sender.system("MSG_OFFLINE");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]);
|
if (IgnoreSystem.isIgnored(target, player)) {
|
||||||
if(target == null){
|
sender.system("MSG_IGNORED");
|
||||||
Message.send("MSG_OFFLINE", player);
|
|
||||||
return;
|
|
||||||
}else if (IgnoreSystem.isIgnored(target, player)) {
|
|
||||||
Message.send("MSG_IGNORED", player);
|
|
||||||
return;
|
|
||||||
}else if(target.getChatMode() != ProxiedPlayer.ChatMode.SHOWN){
|
|
||||||
Message.send("MSG_NOMESSAGE", player);
|
|
||||||
return;
|
|
||||||
}else if(target.equals(player)){
|
|
||||||
Message.send("MSG_SELF", player);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder msgBuilder = new StringBuilder();
|
ChatListener.sendChat(sender, Stream.of(sender, ChatSender.of(target)), "CHAT_MSG", String.join(" ", args));
|
||||||
for (int i = 1; i < args.length; i++){
|
|
||||||
msgBuilder.append(args[i]).append(" ");
|
|
||||||
}
|
|
||||||
Message.sendPrefixless("MSG_FORMAT", player, player.getName(), target.getName(), msgBuilder.toString());
|
|
||||||
Message.sendPrefixless("MSG_FORMAT", target, player.getName(), target.getName(), msgBuilder.toString());
|
|
||||||
BungeeCore.log(Message.parse("MSG_FORMAT", player, player.getName(), target.getName(), msgBuilder.toString()));
|
|
||||||
|
|
||||||
lastChats.put(player, target);
|
lastChats.put(player, target);
|
||||||
lastChats.put(target, player);
|
lastChats.put(target, player);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
|
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
|
||||||
|
@ -19,11 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.BungeeCore;
|
import de.steamwar.messages.ChatSender;
|
||||||
import de.steamwar.bungeecore.Message;
|
|
||||||
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
|
||||||
import de.steamwar.bungeecore.sql.Punishment;
|
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
@ -37,43 +33,14 @@ public class RCommand extends BasicCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(sender instanceof ProxiedPlayer){
|
if(!(sender instanceof ProxiedPlayer))
|
||||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
return;
|
||||||
|
|
||||||
if(args.length == 0){
|
if(args.length == 0){
|
||||||
Message.send("R_USAGE", player);
|
ChatSender.of(sender).system("R_USAGE");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SteamwarUser user = SteamwarUser.get(player);
|
MsgCommand.msg((ProxiedPlayer) sender, lastChats.get(sender), args);
|
||||||
if (user.isPunishedWithMessage(player, Punishment.PunishmentType.Mute)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProxiedPlayer target = lastChats.get(player);
|
|
||||||
if(target == null){
|
|
||||||
Message.send("R_NOTHING", player);
|
|
||||||
return;
|
|
||||||
}else if(!target.isConnected()){
|
|
||||||
Message.send("R_OFFLINE", player);
|
|
||||||
lastChats.remove(player);
|
|
||||||
return;
|
|
||||||
}else if (IgnoreSystem.isIgnored(target, player)) {
|
|
||||||
Message.send("R_BLOCKED", player);
|
|
||||||
return;
|
|
||||||
}else if(target.getChatMode() != ProxiedPlayer.ChatMode.SHOWN){
|
|
||||||
Message.send("R_NO_CHAT", player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
StringBuilder msgBuilder = new StringBuilder();
|
|
||||||
for (String arg : args){
|
|
||||||
msgBuilder.append(arg).append(" ");
|
|
||||||
}
|
|
||||||
Message.sendPrefixless("MSG_FORMAT", player, player.getName(), target.getName(), msgBuilder.toString());
|
|
||||||
Message.sendPrefixless("MSG_FORMAT", target, player.getName(), target.getName(), msgBuilder.toString());
|
|
||||||
BungeeCore.log(Message.parse("MSG_FORMAT", player, player.getName(), target.getName(), msgBuilder.toString()));
|
|
||||||
|
|
||||||
lastChats.put(target, player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,17 +19,9 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.BungeeCore;
|
|
||||||
import de.steamwar.bungeecore.Message;
|
|
||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
|
||||||
import de.steamwar.bungeecore.listeners.ChatListener;
|
import de.steamwar.bungeecore.listeners.ChatListener;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
public class ServerTeamchatCommand extends BasicCommand {
|
public class ServerTeamchatCommand extends BasicCommand {
|
||||||
|
|
||||||
@ -38,48 +30,13 @@ public class ServerTeamchatCommand extends BasicCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender s, String[] args) {
|
||||||
if(sender instanceof ProxiedPlayer){
|
ChatSender sender = ChatSender.of(s);
|
||||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
|
||||||
|
|
||||||
if(args.length == 0) {
|
if(args.length == 0) {
|
||||||
Message.sendPrefixless("STC_USAGE", player);
|
sender.system("STC_USAGE");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder msgBuilder = new StringBuilder();
|
ChatListener.sendChat(sender, ChatSender.serverteamReceivers(), "CHAT_SERVERTEAM", String.join(" ", args));
|
||||||
for (String arg : args){
|
|
||||||
msgBuilder.append(arg).append(" ");
|
|
||||||
}
|
|
||||||
String msg = msgBuilder.toString();
|
|
||||||
msg = ChatColor.translateAlternateColorCodes('&', msg);
|
|
||||||
|
|
||||||
if (SteamwarDiscordBot.instance() != null) {
|
|
||||||
try {
|
|
||||||
SteamwarDiscordBot.instance().getServerTeamChatListener().send("<t:" + (System.currentTimeMillis() / 1000) + "> " + (player.getName() + "» " + msg).replaceAll("§[a-f0-9r]", ""));
|
|
||||||
} catch (Exception e) {
|
|
||||||
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not send stc message to discord", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sendToTeam(msg, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendToTeam(String message, SteamwarUser sender){
|
|
||||||
for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
|
|
||||||
if ((target.hasPermission("bungeecore.teamchat"))
|
|
||||||
&& target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){
|
|
||||||
Message.sendPrefixless("STC_FORMAT", target, sender.getUserName(), ChatListener.highlightOwnMarks(message, "§r", target));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendToTeam(String message, ProxiedPlayer sender){
|
|
||||||
for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
|
|
||||||
if ((target.hasPermission("bungeecore.teamchat"))
|
|
||||||
&& target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){
|
|
||||||
Message.sendPrefixless("STC_FORMAT", target, sender.getName(), ChatListener.highlightOwnMarks(message, "§r", target));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,10 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
|
||||||
import de.steamwar.bungeecore.listeners.ChatListener;
|
import de.steamwar.bungeecore.listeners.ChatListener;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
public class TeamchatCommand extends BasicCommand {
|
public class TeamchatCommand extends BasicCommand {
|
||||||
|
|
||||||
@ -34,35 +31,19 @@ public class TeamchatCommand extends BasicCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender s, String[] args) {
|
||||||
if(sender instanceof ProxiedPlayer){
|
ChatSender sender = ChatSender.of(s);
|
||||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
|
||||||
|
|
||||||
if(user.getTeam() == 0){
|
|
||||||
Message.send("TC_NO_TEAM", player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(args.length == 0){
|
if(args.length == 0){
|
||||||
Message.send("TC_USAGE", player);
|
sender.system("TC_USAGE");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder msgBuilder = new StringBuilder();
|
SteamwarUser user = sender.user();
|
||||||
for (String arg : args){
|
if(user.getTeam() == 0){
|
||||||
msgBuilder.append(arg).append(" ");
|
sender.system("TC_NO_TEAM");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
String msg = msgBuilder.toString();
|
|
||||||
msg = ChatColor.translateAlternateColorCodes('&', msg);
|
|
||||||
|
|
||||||
for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
|
ChatListener.sendChat(sender, ChatSender.allReceivers().filter(player -> player.user().getTeam() == user.getTeam()), "CHAT_TEAM", String.join(" ", args));
|
||||||
SteamwarUser targetuser = SteamwarUser.get(target.getUniqueId());
|
|
||||||
if (targetuser.getTeam() == user.getTeam()
|
|
||||||
&& target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){
|
|
||||||
Message.sendPrefixless("TC_FORMAT", target, player.getName(), ChatListener.highlightOwnMarks(msg, "§f", target));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,13 +30,11 @@ import net.md_5.bungee.api.event.ChatEvent;
|
|||||||
import net.md_5.bungee.api.event.TabCompleteEvent;
|
import net.md_5.bungee.api.event.TabCompleteEvent;
|
||||||
import net.md_5.bungee.api.event.TabCompleteResponseEvent;
|
import net.md_5.bungee.api.event.TabCompleteResponseEvent;
|
||||||
import net.md_5.bungee.api.scheduler.TaskScheduler;
|
import net.md_5.bungee.api.scheduler.TaskScheduler;
|
||||||
import net.md_5.bungee.command.ConsoleCommandSender;
|
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@ -58,7 +56,7 @@ public class ChatListener extends BasicListener {
|
|||||||
|
|
||||||
if (message.contains("jndi:ldap")) {
|
if (message.contains("jndi:ldap")) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
SteamwarUser.get(player.getUniqueId()).punishPerma(Punishment.PunishmentType.Ban, "Versuchte Exploit-Ausnutzung", 0);
|
SteamwarUser.get(player).punishPerma(Punishment.PunishmentType.Ban, "Versuchte Exploit-Ausnutzung", 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,32 +74,73 @@ public class ChatListener extends BasicListener {
|
|||||||
} else if (message.startsWith("+")) {
|
} else if (message.startsWith("+")) {
|
||||||
localChat(player, message.substring(1));
|
localChat(player, message.substring(1));
|
||||||
} else {
|
} else {
|
||||||
String finalMessage = message;
|
sendChat(ChatSender.of(player), ChatSender.globalReceivers(), "CHAT_GLOBAL", message);
|
||||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> sendChat(ChatSender.of(player), globalReceivers(), "CHAT_GLOBAL", finalMessage));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Stream<ProxiedPlayer> globalReceivers() {
|
public static void sendChat(ChatSender sender, Stream<ChatSender> receivers, String format, String message) {
|
||||||
//TODO: Filter arena players
|
String finalMessage = modifyFilter(sender, message);
|
||||||
return ProxyServer.getInstance().getPlayers().stream();
|
if(finalMessage == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
SteamwarUser user = sender.user();
|
||||||
|
|
||||||
|
AtomicBoolean noReceiver = new AtomicBoolean(true);
|
||||||
|
receivers.filter(ChatSender::chatShown).forEach(player -> {
|
||||||
|
noReceiver.set(false);
|
||||||
|
chatToReciever(player, user, format, finalMessage);
|
||||||
|
});
|
||||||
|
|
||||||
|
chatToReciever(ChatSender.console(), user, format, finalMessage);
|
||||||
|
|
||||||
|
if(format.equals("CHAT_GLOBAL")) {
|
||||||
|
if (SteamwarDiscordBot.instance() != null)
|
||||||
|
chatToReciever(ChatSender.discordChannel(SteamwarDiscordBot.instance().getIngameChatListener()), user, format, finalMessage);
|
||||||
|
} else if (format.equals("CHAT_SERVERTEAM")) {
|
||||||
|
if (SteamwarDiscordBot.instance() != null)
|
||||||
|
chatToReciever(ChatSender.discordChannel(SteamwarDiscordBot.instance().getServerTeamChatListener()), user, format, finalMessage);
|
||||||
|
} else if (noReceiver.get()) {
|
||||||
|
sender.system("CHAT_NO_RECEIVER");
|
||||||
|
//TODO always 1 Receiver (own)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendChat(ChatSender sender, Stream<ProxiedPlayer> receivers, String format, String message) {
|
public static void localChat(ProxiedPlayer player, String message) {
|
||||||
|
ChatSender sender = ChatSender.of(player);
|
||||||
|
if(message.length() == 0){
|
||||||
|
sender.system("CHAT_BC_USAGE");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
message = sanitize7(message);
|
||||||
|
|
||||||
|
if(ChatListener.filteredCommand(player, message))
|
||||||
|
return;
|
||||||
|
if(!message.startsWith("/")) {
|
||||||
|
message = modifyFilter(sender, message);
|
||||||
|
if(message == null)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.chat(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String modifyFilter(ChatSender sender, String message) {
|
||||||
if(!sender.chatShown()) {
|
if(!sender.chatShown()) {
|
||||||
sender.system("CHAT_RECEIVE");
|
sender.system("CHAT_RECEIVE");
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
SteamwarUser user = sender.user();
|
SteamwarUser user = sender.user();
|
||||||
UserGroup group = user.getUserGroup();
|
UserGroup group = user.getUserGroup();
|
||||||
if(!group.isTeamGroup() && (message.contains("http:") || message.contains("https:") || message.contains("www."))){
|
if(!group.isTeamGroup() && (message.contains("http:") || message.contains("https:") || message.contains("www."))){
|
||||||
sender.system("CHAT_NO_LINKS");
|
sender.system("CHAT_NO_LINKS");
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute))
|
if (user.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute))
|
||||||
return;
|
return null;
|
||||||
|
|
||||||
if(group != UserGroup.Member || coloredTeams.contains(user.getTeam()))
|
if(group != UserGroup.Member || coloredTeams.contains(user.getTeam()))
|
||||||
message = ChatColor.translateAlternateColorCodes('&', message);
|
message = ChatColor.translateAlternateColorCodes('&', message);
|
||||||
@ -110,35 +149,8 @@ public class ChatListener extends BasicListener {
|
|||||||
specialAlert(sender, "Lixfel", "CHAT_LIXFEL_", 3, 6, 11, 12, 15);
|
specialAlert(sender, "Lixfel", "CHAT_LIXFEL_", 3, 6, 11, 12, 15);
|
||||||
if (message.contains("YOYONOW"))
|
if (message.contains("YOYONOW"))
|
||||||
specialAlert(sender, "YoyoNow", "CHAT_YOYONOW_", 3, 6, 11, 12);
|
specialAlert(sender, "YoyoNow", "CHAT_YOYONOW_", 3, 6, 11, 12);
|
||||||
//TODO: Extract filters and specials for local chat
|
|
||||||
|
|
||||||
String emblem = UserElo.getEmblem(user);
|
return message;
|
||||||
String team = user.getTeam() == 0 ? "" : Team.get(user.getTeam()).getTeamColor() + Team.get(user.getTeam()).getTeamKuerzel() + " ";
|
|
||||||
String finalMessage = message;
|
|
||||||
|
|
||||||
//Location Team Emblem Group Name» Message
|
|
||||||
// {0}: sender.getName() {1}: target.getName() {2}: message {3}: team {4}: emblem {5}: usercolor {6}: usergroup {7}: Messagecolor
|
|
||||||
// CHAT_SERVERTEAM §eSTC§8»{5}{0} §f{2}
|
|
||||||
// CHAT_TEAM {3}{5}{0}§8» §f{2}
|
|
||||||
// CHAT_GLOBAL {3}{4}{5}{6}{0}§8» {7}{2}
|
|
||||||
// CHAT_DISCORD_GLOBAL §8DC {5}{6}{0}§8» {7}{2}
|
|
||||||
// CHAT_MSG §e{0}§8»§e{1} §f{2}
|
|
||||||
|
|
||||||
AtomicBoolean noReceiver = new AtomicBoolean(true);
|
|
||||||
receivers.map(ChatSender::of).filter(ChatSender::chatShown).forEach(player -> {
|
|
||||||
noReceiver.set(false);
|
|
||||||
chatToReciever(player, user, format, finalMessage);
|
|
||||||
});
|
|
||||||
|
|
||||||
chatToReciever(ChatSender.console(), user, format, message); //TODO only global/DCglobal
|
|
||||||
|
|
||||||
if(format.equals("CHAT_GLOBAL")) {
|
|
||||||
if (SteamwarDiscordBot.instance() != null) {
|
|
||||||
chatToReciever(ChatSender.discordConsole(), user, format, message);
|
|
||||||
}
|
|
||||||
} else if(noReceiver.get()) {
|
|
||||||
//TODO nobody hears you message
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void chatToReciever(ChatSender receiver, SteamwarUser sender, String format, String message) {
|
private static void chatToReciever(ChatSender receiver, SteamwarUser sender, String format, String message) {
|
||||||
@ -146,7 +158,7 @@ public class ChatListener extends BasicListener {
|
|||||||
receiver.chat(new Message(format,
|
receiver.chat(new Message(format,
|
||||||
sender,
|
sender,
|
||||||
receiver,
|
receiver,
|
||||||
highlightOwnMarks(message, group.getChatColorCode(), receiver),
|
highlightMentions(message, group.getChatColorCode(), receiver),
|
||||||
sender.getTeam() == 0 ? "" : Team.get(sender.getTeam()).getTeamColor() + Team.get(sender.getTeam()).getTeamKuerzel() + " ",
|
sender.getTeam() == 0 ? "" : Team.get(sender.getTeam()).getTeamColor() + Team.get(sender.getTeam()).getTeamKuerzel() + " ",
|
||||||
UserElo.getEmblem(sender),
|
UserElo.getEmblem(sender),
|
||||||
group.getColorCode(),
|
group.getColorCode(),
|
||||||
@ -154,20 +166,6 @@ public class ChatListener extends BasicListener {
|
|||||||
group.getChatColorCode()));
|
group.getChatColorCode()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void localChat(ProxiedPlayer player, String message) {
|
|
||||||
if(message.length() == 0){
|
|
||||||
Message.send("CHAT_BC_USAGE", player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
message = sanitize7(message);
|
|
||||||
|
|
||||||
if(ChatListener.filteredCommand(player, message))
|
|
||||||
return;
|
|
||||||
|
|
||||||
player.chat(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String sanitize7(String message) {
|
private static String sanitize7(String message) {
|
||||||
String begin = message.split(" ", 2)[0];
|
String begin = message.split(" ", 2)[0];
|
||||||
if(begin.startsWith("7") && begin.substring(1).matches("[A-Za-z]+")){
|
if(begin.startsWith("7") && begin.substring(1).matches("[A-Za-z]+")){
|
||||||
@ -197,7 +195,7 @@ public class ChatListener extends BasicListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String highlightOwnMarks(String message, String returnColor, ChatSender player) {
|
private static String highlightMentions(String message, String returnColor, ChatSender player) {
|
||||||
if(!message.contains("@"))
|
if(!message.contains("@"))
|
||||||
return message;
|
return message;
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
PREFIX=§eSteam§8War»
|
PREFIX=§eSteam§8War»
|
||||||
SPACER=
|
SPACER=
|
||||||
TIMEFORMAT=HH:mm dd.MM.yyyy
|
TIMEFORMAT=HH:mm dd.MM.yyyy
|
||||||
|
PLAIN_STRING={0}
|
||||||
|
|
||||||
UNKNOWN_COMMAND=§cUnbekannter Befehl.
|
UNKNOWN_COMMAND=§cUnbekannter Befehl.
|
||||||
UNKNOWN_PLAYER=§cDiesen Spieler gibt es nicht.
|
UNKNOWN_PLAYER=§cDiesen Spieler gibt es nicht.
|
||||||
@ -294,11 +295,8 @@ KICK_NORMAL=§cDu wurdest gekickt.
|
|||||||
|
|
||||||
#MsgCommand
|
#MsgCommand
|
||||||
MSG_USAGE=§8/§7msg §8[§eBenutzer§8] [§eNachricht§8]
|
MSG_USAGE=§8/§7msg §8[§eBenutzer§8] [§eNachricht§8]
|
||||||
MSG_OFFLINE=§cDieser Spieler ist derzeit nicht online!
|
MSG_OFFLINE=§cKein Gesprächspartner verfügbar!
|
||||||
MSG_IGNORED=§cDieser Spieler hat dich geblockt!
|
MSG_IGNORED=§cDieser Spieler hat dich geblockt!
|
||||||
MSG_NOMESSAGE=§cDieser Spieler empfängt derzeit keine Chatnachrichten!
|
|
||||||
MSG_SELF=§cNachrichten an dich selbst hast du wirklich nicht nötig!
|
|
||||||
MSG_FORMAT=§e{0}§8»§e{1} §r§7{2}
|
|
||||||
|
|
||||||
#PingCommand
|
#PingCommand
|
||||||
PING_RESPONSE=§7Dein Ping beträgt §c{0}§7 ms!
|
PING_RESPONSE=§7Dein Ping beträgt §c{0}§7 ms!
|
||||||
@ -311,10 +309,6 @@ POLL_ANSWER_NEW=§aDeine Antwort wurde registriert.
|
|||||||
|
|
||||||
#RCommand
|
#RCommand
|
||||||
R_USAGE=§8/§7r §8[§eAntwort§8]
|
R_USAGE=§8/§7r §8[§eAntwort§8]
|
||||||
R_NOTHING=§cDu hast bisher mit niemandem geschrieben!
|
|
||||||
R_OFFLINE=§cDieser Spieler ist derzeit nicht online!
|
|
||||||
R_BLOCKED=§cDieser Spieler hat dich geblockt!
|
|
||||||
R_NO_CHAT=§cDieser Spieler empfängt derzeit keine Chatnachrichten!
|
|
||||||
|
|
||||||
#RegelnCommand
|
#RegelnCommand
|
||||||
REGELN_RULES=§7§lRegelwerke
|
REGELN_RULES=§7§lRegelwerke
|
||||||
@ -356,12 +350,10 @@ TUTORIAL_OWN_HELP=§8/§7tutorial own §8- §7Liste der eigenen Tutorials
|
|||||||
|
|
||||||
#ServerTeamchatCommand
|
#ServerTeamchatCommand
|
||||||
STC_USAGE=§8/§7stc §8[§eNachricht an das Team§8]
|
STC_USAGE=§8/§7stc §8[§eNachricht an das Team§8]
|
||||||
STC_FORMAT=§8STC §e{0}» §r{1}
|
|
||||||
|
|
||||||
#TeamchatCommand
|
#TeamchatCommand
|
||||||
TC_USAGE=§8/§7tc §8[§eNachricht an das Team§8]
|
TC_USAGE=§8/§7tc §8[§eNachricht an das Team§8]
|
||||||
TC_NO_TEAM=§cDu bist in keinem Team.
|
TC_NO_TEAM=§cDu bist in keinem Team.
|
||||||
TC_FORMAT=§8TC §e{0}§8» §r{1}
|
|
||||||
|
|
||||||
#TeamCommand
|
#TeamCommand
|
||||||
TEAM_IN_TEAM=§cDu bist bereits in einem Team.
|
TEAM_IN_TEAM=§cDu bist bereits in einem Team.
|
||||||
@ -501,6 +493,13 @@ CHAT_YOYONOW_4=Ich wünsche dir noch weiterhin ein reibungsloses Spielerlebnis.
|
|||||||
CHAT_RECEIVE=§cUm Chatnachrichten versenden zu können, musst du auch welche empfangen!
|
CHAT_RECEIVE=§cUm Chatnachrichten versenden zu können, musst du auch welche empfangen!
|
||||||
CHAT_NO_LINKS=§cDu darfst keine Links versenden.
|
CHAT_NO_LINKS=§cDu darfst keine Links versenden.
|
||||||
CHAT_BC_USAGE=§8/§7bc §8[§eNachricht§8]
|
CHAT_BC_USAGE=§8/§7bc §8[§eNachricht§8]
|
||||||
|
CHAT_NO_RECEIVER=§cNiemand empfängt deine Nachricht
|
||||||
|
|
||||||
|
CHAT_SERVERTEAM=§8STC §e{0}§8» §f{2}
|
||||||
|
CHAT_GLOBAL={3}{4}{5}{6}{0}§8» {7}{2}
|
||||||
|
CHAT_DISCORD_GLOBAL=§8Dc {5}{6}{0}§8» {7}{2}
|
||||||
|
CHAT_TEAM=§8TC §e{0}§8» §f{2}
|
||||||
|
CHAT_MSG=§e{0}§8»§e{1} §7{2}
|
||||||
|
|
||||||
#CheckListner
|
#CheckListner
|
||||||
CHECK_UNCHECKED=§7Du hast noch §e{0} §7ungeprüfte Schematic§8(§7s§8)!
|
CHECK_UNCHECKED=§7Du hast noch §e{0} §7ungeprüfte Schematic§8(§7s§8)!
|
||||||
|
@ -19,12 +19,15 @@
|
|||||||
|
|
||||||
package de.steamwar.messages;
|
package de.steamwar.messages;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.Arenaserver;
|
||||||
import de.steamwar.bungeecore.BungeeCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.Subserver;
|
||||||
|
import de.steamwar.bungeecore.bot.listeners.DiscordChatListener;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
@ -39,9 +42,29 @@ import java.util.Date;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public interface ChatSender {
|
public interface ChatSender {
|
||||||
|
|
||||||
|
static Stream<ProxiedPlayer> all() {
|
||||||
|
return ProxyServer.getInstance().getPlayers().stream();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Stream<ChatSender> allReceivers() {
|
||||||
|
return all().map(ChatSender::of);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Stream<ChatSender> globalReceivers() {
|
||||||
|
return all().filter(player -> {
|
||||||
|
Subserver subserver = Subserver.getSubserver(player);
|
||||||
|
return !(subserver instanceof Arenaserver && subserver.getServer() == player.getServer().getInfo());
|
||||||
|
}).map(ChatSender::of);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Stream<ChatSender> serverteamReceivers() {
|
||||||
|
return allReceivers().filter(player -> player.user().getUserGroup().isTeamGroup());
|
||||||
|
}
|
||||||
|
|
||||||
SteamwarUser user();
|
SteamwarUser user();
|
||||||
|
|
||||||
Locale getLocale();
|
Locale getLocale();
|
||||||
@ -64,6 +87,10 @@ public interface ChatSender {
|
|||||||
send(false, ChatMessageType.SYSTEM, null, null, new Message(message, params));
|
send(false, ChatMessageType.SYSTEM, null, null, new Message(message, params));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default void prefixless(String message, Message onHover, ClickEvent onClick, Object... params) {
|
||||||
|
send(false, ChatMessageType.SYSTEM, onHover, onClick, new Message(message, params));
|
||||||
|
}
|
||||||
|
|
||||||
default void send(boolean prefixed, ChatMessageType type, Message onHover, ClickEvent onClick, Message message) {
|
default void send(boolean prefixed, ChatMessageType type, Message onHover, ClickEvent onClick, Message message) {
|
||||||
TextComponent msg = new TextComponent(parse(prefixed, message));
|
TextComponent msg = new TextComponent(parse(prefixed, message));
|
||||||
if(onHover != null)
|
if(onHover != null)
|
||||||
@ -79,7 +106,7 @@ public interface ChatSender {
|
|||||||
String pattern = "";
|
String pattern = "";
|
||||||
if(prefixed)
|
if(prefixed)
|
||||||
pattern = resourceBundle.getObject("PREFIX") + " ";
|
pattern = resourceBundle.getObject("PREFIX") + " ";
|
||||||
pattern += (String)resourceBundle.getObject(message.getMessage());
|
pattern += (String)resourceBundle.getObject(message.getFormat());
|
||||||
|
|
||||||
MessageFormat format = new MessageFormat(pattern, locale);
|
MessageFormat format = new MessageFormat(pattern, locale);
|
||||||
Object[] params = message.getParams();
|
Object[] params = message.getParams();
|
||||||
@ -158,7 +185,7 @@ public interface ChatSender {
|
|||||||
return of(ConsoleCommandSender.getInstance());
|
return of(ConsoleCommandSender.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
static ChatSender discordConsole() {
|
static ChatSender discordChannel(DiscordChatListener channel) {
|
||||||
return new ChatSender() {
|
return new ChatSender() {
|
||||||
@Override
|
@Override
|
||||||
public SteamwarUser user() {
|
public SteamwarUser user() {
|
||||||
@ -178,7 +205,7 @@ public interface ChatSender {
|
|||||||
@Override
|
@Override
|
||||||
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
||||||
try {
|
try {
|
||||||
SteamwarDiscordBot.instance().getIngameChatListener().send("<t:" + (System.currentTimeMillis() / 1000) + "> " + new TextComponent(msg).toPlainText());
|
channel.send("<t:" + (System.currentTimeMillis() / 1000) + "> " + new TextComponent(msg).toPlainText());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not send chat message to discord", e);
|
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not send chat message to discord", e);
|
||||||
}
|
}
|
||||||
@ -206,7 +233,7 @@ public interface ChatSender {
|
|||||||
@Override
|
@Override
|
||||||
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
||||||
try {
|
try {
|
||||||
//TODO SteamwarDiscordBot.instance().getIngameChatListener().send("<t:" + (System.currentTimeMillis() / 1000) + "> " + new TextComponent(msg).toPlainText());
|
message.delete().queue();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not send chat reply to discord user", e);
|
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not send chat reply to discord user", e);
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren