SteamWar/BungeeCore
Archiviert
13
2

Add ServerMetaInfo
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2022-06-14 15:47:11 +02:00
Ursprung 7aadaa2df3
Commit bf4f7c6adf
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.commands.TeamCommand;
import de.steamwar.bungeecore.listeners.BasicListener; import de.steamwar.bungeecore.listeners.BasicListener;
import de.steamwar.network.packets.NetworkPacket; 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.connection.Server;
import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.event.EventHandler; 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"); private static final List<String> blockedTags = Arrays.asList("bungeecord:main", "BungeeCord", "sw:bridge");
public static ServerInfo sender;
@EventHandler(priority = EventPriority.HIGHEST) @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())) { 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()); BungeeCore.log(Level.SEVERE, ((InetSocketAddress) event.getSender().getSocketAddress()).getHostString() + " tried to send a plugin message with tag " + event.getTag());
event.setCancelled(true); event.setCancelled(true);
@ -54,8 +51,6 @@ public class NetworkReceiver extends BasicListener {
if(!(event.getSender() instanceof Server)) if(!(event.getSender() instanceof Server))
return; return;
sender = ((Server) event.getSender()).getInfo(); NetworkPacket.handle(new ServerMetaInfo(((Server) event.getSender()).getInfo()), event.getData());
NetworkPacket.handle(event.getData());
sender = null;
} }
} }

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

Datei anzeigen

@ -19,7 +19,7 @@
package de.steamwar.bungeecore.network.handlers; 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.PacketHandler;
import de.steamwar.network.packets.client.ImALobbyPacket; import de.steamwar.network.packets.client.ImALobbyPacket;
@ -27,6 +27,6 @@ public class ImALobbyHandler extends PacketHandler {
@Handler @Handler
public void handle(ImALobbyPacket packet) { 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.inventory.SWInventory;
import de.steamwar.bungeecore.network.NetworkReceiver; import de.steamwar.bungeecore.network.NetworkReceiver;
import de.steamwar.bungeecore.network.NetworkSender; import de.steamwar.bungeecore.network.NetworkSender;
import de.steamwar.bungeecore.network.ServerMetaInfo;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.PacketHandler;
import de.steamwar.network.packets.client.InventoryCallbackPacket; import de.steamwar.network.packets.client.InventoryCallbackPacket;
import de.steamwar.network.packets.server.CloseInventoryPacket; import de.steamwar.network.packets.server.CloseInventoryPacket;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -44,7 +46,7 @@ public class InventoryCallbackHandler extends PacketHandler {
if(!inventoryHashMap.containsKey(owner.getId())) { 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."); 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) { if(type == InventoryCallbackPacket.CallbackType.CLICK) {
NetworkSender.send(NetworkReceiver.sender, new CloseInventoryPacket(owner.getId())); NetworkSender.send(((ServerMetaInfo) packet.getMetaInfos()).getSender(), new CloseInventoryPacket(owner.getId()));
} }
return; return;
} }