Dieser Commit ist enthalten in:
Commit
7b5359b558
@ -1 +1 @@
|
|||||||
Subproject commit 492894ca8d41ee0bde4dcb9d520db5f7478c50c7
|
Subproject commit c96efa9a50ae8c030f4543768239613d5e72be79
|
@ -24,6 +24,7 @@ import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
|||||||
import de.steamwar.bungeecore.commands.*;
|
import de.steamwar.bungeecore.commands.*;
|
||||||
import de.steamwar.bungeecore.listeners.*;
|
import de.steamwar.bungeecore.listeners.*;
|
||||||
import de.steamwar.bungeecore.listeners.mods.*;
|
import de.steamwar.bungeecore.listeners.mods.*;
|
||||||
|
import de.steamwar.bungeecore.network.BungeeNetworkHandler;
|
||||||
import de.steamwar.bungeecore.network.NetworkReceiver;
|
import de.steamwar.bungeecore.network.NetworkReceiver;
|
||||||
import de.steamwar.bungeecore.sql.*;
|
import de.steamwar.bungeecore.sql.*;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
@ -157,6 +158,7 @@ public class BungeeCore extends Plugin {
|
|||||||
new EventStarter();
|
new EventStarter();
|
||||||
new SessionManager();
|
new SessionManager();
|
||||||
new NetworkReceiver();
|
new NetworkReceiver();
|
||||||
|
BungeeNetworkHandler.register();
|
||||||
new TablistManager();
|
new TablistManager();
|
||||||
new SettingsChangedListener();
|
new SettingsChangedListener();
|
||||||
|
|
||||||
|
@ -25,9 +25,7 @@ import de.steamwar.bungeecore.inventory.SWItem;
|
|||||||
import de.steamwar.bungeecore.inventory.SWListInv;
|
import de.steamwar.bungeecore.inventory.SWListInv;
|
||||||
import de.steamwar.bungeecore.sql.*;
|
import de.steamwar.bungeecore.sql.*;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import io.netty.channel.ConnectTimeoutException;
|
|
||||||
import net.md_5.bungee.BungeeCord;
|
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.ChatColor;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
@ -660,7 +658,7 @@ public class TeamCommand extends BasicCommand {
|
|||||||
Message.send("TEAM_SERVER_SET", player);
|
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
|
// Check if the address is a valid special local or loop back
|
||||||
if (addr.isAnyLocalAddress() || addr.isLoopbackAddress())
|
if (addr.isAnyLocalAddress() || addr.isLoopbackAddress())
|
||||||
return true;
|
return true;
|
||||||
|
@ -20,9 +20,9 @@
|
|||||||
package de.steamwar.bungeecore.network;
|
package de.steamwar.bungeecore.network;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.BungeeCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
|
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;
|
||||||
@ -36,26 +36,21 @@ import java.util.logging.Level;
|
|||||||
public class NetworkReceiver extends BasicListener {
|
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");
|
||||||
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)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public synchronized void onPluginMessage(PluginMessageEvent event) {
|
public void onPluginMessage(PluginMessageEvent event) {
|
||||||
if (blockedTags.contains(event.getTag()) && !allowedAddresses.contains(((InetSocketAddress) event.getSender().getSocketAddress()).getHostString())) {
|
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);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!event.getTag().equalsIgnoreCase("sw:bridge"))
|
if(!event.getTag().equals("sw:bridge"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public class NetworkSender {
|
|||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public static void send(ProxiedPlayer player, NetworkPacket packet) {
|
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) {
|
public static void send(ServerInfo serverInfo, NetworkPacket packet) {
|
||||||
|
36
src/de/steamwar/bungeecore/network/ServerMetaInfo.java
Normale Datei
36
src/de/steamwar/bungeecore/network/ServerMetaInfo.java
Normale Datei
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -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());
|
||||||
|
|
||||||
|
@ -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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren