Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
336d4f6a3c
Commit
0bf5a65850
@ -124,6 +124,7 @@ public class BungeeCore extends Plugin {
|
|||||||
new PlaytimeCommand();
|
new PlaytimeCommand();
|
||||||
new ArenaCommand();
|
new ArenaCommand();
|
||||||
new RankCommand();
|
new RankCommand();
|
||||||
|
new LocalCommand();
|
||||||
|
|
||||||
// Punishment Commands:
|
// Punishment Commands:
|
||||||
new PunishmentCommand("ban", Punishment.PunishmentType.Ban);
|
new PunishmentCommand("ban", Punishment.PunishmentType.Ban);
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.bungeecore;
|
package de.steamwar.bungeecore;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
||||||
|
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.ProxyServer;
|
||||||
@ -28,16 +29,14 @@ 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;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.*;
|
import java.util.Date;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
public class Message {
|
public class Message {
|
||||||
|
|
||||||
private static final Map<String, ResourceBundle> bundles = new HashMap<>();
|
|
||||||
|
|
||||||
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)));
|
||||||
}
|
}
|
||||||
@ -58,29 +57,10 @@ public class Message {
|
|||||||
return sender instanceof ProxiedPlayer ? ((ProxiedPlayer)sender).getLocale() : Locale.getDefault();
|
return sender instanceof ProxiedPlayer ? ((ProxiedPlayer)sender).getLocale() : Locale.getDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String BASE_PATH = "/" + "de.steamwar.messages.BungeeCore".replace('.', '/');
|
|
||||||
|
|
||||||
private static ResourceBundle getResourceBundle(String locale, ResourceBundle parent) {
|
|
||||||
return bundles.computeIfAbsent(locale, locale1 -> {
|
|
||||||
InputStream inputStream = Message.class.getResourceAsStream(BASE_PATH + ("".equals(locale) ? "" : "_" + locale) + ".properties");
|
|
||||||
if(inputStream == null)
|
|
||||||
return parent;
|
|
||||||
try {
|
|
||||||
return new SteamwarResourceBundle(inputStream, parent);
|
|
||||||
} catch (IOException e) {
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ResourceBundle getResourceBundle(Locale locale) {
|
|
||||||
return getResourceBundle(locale.toString(), getResourceBundle(locale.getLanguage(), getResourceBundle( "", (ResourceBundle) null)));
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
||||||
ResourceBundle resourceBundle = getResourceBundle(locale);
|
ResourceBundle resourceBundle = SteamwarResourceBundle.getResourceBundle(locale);
|
||||||
String pattern = "";
|
String pattern = "";
|
||||||
if(prefixed)
|
if(prefixed)
|
||||||
pattern = resourceBundle.getObject("PREFIX") + " ";
|
pattern = resourceBundle.getObject("PREFIX") + " ";
|
||||||
@ -122,7 +102,7 @@ public class Message {
|
|||||||
send(message, false, sender, ChatMessageType.SYSTEM, onHover, onClick, params);
|
send(message, false, sender, ChatMessageType.SYSTEM, onHover, onClick, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void send(String message, boolean prefixed, CommandSender sender, ChatMessageType type, String onHover, ClickEvent onClick, Object... params){
|
private static void send(String message, boolean prefixed, CommandSender sender, ChatMessageType type, String onHover, ClickEvent onClick, Object... params){
|
||||||
if(type == ChatMessageType.CHAT && sender instanceof ProxiedPlayer && ((ProxiedPlayer)sender).getChatMode() != ProxiedPlayer.ChatMode.SHOWN)
|
if(type == ChatMessageType.CHAT && sender instanceof ProxiedPlayer && ((ProxiedPlayer)sender).getChatMode() != ProxiedPlayer.ChatMode.SHOWN)
|
||||||
return;
|
return;
|
||||||
TextComponent msg = parseToComponent(message, prefixed, sender, params);
|
TextComponent msg = parseToComponent(message, prefixed, sender, params);
|
||||||
@ -189,10 +169,4 @@ public class Message {
|
|||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SteamwarResourceBundle extends PropertyResourceBundle {
|
|
||||||
public SteamwarResourceBundle(InputStream stream, ResourceBundle parent) throws IOException {
|
|
||||||
super(stream);
|
|
||||||
setParent(parent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -24,7 +24,7 @@ import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
|||||||
import de.steamwar.bungeecore.listeners.ChatListener;
|
import de.steamwar.bungeecore.listeners.ChatListener;
|
||||||
import de.steamwar.bungeecore.sql.Punishment;
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.bungeecore.sql.UserGroup;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
import net.dv8tion.jda.api.MessageBuilder;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.dv8tion.jda.api.entities.TextChannel;
|
import net.dv8tion.jda.api.entities.TextChannel;
|
||||||
@ -43,19 +43,10 @@ public class IngameChatListener extends BasicDiscordListener {
|
|||||||
}
|
}
|
||||||
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) {
|
if (steamwarUser == null || event.getMessage().getContentRaw().length() > 250 || steamwarUser.isPunished(Punishment.PunishmentType.Ban)) {
|
||||||
event.getMessage().delete().queue();
|
event.getMessage().delete().queue();
|
||||||
} else {
|
} else {
|
||||||
String s = event.getMessage().getContentDisplay();
|
ChatListener.sendChat(ChatSender.of(event.getMessage(), steamwarUser), ChatListener.globalReceivers(), "CHAT_DISCORD_GLOBAL", event.getMessage().getContentDisplay().replaceAll("§", "&").replace('\n', ' '));
|
||||||
if (steamwarUser.getUserGroup() == UserGroup.Member && (s.contains("http") || s.contains("www"))) {
|
|
||||||
event.getMessage().delete().queue();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (steamwarUser.isPunished(Punishment.PunishmentType.Mute) || steamwarUser.isPunished(Punishment.PunishmentType.Ban)) {
|
|
||||||
event.getMessage().delete().queue();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ChatListener.discordChat(steamwarUser, event.getMessage().getContentDisplay().replaceAll("§[a-f0-9]", "").replace('\n', ' '));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,12 +19,9 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.Arenaserver;
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.Servertype;
|
|
||||||
import de.steamwar.bungeecore.Subserver;
|
import de.steamwar.bungeecore.Subserver;
|
||||||
import de.steamwar.bungeecore.SubserverSystem;
|
|
||||||
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.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
@ -42,23 +39,12 @@ public class ArenaCommand extends BasicCommand {
|
|||||||
return;
|
return;
|
||||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||||
|
|
||||||
SteamwarUser steamwarUser = SteamwarUser.get(player);
|
|
||||||
if (steamwarUser.isPunishedWithMessage(player, Punishment.PunishmentType.NoFightServer)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ServerInfo server = ProxyServer.getInstance().getServerInfo(String.join(" ", args));
|
ServerInfo server = ProxyServer.getInstance().getServerInfo(String.join(" ", args));
|
||||||
if(server == null) {
|
if(server == null || !(Subserver.getSubserver(server) instanceof Arenaserver)) {
|
||||||
Message.send("ARENA_NOT_FOUND", player);
|
Message.send("ARENA_NOT_FOUND", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Subserver subserver = Subserver.getSubserver(server);
|
TpCommand.teleport(player, server);
|
||||||
if(subserver == null || subserver.getType() != Servertype.ARENA) {
|
|
||||||
Message.send("ARENA_NOT_FOUND", player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SubserverSystem.sendPlayer(subserver, player);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import de.steamwar.bungeecore.inventory.SWInventory;
|
|||||||
import de.steamwar.bungeecore.inventory.SWItem;
|
import de.steamwar.bungeecore.inventory.SWItem;
|
||||||
import de.steamwar.bungeecore.sql.BauweltMember;
|
import de.steamwar.bungeecore.sql.BauweltMember;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
|
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.ProxyServer;
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
@ -78,7 +79,7 @@ public class BauCommand extends BasicCommand {
|
|||||||
testarena(p, args);
|
testarena(p, args);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
HelpCommand.sendBauHelp(p);
|
HelpCommand.sendBauHelp(ChatSender.of(p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -130,7 +131,7 @@ public class BauCommand extends BasicCommand {
|
|||||||
() -> new ServerStarter().build18(worldOwner.getUuid()).send(p).start(),
|
() -> new ServerStarter().build18(worldOwner.getUuid()).send(p).start(),
|
||||||
() -> new ServerStarter().build15(worldOwner.getUuid()).send(p).start(),
|
() -> new ServerStarter().build15(worldOwner.getUuid()).send(p).start(),
|
||||||
() -> new ServerStarter().build12(worldOwner.getUuid()).send(p).start(),
|
() -> new ServerStarter().build12(worldOwner.getUuid()).send(p).start(),
|
||||||
() -> HelpCommand.sendBauHelp(p));
|
() -> HelpCommand.sendBauHelp(ChatSender.of(p)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void versionSelector(ProxiedPlayer p, String[] args, int pos, Runnable run18, Runnable run15, Runnable run12, Runnable runElse) {
|
private static void versionSelector(ProxiedPlayer p, String[] args, int pos, Runnable run18, Runnable run15, Runnable run12, Runnable runElse) {
|
||||||
@ -233,7 +234,7 @@ public class BauCommand extends BasicCommand {
|
|||||||
() -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS18_PATH + user.getId())),
|
() -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS18_PATH + user.getId())),
|
||||||
() -> deleteConfirmation(p, () -> deleteWorld(p, BungeeCore.USERWORLDS15 + user.getId())),
|
() -> deleteConfirmation(p, () -> deleteWorld(p, BungeeCore.USERWORLDS15 + user.getId())),
|
||||||
() -> deleteConfirmation(p, () -> deleteWorld(p, BungeeCore.WORLD_FOLDER + p.getUniqueId().toString())),
|
() -> deleteConfirmation(p, () -> deleteWorld(p, BungeeCore.WORLD_FOLDER + p.getUniqueId().toString())),
|
||||||
() -> HelpCommand.sendBauHelp(p));
|
() -> HelpCommand.sendBauHelp(ChatSender.of(p)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void deleteConfirmation(ProxiedPlayer p, Runnable worldDeletion) {
|
private static void deleteConfirmation(ProxiedPlayer p, Runnable worldDeletion) {
|
||||||
|
@ -20,10 +20,9 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
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.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
public class HelpCommand extends BasicCommand {
|
public class HelpCommand extends BasicCommand {
|
||||||
|
|
||||||
@ -32,32 +31,29 @@ public class HelpCommand extends BasicCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender s, String[] args) {
|
||||||
|
ChatSender sender = ChatSender.of(s);
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
Message.send("HELP_LOBBY", true, sender, ChatMessageType.SYSTEM, Message.parse("HELP_LOBBY_HOVER", sender), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/l"));
|
printPage(sender, ClickEvent.Action.RUN_COMMAND,
|
||||||
Message.send("HELP_BAU", true, sender, ChatMessageType.SYSTEM, Message.parse("HELP_BAU_HOVER", sender), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/bau"));
|
"HELP_LOBBY", "/l",
|
||||||
Message.send("HELP_BAUSERVER", true, sender, ChatMessageType.SYSTEM, Message.parse("HELP_BAUSERVER_HOVER", sender), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/help bau"));
|
"HELP_BAU", "/bau",
|
||||||
Message.send("HELP_FIGHT", true, sender, ChatMessageType.SYSTEM, Message.parse("HELP_FIGHT_HOVER", sender), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/fight"));
|
"HELP_BAUSERVER", "/help bau",
|
||||||
Message.send("HELP_CHALLENGE", true, sender, ChatMessageType.SYSTEM, Message.parse("HELP_CHALLENGE_HOVER", sender), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/challenge"));
|
"HELP_FIGHT", "/fight",
|
||||||
Message.send("HELP_HISTORIC", true, sender, ChatMessageType.SYSTEM, Message.parse("HELP_HISTORIC_HOVER", sender), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/historic"));
|
"HELP_CHALLENGE", "/challenge",
|
||||||
Message.send("HELP_TEAM", true, sender, ChatMessageType.SYSTEM, Message.parse("HELP_TEAM_HOVER", sender), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team"));
|
"HELP_HISTORIC", "/historic",
|
||||||
Message.send("HELP_JOIN", true, sender, ChatMessageType.SYSTEM, Message.parse("HELP_JOIN_HOVER", sender), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join"));
|
"HELP_TEAM", "/team",
|
||||||
Message.send("HELP_LOCAL", true, sender, ChatMessageType.SYSTEM, Message.parse("HELP_LOCAL_HOVER", sender), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/local"));
|
"HELP_JOIN", "/join",
|
||||||
return;
|
"HELP_LOCAL", "/local");
|
||||||
|
}else if (args[0].equalsIgnoreCase("bauserver")) {
|
||||||
|
sendBauHelp(sender);
|
||||||
|
}else if (args[0].equalsIgnoreCase("bau")) {
|
||||||
|
bauHelpGroup(sender, args);
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("bauserver")) {
|
|
||||||
sendBauHelp((ProxiedPlayer) sender);
|
|
||||||
}
|
|
||||||
if (args[0].equalsIgnoreCase("bau")) {
|
|
||||||
bauHelpGroup((ProxiedPlayer) sender, args);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
private static void bauHelpGroup(ChatSender sender, String[] args) {
|
||||||
|
|
||||||
private static void bauHelpGroup(ProxiedPlayer p, String[] args) {
|
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
sendBauHelpGroup(p);
|
sendBauHelpGroup(sender);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,89 +61,63 @@ public class HelpCommand extends BasicCommand {
|
|||||||
case "admin":
|
case "admin":
|
||||||
case "owner":
|
case "owner":
|
||||||
case "bauwelt":
|
case "bauwelt":
|
||||||
sendBauHelpAdmin(p);
|
sender.system("HELP_BAU_GROUP_ADMIN_TITLE");
|
||||||
|
sendBauHelp(sender);
|
||||||
return;
|
return;
|
||||||
case "world":
|
case "world":
|
||||||
sendBauHelpWorld(p);
|
printPage(sender, "HELP_BAU_GROUP_WORLD_TITLE", "HELP_TNT", "HELP_FIRE", "HELP_FREEZE", "HELP_TPSLIMIT", "HELP_PROTECT", "HELP_RESET");
|
||||||
return;
|
return;
|
||||||
case "player":
|
case "player":
|
||||||
sendBauHelpPlayer(p);
|
printPage(sender, "HELP_BAU_GROUP_PLAYER_TITLE", "HELP_SPEED", "HELP_NV", "HELP_WV", "HELP_DEBUGSTICK", "HELP_TRACE", "HELP_LOADER");
|
||||||
return;
|
return;
|
||||||
case "worldedit":
|
case "worldedit":
|
||||||
case "we":
|
case "we":
|
||||||
case "world-edit":
|
case "world-edit":
|
||||||
case "edit":
|
case "edit":
|
||||||
sendBauHelpWorldEdit(p);
|
printPage(sender, "HELP_BAU_GROUP_WE_TITLE", "HELP_WE_POS1", "HELP_WE_POS2", "HELP_WE_COPY", "HELP_WE_PASTE", "HELP_WE_FLOPY", "HELP_WE_FLOPYP", "HELP_WE_ROTATE_90", "HELP_WE_ROTATE_180", "HELP_WE_ROTATE_N90");
|
||||||
return;
|
return;
|
||||||
case "other":
|
case "other":
|
||||||
sendBauHelpOther(p);
|
printPage(sender, "HELP_BAU_GROUP_OTHER_TITLE", "HELP_TESTBLOCK", "HELP_SKULL", "HELP_BAUINFO");
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
sendBauHelpGroup(p);
|
sendBauHelpGroup(sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void sendBauHelpGroup(ProxiedPlayer p) {
|
private static void sendBauHelpGroup(ChatSender sender) {
|
||||||
Message.send("HELP_BAU_GROUP_ADMIN", true, p, ChatMessageType.SYSTEM, Message.parse("HELP_BAU_GROUP_ADMIN_HOVER", p), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/help bau admin"));
|
printPage(sender, ClickEvent.Action.RUN_COMMAND,
|
||||||
Message.send("HELP_BAU_GROUP_WORLD", true, p, ChatMessageType.SYSTEM, Message.parse("HELP_BAU_GROUP_WORLD_HOVER", p), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/help bau world"));
|
"HELP_BAU_GROUP_ADMIN", "/help bau admin",
|
||||||
Message.send("HELP_BAU_GROUP_PLAYER", true, p, ChatMessageType.SYSTEM, Message.parse("HELP_BAU_GROUP_PLAYER_HOVER", p), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/help bau player"));
|
"HELP_BAU_GROUP_WORLD", "/help bau world",
|
||||||
Message.send("HELP_BAU_GROUP_WE", true, p, ChatMessageType.SYSTEM, Message.parse("HELP_BAU_GROUP_WE_HOVER", p), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/help bau we"));
|
"HELP_BAU_GROUP_PLAYER", "/help bau player",
|
||||||
Message.send("HELP_BAU_GROUP_OTHER", true, p, ChatMessageType.SYSTEM, Message.parse("HELP_BAU_GROUP_OTHER_HOVER", p), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/help bau other"));
|
"HELP_BAU_GROUP_WE", "/help bau we",
|
||||||
|
"HELP_BAU_GROUP_OTHER", "/help bau other");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sendBauHelp(ProxiedPlayer p) {
|
static void sendBauHelp(ChatSender sender) {
|
||||||
Message.send("HELP_BAU_TP", true, p, ChatMessageType.SYSTEM, Message.parse("HELP_BAU_TP_HOVER", p), new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/bau tp "));
|
printPage(sender, ClickEvent.Action.SUGGEST_COMMAND,
|
||||||
Message.send("HELP_BAU_ADDMEMBER", true, p, ChatMessageType.SYSTEM, Message.parse("HELP_BAU_ADDMEMBER_HOVER", p), new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/bau addmember "));
|
"HELP_BAU_TP", "/bau tp ",
|
||||||
Message.send("HELP_BAU_DELMEMBER", true, p, ChatMessageType.SYSTEM, Message.parse("HELP_BAU_DELMEMBER_HOVER", p), new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/bau delmember "));
|
"HELP_BAU_ADDMEMBER", "/bau addmember ",
|
||||||
Message.send("HELP_BAU_TOGGLEWE", true, p, ChatMessageType.SYSTEM, Message.parse("HELP_BAU_TOGGLEWE_HOVER", p), new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/bau togglewe "));
|
"HELP_BAU_DELMEMBER", "/bau delmember ",
|
||||||
Message.send("HELP_BAU_TOGGLEWORLD", true, p, ChatMessageType.SYSTEM, Message.parse("HELP_BAU_TOGGLEWORLD_HOVER", p), new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/bau toggleworld "));
|
"HELP_BAU_TOGGLEWE", "/bau togglewe ",
|
||||||
Message.send("HELP_BAU_DELETE", true, p, ChatMessageType.SYSTEM, Message.parse("HELP_BAU_DELETE_HOVER", p), new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/bau delete "));
|
"HELP_BAU_TOGGLEWORLD", "/bau toggleworld ",
|
||||||
Message.send("HELP_BAU_TESTARENA", true, p, ChatMessageType.SYSTEM, Message.parse("HELP_BAU_TESTARENA_HOVER", p), new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/bau testarena "));
|
"HELP_BAU_DELETE", "/bau delete ",
|
||||||
|
"HELP_BAU_TESTARENA", "/bau testarena ");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sendBauHelpWorld(ProxiedPlayer p) {
|
private static void printPage(ChatSender sender, ClickEvent.Action action, String... args) {
|
||||||
Message.send("HELP_BAU_GROUP_WORLD_TITLE", p);
|
for(int i = 0; i < args.length; i += 2) {
|
||||||
Message.sendPrefixless("HELP_TNT", p);
|
String message = args[i];
|
||||||
Message.sendPrefixless("HELP_FIRE", p);
|
String hoverMessage = message + "_HOVER";
|
||||||
Message.sendPrefixless("HELP_FREEZE", p);
|
String command = args[i+1];
|
||||||
Message.sendPrefixless("HELP_TPSLIMIT", p);
|
|
||||||
Message.sendPrefixless("HELP_PROTECT", p);
|
sender.system(message, new Message(hoverMessage), new ClickEvent(action, command));
|
||||||
Message.sendPrefixless("HELP_RESET", p);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sendBauHelpPlayer(ProxiedPlayer p) {
|
private static void printPage(ChatSender sender, String title, String... messages) {
|
||||||
Message.sendPrefixless("HELP_BAU_GROUP_PLAYER_TITLE", p);
|
sender.system(title);
|
||||||
Message.sendPrefixless("HELP_SPEED", p);
|
for (String message : messages) {
|
||||||
Message.sendPrefixless("HELP_NV", p);
|
sender.prefixless(message);
|
||||||
Message.sendPrefixless("HELP_WV", p);
|
|
||||||
Message.sendPrefixless("HELP_DEBUGSTICK", p);
|
|
||||||
Message.sendPrefixless("HELP_TRACE", p);
|
|
||||||
Message.sendPrefixless("HELP_LOADER", p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sendBauHelpAdmin(ProxiedPlayer p) {
|
|
||||||
Message.send("HELP_BAU_GROUP_ADMIN_TITLE", p);
|
|
||||||
sendBauHelp(p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sendBauHelpWorldEdit(ProxiedPlayer p) {
|
|
||||||
Message.sendPrefixless("HELP_BAU_GROUP_WE_TITLE", p);
|
|
||||||
Message.sendPrefixless("HELP_WE_POS1", p);
|
|
||||||
Message.sendPrefixless("HELP_WE_POS2", p);
|
|
||||||
Message.sendPrefixless("HELP_WE_COPY", p);
|
|
||||||
Message.sendPrefixless("HELP_WE_PASTE", p);
|
|
||||||
Message.sendPrefixless("HELP_WE_FLOPY", p);
|
|
||||||
Message.sendPrefixless("HELP_WE_FLOPYP", p);
|
|
||||||
Message.sendPrefixless("HELP_WE_ROTATE_90", p);
|
|
||||||
Message.sendPrefixless("HELP_WE_ROTATE_180", p);
|
|
||||||
Message.sendPrefixless("HELP_WE_ROTATE_N90", p);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sendBauHelpOther(ProxiedPlayer p) {
|
|
||||||
Message.sendPrefixless("HELP_BAU_GROUP_OTHER_TITLE", p);
|
|
||||||
Message.sendPrefixless("HELP_TESTBLOCK", p);
|
|
||||||
Message.sendPrefixless("HELP_SKULL", p);
|
|
||||||
Message.sendPrefixless("HELP_BAUINFO", p);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
39
src/de/steamwar/bungeecore/commands/LocalCommand.java
Normale Datei
39
src/de/steamwar/bungeecore/commands/LocalCommand.java
Normale Datei
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2022 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.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.listeners.ChatListener;
|
||||||
|
import net.md_5.bungee.api.CommandSender;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
public class LocalCommand extends BasicCommand {
|
||||||
|
|
||||||
|
public LocalCommand() {
|
||||||
|
super("local", null, "bc", "bauchat");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, String[] args) {
|
||||||
|
if(!(sender instanceof ProxiedPlayer))
|
||||||
|
return;
|
||||||
|
|
||||||
|
ChatListener.localChat((ProxiedPlayer) sender, String.join(" ", args));
|
||||||
|
}
|
||||||
|
}
|
@ -69,7 +69,7 @@ public class ServerTeamchatCommand extends BasicCommand {
|
|||||||
for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
|
for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
|
||||||
if ((target.hasPermission("bungeecore.teamchat"))
|
if ((target.hasPermission("bungeecore.teamchat"))
|
||||||
&& target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){
|
&& target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){
|
||||||
Message.sendPrefixless("STC_FORMAT", target, sender.getUserName(), ChatListener.parseAtMessage(message, "§r", target));
|
Message.sendPrefixless("STC_FORMAT", target, sender.getUserName(), ChatListener.highlightOwnMarks(message, "§r", target));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ public class ServerTeamchatCommand extends BasicCommand {
|
|||||||
for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
|
for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
|
||||||
if ((target.hasPermission("bungeecore.teamchat"))
|
if ((target.hasPermission("bungeecore.teamchat"))
|
||||||
&& target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){
|
&& target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){
|
||||||
Message.sendPrefixless("STC_FORMAT", target, sender.getName(), ChatListener.parseAtMessage(message, "§r", target));
|
Message.sendPrefixless("STC_FORMAT", target, sender.getName(), ChatListener.highlightOwnMarks(message, "§r", target));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ public class TeamchatCommand extends BasicCommand {
|
|||||||
SteamwarUser targetuser = SteamwarUser.get(target.getUniqueId());
|
SteamwarUser targetuser = SteamwarUser.get(target.getUniqueId());
|
||||||
if (targetuser.getTeam() == user.getTeam()
|
if (targetuser.getTeam() == user.getTeam()
|
||||||
&& target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){
|
&& target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){
|
||||||
Message.sendPrefixless("TC_FORMAT", target, player.getName(), ChatListener.parseAtMessage(msg, "§f", target));
|
Message.sendPrefixless("TC_FORMAT", target, player.getName(), ChatListener.highlightOwnMarks(msg, "§f", target));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,59 +25,91 @@ 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.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.ChatEvent;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class TpCommand extends BasicCommand {
|
public class TpCommand extends BasicCommand {
|
||||||
|
|
||||||
public static void onTp(ChatEvent e, String[] command){
|
|
||||||
if(!(e.getSender() instanceof ProxiedPlayer))
|
|
||||||
return;
|
|
||||||
if(onTp((ProxiedPlayer) e.getSender(), Arrays.copyOfRange(command, 1, command.length)))
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TpCommand(){
|
public TpCommand(){
|
||||||
super("join", null);
|
super("join", null, "tp", "teleport");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!(sender instanceof ProxiedPlayer))
|
if(!(sender instanceof ProxiedPlayer))
|
||||||
return;
|
return;
|
||||||
|
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||||
|
|
||||||
if(!onTp((ProxiedPlayer) sender, args))
|
|
||||||
Message.send("TP_NOT_FOUND", sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
|
|
||||||
if(args.length == 1){
|
|
||||||
return allPlayers(args[0]);
|
|
||||||
}
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean onTp(ProxiedPlayer player, String[] args){
|
|
||||||
if(args.length == 0){
|
if(args.length == 0){
|
||||||
if(Event.get() == null)
|
if(Event.get() == null)
|
||||||
Message.send("TP_USAGE", player);
|
Message.send("TP_USAGE", player);
|
||||||
else
|
else
|
||||||
Message.send("TP_USAGE_EVENT", player);
|
Message.send("TP_USAGE_EVENT", player);
|
||||||
return true;
|
return;
|
||||||
}else if(CheckCommand.isChecking(player)){
|
|
||||||
Message.send("CHECK_CHECKING", player);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ServerInfo server = getTarget(player, args[0]);
|
||||||
|
|
||||||
|
//Give control of teleport command to server
|
||||||
|
if(server == null) {
|
||||||
|
player.chat("/teleport " + String.join(" ", args));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
teleport(player, server);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
|
||||||
|
if(args.length > 0)
|
||||||
|
return allPlayers(args[args.length - 1]);
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void teleport(ProxiedPlayer player, ServerInfo server){
|
||||||
|
if(CheckCommand.isChecking(player)){
|
||||||
|
Message.send("CHECK_CHECKING", player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String serverPerm = BungeeCore.serverPermissions.get(server.getName());
|
||||||
|
Subserver subserver = Subserver.getSubserver(server);
|
||||||
|
|
||||||
|
if (subserver instanceof Arenaserver) {
|
||||||
|
if (!SteamwarUser.get(player).isPunishedWithMessage(player, Punishment.PunishmentType.NoFightServer))
|
||||||
|
SubserverSystem.sendPlayer(subserver, player);
|
||||||
|
|
||||||
|
} else if(subserver instanceof Bauserver) {
|
||||||
|
Bauserver bauserver = (Bauserver) subserver;
|
||||||
|
if (bauserver.getOwner().equals(player.getUniqueId()) || BauweltMember.getBauMember(bauserver.getOwner(), player.getUniqueId()) != null) {
|
||||||
|
SubserverSystem.sendPlayer(subserver, player);
|
||||||
|
} else {
|
||||||
|
SubserverSystem.sendDeniedMessage(player, bauserver.getOwner());
|
||||||
|
Message.send("JOIN_PLAYER_BLOCK", player);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (serverPerm != null && !player.hasPermission(serverPerm)) {
|
||||||
|
Message.send("JOIN_PLAYER_BLOCK", player);
|
||||||
|
|
||||||
|
} else if (serverPerm == null && !player.getGroups().contains("team")) {
|
||||||
|
Message.send("JOIN_PLAYER_BLOCK", player);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
player.connect(server);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ServerInfo getTarget(ProxiedPlayer player, String arg) {
|
||||||
|
ServerInfo server = null;
|
||||||
|
|
||||||
//Get target player server
|
//Get target player server
|
||||||
ServerInfo server = getTargetPlayer(args[0]);
|
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(arg);
|
||||||
|
if(target != null)
|
||||||
|
server = target.getServer().getInfo();
|
||||||
|
|
||||||
//Get target team event arena
|
//Get target team event arena
|
||||||
if(server == null){
|
if(server == null){
|
||||||
Team team = Team.get(args[0]);
|
Team team = Team.get(arg);
|
||||||
if(team != null){
|
if(team != null){
|
||||||
Subserver eventArena = EventStarter.getEventServer().get(team.getTeamId());
|
Subserver eventArena = EventStarter.getEventServer().get(team.getTeamId());
|
||||||
if(eventArena != null && Subserver.getServerList().contains(eventArena))
|
if(eventArena != null && Subserver.getServerList().contains(eventArena))
|
||||||
@ -85,63 +117,9 @@ public class TpCommand extends BasicCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Give control of teleport command to server
|
if(server == player.getServer().getInfo())
|
||||||
if(server == null || server == player.getServer().getInfo())
|
server = null;
|
||||||
return false;
|
|
||||||
|
|
||||||
// Check if player is allowed to join fights
|
return server;
|
||||||
Subserver subserver = Subserver.getSubserver(server);
|
|
||||||
if (subserver != null && subserver.getType() == Servertype.ARENA) {
|
|
||||||
SteamwarUser steamwarUser = SteamwarUser.get(player);
|
|
||||||
if (steamwarUser.isPunishedWithMessage(player, Punishment.PunishmentType.NoFightServer)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
teleport(player, server);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ServerInfo getTargetPlayer(String playerName){
|
|
||||||
SteamwarUser user = SteamwarUser.get(playerName);
|
|
||||||
if(user == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(user.getUuid());
|
|
||||||
if(target == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
Subserver subserver = Subserver.getSubserver(target);
|
|
||||||
if(subserver != null)
|
|
||||||
return subserver.getServer();
|
|
||||||
|
|
||||||
return target.getServer().getInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void teleport(ProxiedPlayer player, ServerInfo server){
|
|
||||||
String serverPerm = BungeeCore.serverPermissions.get(server.getName());
|
|
||||||
Subserver subserver = Subserver.getSubserver(server);
|
|
||||||
|
|
||||||
if(subserver != null) {
|
|
||||||
Servertype type = subserver.getType();
|
|
||||||
if (type == Servertype.ARENA) {
|
|
||||||
SubserverSystem.sendPlayer(subserver, player);
|
|
||||||
} else if (type == Servertype.BAUSERVER) {
|
|
||||||
Bauserver bauserver = (Bauserver) subserver;
|
|
||||||
if (bauserver.getOwner().equals(player.getUniqueId()) ||
|
|
||||||
BauweltMember.getBauMember(bauserver.getOwner(), player.getUniqueId()) != null) {
|
|
||||||
SubserverSystem.sendPlayer(subserver, player);
|
|
||||||
} else {
|
|
||||||
SubserverSystem.sendDeniedMessage(player, bauserver.getOwner());
|
|
||||||
Message.send("JOIN_PLAYER_BLOCK", player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else if(serverPerm != null && !player.hasPermission(serverPerm)){
|
|
||||||
Message.send("JOIN_PLAYER_BLOCK", player);
|
|
||||||
}else if(serverPerm == null && !player.getGroups().contains("team")) {
|
|
||||||
Message.send("JOIN_PLAYER_BLOCK", player);
|
|
||||||
}else{
|
|
||||||
player.connect(server);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
This file is a part of the SteamWar software.
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
Copyright (C) 2022 SteamWar.de-Serverteam
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -21,254 +21,194 @@ package de.steamwar.bungeecore.listeners;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.*;
|
import de.steamwar.bungeecore.*;
|
||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
import de.steamwar.bungeecore.commands.TpCommand;
|
|
||||||
import de.steamwar.bungeecore.comms.packets.PingPacket;
|
import de.steamwar.bungeecore.comms.packets.PingPacket;
|
||||||
import de.steamwar.bungeecore.sql.*;
|
import de.steamwar.bungeecore.sql.*;
|
||||||
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.api.*;
|
import net.md_5.bungee.api.*;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.ChatEvent;
|
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.sql.Timestamp;
|
import java.util.*;
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class ChatListener extends BasicListener {
|
public class ChatListener extends BasicListener {
|
||||||
|
|
||||||
private static final Title LIXFEL = ProxyServer.getInstance().createTitle().fadeIn(5).fadeOut(20).stay(30).title(TextComponent.fromLegacyText("§4§lLIXFEL"));
|
private static final Set<Integer> coloredTeams = new HashSet<>();
|
||||||
private static final Title YOYONOW = ProxyServer.getInstance().createTitle().fadeIn(5).fadeOut(20).stay(30).title(TextComponent.fromLegacyText("§4§lYOYONOW"));
|
static {
|
||||||
|
coloredTeams.add(12);
|
||||||
|
coloredTeams.add(54);
|
||||||
|
coloredTeams.add(285);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onChatEvent(ChatEvent e){
|
public void onChatEvent(ChatEvent e) {
|
||||||
if(e.getMessage().contains("jndi:ldap")) {
|
if(!(e.getSender() instanceof ProxiedPlayer))
|
||||||
|
return;
|
||||||
|
ProxiedPlayer player = (ProxiedPlayer) e.getSender();
|
||||||
|
String message = e.getMessage();
|
||||||
|
|
||||||
|
if (message.contains("jndi:ldap")) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
SteamwarUser.get(((ProxiedPlayer) e.getSender()).getUniqueId()).punishPerma(Punishment.PunishmentType.Ban, "Versuchte Exploit-Ausnutzung", 0);
|
SteamwarUser.get(player.getUniqueId()).punishPerma(Punishment.PunishmentType.Ban, "Versuchte Exploit-Ausnutzung", 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sanitize7(e);
|
message = sanitize7(message);
|
||||||
if(e.getMessage().startsWith("/"))
|
|
||||||
onCommand(e);
|
|
||||||
else if(e.getMessage().startsWith("+"))
|
|
||||||
onPlusMessage(e);
|
|
||||||
else
|
|
||||||
onChat(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
if (message.startsWith("/")) {
|
||||||
* Replaces 7(7)command to /(/)command.
|
if(filteredCommand((CommandSender) e.getSender(), message))
|
||||||
* */
|
|
||||||
private void sanitize7(ChatEvent e){
|
|
||||||
String begin = e.getMessage().split(" ", 2)[0];
|
|
||||||
if(begin.startsWith("7") && begin.substring(1).matches("[A-Za-z]+")){
|
|
||||||
e.setMessage("/" + e.getMessage().substring(1));
|
|
||||||
}else if(begin.startsWith("77") && begin.substring(2).matches("[A-Za-z]+")){
|
|
||||||
e.setMessage("//" + e.getMessage().substring(2));
|
|
||||||
}else if(begin.startsWith("7/") && begin.substring(2).matches("[A-Za-z]+")){
|
|
||||||
e.setMessage("//" + e.getMessage().substring(2));
|
|
||||||
}else if(begin.startsWith("/7") && begin.substring(2).matches("[A-Za-z]+")){
|
|
||||||
e.setMessage("//" + e.getMessage().substring(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onCommand(ChatEvent e){
|
|
||||||
String [] command = e.getMessage().split(" ");
|
|
||||||
if(command[0].contains(":")){
|
|
||||||
if(e.getSender() instanceof ProxiedPlayer)
|
|
||||||
Message.send("UNKNOWN_COMMAND", (CommandSender) e.getSender());
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(command[0].toLowerCase()){
|
|
||||||
case "/bc":
|
|
||||||
case "/bauchat":
|
|
||||||
case "/local":
|
|
||||||
localChat(e, command);
|
|
||||||
break;
|
|
||||||
case "/tp":
|
|
||||||
TpCommand.onTp(e, command);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
//do nothing, let the normal command handlers proceed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void lixfelAlert(ProxiedPlayer sender) {
|
|
||||||
LIXFEL.send(sender);
|
|
||||||
Message.send("CHAT_LIXFEL_ACTION_BAR", sender, ChatMessageType.ACTION_BAR);
|
|
||||||
TaskScheduler scheduler = ProxyServer.getInstance().getScheduler();
|
|
||||||
scheduler.schedule(BungeeCore.get(), () -> Message.sendPrefixless("MSG_FORMAT", sender, "Lixfel", sender.getDisplayName(), Message.parse("CHAT_LIXFEL_1", sender)), 3, TimeUnit.SECONDS);
|
|
||||||
scheduler.schedule(BungeeCore.get(), () -> Message.sendPrefixless("MSG_FORMAT", sender, "Lixfel", sender.getDisplayName(), Message.parse("CHAT_LIXFEL_2", sender)), 6, TimeUnit.SECONDS);
|
|
||||||
scheduler.schedule(BungeeCore.get(), () -> Message.sendPrefixless("MSG_FORMAT", sender, "Lixfel", sender.getDisplayName(), Message.parse("CHAT_LIXFEL_3", sender)), 11, TimeUnit.SECONDS);
|
|
||||||
scheduler.schedule(BungeeCore.get(), () -> Message.sendPrefixless("MSG_FORMAT", sender, "Lixfel", sender.getDisplayName(), Message.parse("CHAT_LIXFEL_4", sender)), 12, TimeUnit.SECONDS);
|
|
||||||
scheduler.schedule(BungeeCore.get(), () -> Message.sendPrefixless("MSG_FORMAT", sender, "Lixfel", sender.getDisplayName(), Message.parse("CHAT_LIXFEL_5", sender)), 15, TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void yoyonowAlert(ProxiedPlayer sender) {
|
|
||||||
YOYONOW.send(sender);
|
|
||||||
Message.send("CHAT_LIXFEL_ACTION_BAR", sender, ChatMessageType.ACTION_BAR);
|
|
||||||
TaskScheduler scheduler = ProxyServer.getInstance().getScheduler();
|
|
||||||
scheduler.schedule(BungeeCore.get(), () -> Message.sendPrefixless("MSG_FORMAT", sender, "YoyoNow", sender.getDisplayName(), Message.parse("CHAT_YOYONOW_1", sender)), 3, TimeUnit.SECONDS);
|
|
||||||
scheduler.schedule(BungeeCore.get(), () -> Message.sendPrefixless("MSG_FORMAT", sender, "YoyoNow", sender.getDisplayName(), Message.parse("CHAT_YOYONOW_2", sender)), 6, TimeUnit.SECONDS);
|
|
||||||
scheduler.schedule(BungeeCore.get(), () -> Message.sendPrefixless("MSG_FORMAT", sender, "YoyoNow", sender.getDisplayName(), Message.parse("CHAT_YOYONOW_3", sender)), 11, TimeUnit.SECONDS);
|
|
||||||
scheduler.schedule(BungeeCore.get(), () -> Message.sendPrefixless("MSG_FORMAT", sender, "YoyoNow", sender.getDisplayName(), Message.parse("CHAT_YOYONOW_4", sender)), 12, TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onPlusMessage(ChatEvent e) {
|
|
||||||
ProxiedPlayer p = (ProxiedPlayer) e.getSender();
|
|
||||||
Subserver subserver = Subserver.getSubserver(p);
|
|
||||||
if(subserver instanceof Bauserver) {
|
|
||||||
String[] smolArgs = e.getMessage().substring(1).split(" ");
|
|
||||||
String[] args = new String[smolArgs.length + 1];
|
|
||||||
args[0] = "";
|
|
||||||
System.arraycopy(smolArgs, 0, args, 1, smolArgs.length);
|
|
||||||
localChat(e, args);
|
|
||||||
} else {
|
} else {
|
||||||
onChat(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onChat(ChatEvent e){
|
|
||||||
if(e.getSender() instanceof ProxiedPlayer){
|
|
||||||
ProxiedPlayer sender = (ProxiedPlayer) e.getSender();
|
|
||||||
|
|
||||||
if (e.getMessage().contains("LIXFEL"))
|
|
||||||
lixfelAlert(sender);
|
|
||||||
if (e.getMessage().contains("YOYONOW"))
|
|
||||||
yoyonowAlert(sender);
|
|
||||||
|
|
||||||
if(sender.getChatMode() != ProxiedPlayer.ChatMode.SHOWN){
|
|
||||||
Message.send("CHAT_RECEIVE", sender);
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
|
||||||
|
Subserver subserver = Subserver.getSubserver(player);
|
||||||
|
if(subserver instanceof Arenaserver && subserver.getServer() == player.getServer().getInfo()) {
|
||||||
|
localChat(player, message);
|
||||||
|
} else if (message.startsWith("+")) {
|
||||||
|
localChat(player, message.substring(1));
|
||||||
|
} else {
|
||||||
|
String finalMessage = message;
|
||||||
|
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> sendChat(ChatSender.of(player), globalReceivers(), "CHAT_GLOBAL", finalMessage));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Stream<ProxiedPlayer> globalReceivers() {
|
||||||
|
//TODO: Filter arena players
|
||||||
|
return ProxyServer.getInstance().getPlayers().stream();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendChat(ChatSender sender, Stream<ProxiedPlayer> receivers, String format, String message) {
|
||||||
|
if(!sender.chatShown()) {
|
||||||
|
sender.system("CHAT_RECEIVE");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SteamwarUser user = SteamwarUser.get(sender);
|
SteamwarUser user = sender.user();
|
||||||
if (user.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute)) {
|
UserGroup group = user.getUserGroup();
|
||||||
e.setCancelled(true);
|
if(!group.isTeamGroup() && (message.contains("http:") || message.contains("https:") || message.contains("www."))){
|
||||||
|
sender.system("CHAT_NO_LINKS");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!sender.hasPermission(ConnectionListener.TEAM_GROUP) && (e.getMessage().contains("http:") || e.getMessage().contains("https:") || e.getMessage().contains("www."))){
|
if (user.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute))
|
||||||
Message.send("CHAT_NO_LINKS", sender);
|
|
||||||
e.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Subserver subserver = Subserver.getSubserver(sender);
|
|
||||||
if(subserver != null && subserver.getType() == Servertype.ARENA && subserver.getServer() == sender.getServer().getInfo())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
e.setCancelled(true);
|
if(group != UserGroup.Member || coloredTeams.contains(user.getTeam()))
|
||||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> publicChat(user, sender, e.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void discordChat(SteamwarUser user, String message){
|
|
||||||
String name = "§r" + user.getUserName() + "§r";
|
|
||||||
if (user.getUserGroup() != UserGroup.Member) {
|
|
||||||
name = user.getUserGroup().getColorCode() + user.getUserGroup().getChatPrefix() + " " + user.getUserName() + "§r";
|
|
||||||
}
|
|
||||||
String chatcolor = user.getUserGroup().getChatColorCode();
|
|
||||||
|
|
||||||
if(user.getUserGroup() != UserGroup.Member || user.getTeam() == 12 || user.getTeam() == 285 || user.getTeam() == 54)
|
|
||||||
message = ChatColor.translateAlternateColorCodes('&', message);
|
message = ChatColor.translateAlternateColorCodes('&', message);
|
||||||
|
|
||||||
String msg = name + "§7»" + chatcolor + " " + message;
|
if (message.contains("LIXFEL"))
|
||||||
if(user.getTeam() != 0){
|
specialAlert(sender, "Lixfel", "CHAT_LIXFEL_", 3, 6, 11, 12, 15);
|
||||||
Team team = Team.get(user.getTeam());
|
if (message.contains("YOYONOW"))
|
||||||
msg = "§" + team.getTeamColor() + team.getTeamKuerzel() + " §r" + msg;
|
specialAlert(sender, "YoyoNow", "CHAT_YOYONOW_", 3, 6, 11, 12);
|
||||||
}
|
//TODO: Extract filters and specials for local chat
|
||||||
msg = "§7Discord §r" + msg;
|
|
||||||
|
|
||||||
for(ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
|
String emblem = UserElo.getEmblem(user);
|
||||||
Subserver targetServer = Subserver.getSubserver(target);
|
String team = user.getTeam() == 0 ? "" : Team.get(user.getTeam()).getTeamColor() + Team.get(user.getTeam()).getTeamKuerzel() + " ";
|
||||||
if(!(targetServer == null || targetServer.getType() != Servertype.ARENA || targetServer.getServer() != target.getServer().getInfo())) continue;
|
String finalMessage = message;
|
||||||
|
|
||||||
BungeeCore.send(target, ChatMessageType.CHAT, parseAtMessage(msg, chatcolor, target));
|
//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}
|
||||||
|
|
||||||
private void publicChat(SteamwarUser user, ProxiedPlayer sender, String message) {
|
AtomicBoolean noReceiver = new AtomicBoolean(true);
|
||||||
String name = UserElo.getEmblem(user) + sender.getDisplayName();
|
receivers.map(ChatSender::of).filter(ChatSender::chatShown).forEach(player -> {
|
||||||
String chatcolor = user.getUserGroup().getChatColorCode();
|
noReceiver.set(false);
|
||||||
|
chatToReciever(player, user, format, finalMessage);
|
||||||
|
});
|
||||||
|
|
||||||
if(user.getUserGroup() != UserGroup.Member || user.getTeam() == 12 || user.getTeam() == 285 || user.getTeam() == 54)
|
chatToReciever(ChatSender.console(), user, format, message); //TODO only global/DCglobal
|
||||||
message = ChatColor.translateAlternateColorCodes('&', message);
|
|
||||||
|
|
||||||
String msg = name + "§7»" + chatcolor + " " + message;
|
|
||||||
if(user.getTeam() != 0){
|
|
||||||
Team team = Team.get(user.getTeam());
|
|
||||||
msg = "§" + team.getTeamColor() + team.getTeamKuerzel() + " §r" + msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if(format.equals("CHAT_GLOBAL")) {
|
||||||
if (SteamwarDiscordBot.instance() != null) {
|
if (SteamwarDiscordBot.instance() != null) {
|
||||||
try {
|
chatToReciever(ChatSender.discordConsole(), user, format, message);
|
||||||
SteamwarDiscordBot.instance().getIngameChatListener().send("<t:" + (System.currentTimeMillis() / 1000) + "> " + msg.replaceAll("§[a-f0-9r]", ""));
|
|
||||||
} catch (Exception e) {
|
|
||||||
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not send chat message to discord", e);
|
|
||||||
}
|
}
|
||||||
|
} else if(noReceiver.get()) {
|
||||||
|
//TODO nobody hears you message
|
||||||
}
|
}
|
||||||
for(ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
|
|
||||||
Subserver targetServer = Subserver.getSubserver(target);
|
|
||||||
if(!(targetServer == null || targetServer.getType() != Servertype.ARENA || targetServer.getServer() != target.getServer().getInfo())) continue;
|
|
||||||
|
|
||||||
BungeeCore.send(target, ChatMessageType.CHAT, parseAtMessage(msg, chatcolor, target));
|
|
||||||
}
|
|
||||||
BungeeCore.log(sender.getServer().getInfo(), msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void localChat(ChatEvent e, String [] command){
|
private static void chatToReciever(ChatSender receiver, SteamwarUser sender, String format, String message) {
|
||||||
ProxiedPlayer sender = (ProxiedPlayer) e.getSender();
|
UserGroup group = sender.getUserGroup();
|
||||||
BungeeCore.log(sender, e.getMessage());
|
receiver.chat(new Message(format,
|
||||||
if(command.length == 1){
|
sender,
|
||||||
Message.send("CHAT_BC_USAGE", sender, command[0].substring(1));
|
receiver,
|
||||||
e.setCancelled(true);
|
highlightOwnMarks(message, group.getChatColorCode(), receiver),
|
||||||
|
sender.getTeam() == 0 ? "" : Team.get(sender.getTeam()).getTeamColor() + Team.get(sender.getTeam()).getTeamKuerzel() + " ",
|
||||||
|
UserElo.getEmblem(sender),
|
||||||
|
group.getColorCode(),
|
||||||
|
group.getChatPrefix(),
|
||||||
|
group.getChatColorCode()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void localChat(ProxiedPlayer player, String message) {
|
||||||
|
if(message.length() == 0){
|
||||||
|
Message.send("CHAT_BC_USAGE", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SteamwarUser user = SteamwarUser.get(sender);
|
message = sanitize7(message);
|
||||||
if (user.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute)) {
|
|
||||||
e.setCancelled(true);
|
if(ChatListener.filteredCommand(player, message))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
player.chat(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(command[1].startsWith("/") && command[1].contains(":")){
|
private static String sanitize7(String message) {
|
||||||
Message.send("UNKNOWN_COMMAND", sender);
|
String begin = message.split(" ", 2)[0];
|
||||||
e.setCancelled(true);
|
if(begin.startsWith("7") && begin.substring(1).matches("[A-Za-z]+")){
|
||||||
return;
|
message = "/" + message.substring(1);
|
||||||
|
}else if((begin.startsWith("77") || begin.startsWith("7/") || begin.startsWith("/7")) && begin.substring(2).matches("[A-Za-z]+")){
|
||||||
|
message = "//" + message.substring(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
e.setMessage(e.getMessage().substring(command[0].length() + 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String parseAtMessage(String message, String returnColor, ProxiedPlayer player) {
|
|
||||||
if(!message.contains("@")) {
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
private static boolean filteredCommand(CommandSender sender, String message) {
|
||||||
for (String curr : message.split(" ")) {
|
String command = message.split(" ", 2)[0];
|
||||||
if(curr.toLowerCase().startsWith("@" + player.getName().toLowerCase())) {
|
if(command.startsWith("/") && command.contains(":")) {
|
||||||
new PingPacket(SteamwarUser.get(player).getId()).send(player);
|
Message.send("UNKNOWN_COMMAND", sender);
|
||||||
builder.append("§e@")
|
return true;
|
||||||
.append(player.getName())
|
}
|
||||||
.append(returnColor)
|
return false;
|
||||||
.append(curr.substring(player.getName().length() + 1))
|
}
|
||||||
.append(" ");
|
|
||||||
}else {
|
private static void specialAlert(ChatSender sender, String name, String baseMessage, int... delay) {
|
||||||
builder.append(curr)
|
sender.system("CHAT_LIXFEL_ACTION_BAR");
|
||||||
.append(" ");
|
TaskScheduler scheduler = ProxyServer.getInstance().getScheduler();
|
||||||
|
for(int i = 0; i < delay.length; i++) {
|
||||||
|
int finalI = i;
|
||||||
|
scheduler.schedule(BungeeCore.get(), () -> sender.prefixless("MSG_FORMAT", name, sender.user(), new Message(baseMessage + (finalI+1))), delay[i], TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return builder.toString();
|
|
||||||
|
public static String highlightOwnMarks(String message, String returnColor, ChatSender player) {
|
||||||
|
if(!message.contains("@"))
|
||||||
|
return message;
|
||||||
|
|
||||||
|
String mark = "@" + player.user().getUserName();
|
||||||
|
return Arrays.stream(message.split(" ")).map(cur -> {
|
||||||
|
if(cur.equalsIgnoreCase(mark)) {
|
||||||
|
new PingPacket(player.user().getId()).send(player.user().getPlayer());
|
||||||
|
return "§e" + cur + returnColor;
|
||||||
|
}
|
||||||
|
return cur;
|
||||||
|
}).collect(Collectors.joining(" "));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -258,6 +258,10 @@ public class SteamwarUser {
|
|||||||
return team;
|
return team;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ProxiedPlayer getPlayer() {
|
||||||
|
return ProxyServer.getInstance().getPlayer(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
public Punishment getPunishment(Punishment.PunishmentType type) {
|
public Punishment getPunishment(Punishment.PunishmentType type) {
|
||||||
return punishments.getOrDefault(type, null);
|
return punishments.getOrDefault(type, null);
|
||||||
}
|
}
|
||||||
|
@ -471,7 +471,6 @@ TEAM_COLOR_TITLE=Farbe wählen
|
|||||||
#TpCommand
|
#TpCommand
|
||||||
TP_USAGE=§8/§7tp §8[§eSpieler§8]
|
TP_USAGE=§8/§7tp §8[§eSpieler§8]
|
||||||
TP_USAGE_EVENT=§8/§7tp §8[§eSpieler §7oder §eTeam§8]
|
TP_USAGE_EVENT=§8/§7tp §8[§eSpieler §7oder §eTeam§8]
|
||||||
TP_NOT_FOUND=§cKonnte das angegebene Ziel nicht finden.
|
|
||||||
|
|
||||||
#UnignoreCommand
|
#UnignoreCommand
|
||||||
UNIGNORE_USAGE=§8/§7unignore §8[§eSpieler§8]
|
UNIGNORE_USAGE=§8/§7unignore §8[§eSpieler§8]
|
||||||
@ -492,7 +491,7 @@ WEB_EMAIL_SEND=§aEine E-Mail zum Setzen des Passworts wurde gesendet.
|
|||||||
CHAT_LIXFEL_ACTION_BAR=§4§lTechnische Probleme?
|
CHAT_LIXFEL_ACTION_BAR=§4§lTechnische Probleme?
|
||||||
CHAT_LIXFEL_1=Du hast mich gerufen!
|
CHAT_LIXFEL_1=Du hast mich gerufen!
|
||||||
CHAT_LIXFEL_2=Leider bin ich nur ein Mensch und höre nicht alles.
|
CHAT_LIXFEL_2=Leider bin ich nur ein Mensch und höre nicht alles.
|
||||||
CHAT_LIXFEL_3=Daher bitte ich dich, das Problem bzw. den Fehler im Forum in der Kategorie §eFehler melden §cmit einer ausreichenden Beschreibung zu hinterlegen.
|
CHAT_LIXFEL_3=Daher bitte ich dich, das Problem bzw. den Fehler im Forum in der Kategorie §eFehler melden §7mit einer ausreichenden Beschreibung zu hinterlegen.
|
||||||
CHAT_LIXFEL_4=Vielen Dank.
|
CHAT_LIXFEL_4=Vielen Dank.
|
||||||
CHAT_LIXFEL_5=Ich wünsche dir noch weiterhin ein reibungsloses Spielerlebnis.
|
CHAT_LIXFEL_5=Ich wünsche dir noch weiterhin ein reibungsloses Spielerlebnis.
|
||||||
CHAT_YOYONOW_1=Du hast mich gerufen!
|
CHAT_YOYONOW_1=Du hast mich gerufen!
|
||||||
@ -501,7 +500,7 @@ CHAT_YOYONOW_3=Vielen Dank.
|
|||||||
CHAT_YOYONOW_4=Ich wünsche dir noch weiterhin ein reibungsloses Spielerlebnis.
|
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/§e{0} §8[§7Nachricht§8]
|
CHAT_BC_USAGE=§8/§7bc §8[§eNachricht§8]
|
||||||
|
|
||||||
#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)!
|
||||||
|
216
src/de/steamwar/messages/ChatSender.java
Normale Datei
216
src/de/steamwar/messages/ChatSender.java
Normale Datei
@ -0,0 +1,216 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2022 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.messages;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
|
import de.steamwar.bungeecore.Message;
|
||||||
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
import net.md_5.bungee.api.CommandSender;
|
||||||
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
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.hover.content.Text;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
import net.md_5.bungee.command.ConsoleCommandSender;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public interface ChatSender {
|
||||||
|
|
||||||
|
SteamwarUser user();
|
||||||
|
|
||||||
|
Locale getLocale();
|
||||||
|
boolean chatShown();
|
||||||
|
void sendMessage(ChatMessageType type, BaseComponent... msg);
|
||||||
|
|
||||||
|
default void chat(Message message) {
|
||||||
|
send(false, ChatMessageType.CHAT, null, null, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
default void system(String message, Object... params) {
|
||||||
|
send(true, ChatMessageType.SYSTEM, null, null, new Message(message, params));
|
||||||
|
}
|
||||||
|
|
||||||
|
default void system(String message, Message onHover, ClickEvent onClick, Object... params) {
|
||||||
|
send(true, ChatMessageType.SYSTEM, onHover, onClick, new Message(message, params));
|
||||||
|
}
|
||||||
|
|
||||||
|
default void prefixless(String message, Object... params) {
|
||||||
|
send(false, ChatMessageType.SYSTEM, null, null, new Message(message, params));
|
||||||
|
}
|
||||||
|
|
||||||
|
default void send(boolean prefixed, ChatMessageType type, Message onHover, ClickEvent onClick, Message message) {
|
||||||
|
TextComponent msg = new TextComponent(parse(prefixed, message));
|
||||||
|
if(onHover != null)
|
||||||
|
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(parse(false, onHover))));
|
||||||
|
if(onClick != null)
|
||||||
|
msg.setClickEvent(onClick);
|
||||||
|
sendMessage(type, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
default BaseComponent[] parse(boolean prefixed, Message message) {
|
||||||
|
Locale locale = getLocale();
|
||||||
|
ResourceBundle resourceBundle = SteamwarResourceBundle.getResourceBundle(locale);
|
||||||
|
String pattern = "";
|
||||||
|
if(prefixed)
|
||||||
|
pattern = resourceBundle.getObject("PREFIX") + " ";
|
||||||
|
pattern += (String)resourceBundle.getObject(message.getMessage());
|
||||||
|
|
||||||
|
MessageFormat format = new MessageFormat(pattern, locale);
|
||||||
|
Object[] params = message.getParams();
|
||||||
|
for (int i = 0; i < params.length; i++) {
|
||||||
|
if(params[i] instanceof Message) {
|
||||||
|
params[i] = parse(false, (Message) params[i]);
|
||||||
|
} else if(params[i] instanceof Date) {
|
||||||
|
params[i] = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale).format((Date) params[i]);
|
||||||
|
} else if(params[i] instanceof SteamwarUser) {
|
||||||
|
params[i] = ((SteamwarUser) params[i]).getUserName();
|
||||||
|
} else if(params[i] instanceof ProxiedPlayer) {
|
||||||
|
params[i] = ((ProxiedPlayer) params[i]).getName();
|
||||||
|
} else if(params[i] instanceof ChatSender) {
|
||||||
|
params[i] = ((ChatSender) params[i]).user().getUserName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TextComponent.fromLegacyText(format.format(params));
|
||||||
|
}
|
||||||
|
|
||||||
|
static ChatSender of(ProxiedPlayer player) {
|
||||||
|
return new ChatSender() {
|
||||||
|
@Override
|
||||||
|
public SteamwarUser user() {
|
||||||
|
return SteamwarUser.get(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Locale getLocale() {
|
||||||
|
Locale locale = player.getLocale();
|
||||||
|
if(locale == null)
|
||||||
|
locale = Locale.getDefault();
|
||||||
|
return locale;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean chatShown() {
|
||||||
|
return player.getChatMode() == ProxiedPlayer.ChatMode.SHOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
||||||
|
player.sendMessage(type, msg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static ChatSender of(CommandSender sender) {
|
||||||
|
if(sender instanceof ProxiedPlayer)
|
||||||
|
return of((ProxiedPlayer) sender);
|
||||||
|
|
||||||
|
//Console
|
||||||
|
return new ChatSender() {
|
||||||
|
@Override
|
||||||
|
public SteamwarUser user() {
|
||||||
|
return SteamwarUser.get(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Locale getLocale() {
|
||||||
|
return Locale.getDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean chatShown() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
||||||
|
sender.sendMessage(msg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static ChatSender console() {
|
||||||
|
return of(ConsoleCommandSender.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
static ChatSender discordConsole() {
|
||||||
|
return new ChatSender() {
|
||||||
|
@Override
|
||||||
|
public SteamwarUser user() {
|
||||||
|
return SteamwarUser.get(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Locale getLocale() {
|
||||||
|
return Locale.getDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean chatShown() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
||||||
|
try {
|
||||||
|
SteamwarDiscordBot.instance().getIngameChatListener().send("<t:" + (System.currentTimeMillis() / 1000) + "> " + new TextComponent(msg).toPlainText());
|
||||||
|
} catch (Exception e) {
|
||||||
|
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not send chat message to discord", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static ChatSender of(net.dv8tion.jda.api.entities.Message message, SteamwarUser user) {
|
||||||
|
return new ChatSender() {
|
||||||
|
@Override
|
||||||
|
public SteamwarUser user() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Locale getLocale() {
|
||||||
|
return Locale.getDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean chatShown() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
||||||
|
try {
|
||||||
|
//TODO SteamwarDiscordBot.instance().getIngameChatListener().send("<t:" + (System.currentTimeMillis() / 1000) + "> " + new TextComponent(msg).toPlainText());
|
||||||
|
} catch (Exception e) {
|
||||||
|
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not send chat reply to discord user", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
55
src/de/steamwar/messages/SteamwarResourceBundle.java
Normale Datei
55
src/de/steamwar/messages/SteamwarResourceBundle.java
Normale Datei
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2022 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.messages;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.Message;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class SteamwarResourceBundle extends PropertyResourceBundle {
|
||||||
|
|
||||||
|
private static final String BASE_PATH = "/" + "de.steamwar.messages.BungeeCore".replace('.', '/');
|
||||||
|
|
||||||
|
private static final Map<String, ResourceBundle> bundles = new HashMap<>();
|
||||||
|
|
||||||
|
public static ResourceBundle getResourceBundle(Locale locale) {
|
||||||
|
return getResourceBundle(locale.toString(), getResourceBundle(locale.getLanguage(), getResourceBundle( "", null)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ResourceBundle getResourceBundle(String locale, ResourceBundle parent) {
|
||||||
|
return bundles.computeIfAbsent(locale, locale1 -> {
|
||||||
|
InputStream inputStream = Message.class.getResourceAsStream(BASE_PATH + ("".equals(locale) ? "" : "_" + locale) + ".properties");
|
||||||
|
if(inputStream == null)
|
||||||
|
return parent;
|
||||||
|
try {
|
||||||
|
return new SteamwarResourceBundle(inputStream, parent);
|
||||||
|
} catch (IOException e) {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private SteamwarResourceBundle(InputStream stream, ResourceBundle parent) throws IOException {
|
||||||
|
super(stream);
|
||||||
|
setParent(parent);
|
||||||
|
}
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren