SteamWar/BungeeCore
Archiviert
13
2

Add schem deadline message to /event #359

Zusammengeführt
Lixfel hat 15 Commits von deadline nach master 2022-06-23 10:02:49 +02:00 zusammengeführt
9 geänderte Dateien mit 53 neuen und 19 gelöschten Zeilen
Nur Änderungen aus Commit 7b5359b558 werden angezeigt - Alle Commits anzeigen

@ -1 +1 @@
Subproject commit 492894ca8d41ee0bde4dcb9d520db5f7478c50c7
Subproject commit c96efa9a50ae8c030f4543768239613d5e72be79

Datei anzeigen

@ -24,6 +24,7 @@ import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
import de.steamwar.bungeecore.commands.*;
import de.steamwar.bungeecore.listeners.*;
import de.steamwar.bungeecore.listeners.mods.*;
import de.steamwar.bungeecore.network.BungeeNetworkHandler;
import de.steamwar.bungeecore.network.NetworkReceiver;
import de.steamwar.bungeecore.sql.*;
import net.md_5.bungee.api.ChatMessageType;
@ -157,6 +158,7 @@ public class BungeeCore extends Plugin {
new EventStarter();
new SessionManager();
new NetworkReceiver();
BungeeNetworkHandler.register();
new TablistManager();
new SettingsChangedListener();

Datei anzeigen

@ -25,9 +25,7 @@ import de.steamwar.bungeecore.inventory.SWItem;
import de.steamwar.bungeecore.inventory.SWListInv;
import de.steamwar.bungeecore.sql.*;
import de.steamwar.messages.ChatSender;
import io.netty.channel.ConnectTimeoutException;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.UserConnection;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
@ -660,7 +658,7 @@ public class TeamCommand extends BasicCommand {
Message.send("TEAM_SERVER_SET", player);
}
private static boolean isLocalhost(InetAddress addr) {
public static boolean isLocalhost(InetAddress addr) {
// Check if the address is a valid special local or loop back
if (addr.isAnyLocalAddress() || addr.isLoopbackAddress())
return true;

Datei anzeigen

@ -20,9 +20,9 @@
package de.steamwar.bungeecore.network;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.commands.TeamCommand;
import de.steamwar.bungeecore.listeners.BasicListener;
import de.steamwar.network.packets.NetworkPacket;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.event.EventHandler;
@ -36,26 +36,21 @@ import java.util.logging.Level;
public class NetworkReceiver extends BasicListener {
private static final List<String> blockedTags = Arrays.asList("bungeecord:main", "BungeeCord", "sw:bridge");
private static final List<String> allowedAddresses = Arrays.asList("localhost", "127.0.0.1", "0.0.0.0");
public static ServerInfo sender;
@EventHandler(priority = EventPriority.HIGHEST)
public synchronized void onPluginMessage(PluginMessageEvent event) {
if (blockedTags.contains(event.getTag()) && !allowedAddresses.contains(((InetSocketAddress) event.getSender().getSocketAddress()).getHostString())) {
public void onPluginMessage(PluginMessageEvent event) {
if (blockedTags.contains(event.getTag()) && !TeamCommand.isLocalhost(((InetSocketAddress) event.getSender().getSocketAddress()).getAddress())) {
BungeeCore.log(Level.SEVERE, ((InetSocketAddress) event.getSender().getSocketAddress()).getHostString() + " tried to send a plugin message with tag " + event.getTag());
event.setCancelled(true);
return;
}
if(!event.getTag().equalsIgnoreCase("sw:bridge"))
if(!event.getTag().equals("sw:bridge"))
return;
event.setCancelled(true);
if(!(event.getSender() instanceof Server))
return;
sender = ((Server) event.getSender()).getInfo();
NetworkPacket.handle(event.getData());
sender = null;
NetworkPacket.handle(new ServerMetaInfo(((Server) event.getSender()).getInfo()), event.getData());
}
}

Datei anzeigen

@ -28,7 +28,7 @@ public class NetworkSender {
@SneakyThrows
public static void send(ProxiedPlayer player, NetworkPacket packet) {
player.sendData("sw:bridge", packet.serialize());
player.getServer().sendData("sw:bridge", packet.serialize());
}
public static void send(ServerInfo serverInfo, NetworkPacket packet) {

Datei anzeigen

@ -0,0 +1,36 @@
/*
* 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.network;
import de.steamwar.network.packets.MetaInfos;
import net.md_5.bungee.api.config.ServerInfo;
public class ServerMetaInfo implements MetaInfos {
private ServerInfo sender;
public ServerMetaInfo(ServerInfo sender) {
this.sender = sender;
}
public ServerInfo getSender() {
return sender;
}
}

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.bungeecore.network.handlers;
import de.steamwar.bungeecore.listeners.TablistManager;
import de.steamwar.bungeecore.network.NetworkReceiver;
import de.steamwar.bungeecore.network.NetworkSender;
import de.steamwar.bungeecore.network.ServerMetaInfo;
import de.steamwar.network.packets.PacketHandler;
import de.steamwar.network.packets.common.FightInfoPacket;
import net.md_5.bungee.api.config.ServerInfo;
@ -45,7 +46,7 @@ public class FightInfoHandler extends PacketHandler {
@Handler
public void handle(FightInfoPacket packet) {
ServerInfo info = NetworkReceiver.sender;
ServerInfo info = ((ServerMetaInfo) packet.getMetaInfos()).getSender();
FightInfoPacket lobbyPacket = packet.withServerName(info.getName());

Datei anzeigen

@ -19,7 +19,7 @@
package de.steamwar.bungeecore.network.handlers;
import de.steamwar.bungeecore.network.NetworkReceiver;
import de.steamwar.bungeecore.network.ServerMetaInfo;
import de.steamwar.network.packets.PacketHandler;
import de.steamwar.network.packets.client.ImALobbyPacket;
@ -27,6 +27,6 @@ public class ImALobbyHandler extends PacketHandler {
@Handler
public void handle(ImALobbyPacket packet) {
FightInfoHandler.addLobby(NetworkReceiver.sender);
FightInfoHandler.addLobby(((ServerMetaInfo) packet.getMetaInfos()).getSender());
}
}

Datei anzeigen

@ -24,11 +24,13 @@ import de.steamwar.bungeecore.inventory.InvCallback;
import de.steamwar.bungeecore.inventory.SWInventory;
import de.steamwar.bungeecore.network.NetworkReceiver;
import de.steamwar.bungeecore.network.NetworkSender;
import de.steamwar.bungeecore.network.ServerMetaInfo;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.network.packets.PacketHandler;
import de.steamwar.network.packets.client.InventoryCallbackPacket;
import de.steamwar.network.packets.server.CloseInventoryPacket;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo;
import java.util.HashMap;
import java.util.Map;
@ -44,7 +46,7 @@ public class InventoryCallbackHandler extends PacketHandler {
if(!inventoryHashMap.containsKey(owner.getId())) {
BungeeCore.send(ProxyServer.getInstance().getPlayer(owner.getUuid()), BungeeCore.CHAT_PREFIX + "§cBitte erneut versuchen. Durch ein Softwareupdate konnte die übliche Aktion nicht durchgeführt werden.");
if(type == InventoryCallbackPacket.CallbackType.CLICK) {
NetworkSender.send(NetworkReceiver.sender, new CloseInventoryPacket(owner.getId()));
NetworkSender.send(((ServerMetaInfo) packet.getMetaInfos()).getSender(), new CloseInventoryPacket(owner.getId()));
}
return;
}