SteamWar/BungeeCore
Archiviert
13
2

Add ServerMetaInfo #369

Zusammengeführt
Lixfel hat 1 Commits von AddMetaInfo nach master 2022-06-14 16:13:59 +02:00 zusammengeführt
6 geänderte Dateien mit 46 neuen und 12 gelöschten Zeilen

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

Datei anzeigen

@ -23,7 +23,6 @@ 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;
@ -38,10 +37,8 @@ public class NetworkReceiver extends BasicListener {
private static final List<String> blockedTags = Arrays.asList("bungeecord:main", "BungeeCord", "sw:bridge");
public static ServerInfo sender;
@EventHandler(priority = EventPriority.HIGHEST)
public synchronized void onPluginMessage(PluginMessageEvent event) {
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);
@ -54,8 +51,6 @@ public class NetworkReceiver extends BasicListener {
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

@ -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;
}