From ac08d7390b9458f316802c1328914400354477a7 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Sat, 15 May 2021 19:29:56 +0200 Subject: [PATCH 1/8] See Security-Breach issue --- src/de/steamwar/bungeecore/commands/BauCommand.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index 590ef93..c090a5b 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -24,6 +24,7 @@ import de.steamwar.bungeecore.inventory.SWInventory; import de.steamwar.bungeecore.inventory.SWItem; import de.steamwar.bungeecore.sql.BauweltMember; import de.steamwar.bungeecore.sql.SteamwarUser; +import java.util.Collection; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.ChatEvent; @@ -220,9 +221,10 @@ public class BauCommand { ProxiedPlayer z = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUuid()); if(z != null){ Message.send("BAU_DELMEMBER_DELETED_TARGET", z, p.getName()); - Subserver server = Subserver.getSubserver(z); - if(server != null && server.getType() == Servertype.BAUSERVER && ((Bauserver)server).getOwner().equals(p.getUniqueId())) + Collection servers = Subserver.getAllServers(z); + if (!servers.isEmpty() && servers.stream().filter(server -> server.getType() == Servertype.BAUSERVER).anyMatch(server -> ((Bauserver) server).getOwner().equals(p.getUniqueId()))) { z.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LOBBY_SERVER)); + } } Message.send("BAU_DELMEMBER_DELETED", p); } From 83bcdd34bf9385da16ee4384bb6abf046e07c2c2 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Tue, 18 May 2021 18:08:25 +0200 Subject: [PATCH 2/8] rework in persistent bungeecore for said issue --- src/de/steamwar/bungeecore/commands/BauCommand.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index c090a5b..8d63132 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -221,8 +221,7 @@ public class BauCommand { ProxiedPlayer z = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUuid()); if(z != null){ Message.send("BAU_DELMEMBER_DELETED_TARGET", z, p.getName()); - Collection servers = Subserver.getAllServers(z); - if (!servers.isEmpty() && servers.stream().filter(server -> server.getType() == Servertype.BAUSERVER).anyMatch(server -> ((Bauserver) server).getOwner().equals(p.getUniqueId()))) { + if (Subserver.getServerList().stream().filter(server -> server.onServer(p) && server.getType() == Servertype.BAUSERVER).anyMatch(server -> ((Bauserver) server).getOwner().equals(p.getUniqueId()))) { z.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LOBBY_SERVER)); } } From d1b901be699b31fafc5a639d37eef981d244c4a7 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Tue, 18 May 2021 18:09:34 +0200 Subject: [PATCH 3/8] codestyle --- src/de/steamwar/bungeecore/commands/BauCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index 8d63132..37ce439 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -221,7 +221,7 @@ public class BauCommand { ProxiedPlayer z = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUuid()); if(z != null){ Message.send("BAU_DELMEMBER_DELETED_TARGET", z, p.getName()); - if (Subserver.getServerList().stream().filter(server -> server.onServer(p) && server.getType() == Servertype.BAUSERVER).anyMatch(server -> ((Bauserver) server).getOwner().equals(p.getUniqueId()))) { + if (Subserver.getServerList().stream().anyMatch(server -> server.onServer(p) && server.getType() == Servertype.BAUSERVER && ((Bauserver) server).getOwner().equals(p.getUniqueId()))) { z.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LOBBY_SERVER)); } } From 41a8ea316ff3749d6e18d6724767fb0e54445cae Mon Sep 17 00:00:00 2001 From: Zeanon Date: Tue, 18 May 2021 18:10:25 +0200 Subject: [PATCH 4/8] me stupid --- src/de/steamwar/bungeecore/commands/BauCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index 37ce439..04b33ff 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -221,7 +221,7 @@ public class BauCommand { ProxiedPlayer z = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUuid()); if(z != null){ Message.send("BAU_DELMEMBER_DELETED_TARGET", z, p.getName()); - if (Subserver.getServerList().stream().anyMatch(server -> server.onServer(p) && server.getType() == Servertype.BAUSERVER && ((Bauserver) server).getOwner().equals(p.getUniqueId()))) { + if (Subserver.getServerList().stream().anyMatch(server -> server.onServer(z) && server.getType() == Servertype.BAUSERVER && ((Bauserver) server).getOwner().equals(p.getUniqueId()))) { z.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LOBBY_SERVER)); } } From fca4f736e8cb04bb4baf5a00d631526f2acad312 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Tue, 18 May 2021 18:11:56 +0200 Subject: [PATCH 5/8] readability --- src/de/steamwar/bungeecore/commands/BauCommand.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index 04b33ff..3c0a364 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -218,11 +218,11 @@ public class BauCommand { } target.remove(); - ProxiedPlayer z = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUuid()); - if(z != null){ - Message.send("BAU_DELMEMBER_DELETED_TARGET", z, p.getName()); - if (Subserver.getServerList().stream().anyMatch(server -> server.onServer(z) && server.getType() == Servertype.BAUSERVER && ((Bauserver) server).getOwner().equals(p.getUniqueId()))) { - z.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LOBBY_SERVER)); + ProxiedPlayer toRemove = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUuid()); + if(toRemove != null){ + Message.send("BAU_DELMEMBER_DELETED_TARGET", toRemove, p.getName()); + if (Subserver.getServerList().stream().anyMatch(server -> server.onServer(toRemove) && server.getType() == Servertype.BAUSERVER && ((Bauserver) server).getOwner().equals(p.getUniqueId()))) { + toRemove.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LOBBY_SERVER)); } } Message.send("BAU_DELMEMBER_DELETED", p); From 9874ab204edceeec1cb4afff4a4a0ad5e97075c2 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Tue, 18 May 2021 19:26:32 +0200 Subject: [PATCH 6/8] No changes on Persistent Bungeecore nescessary --- pom.xml | 1 + src/de/steamwar/bungeecore/commands/BauCommand.java | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dbf2760..859b262 100644 --- a/pom.xml +++ b/pom.xml @@ -16,6 +16,7 @@ + clean verify -U src diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index 3c0a364..2c79a26 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -221,7 +221,8 @@ public class BauCommand { ProxiedPlayer toRemove = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUuid()); if(toRemove != null){ Message.send("BAU_DELMEMBER_DELETED_TARGET", toRemove, p.getName()); - if (Subserver.getServerList().stream().anyMatch(server -> server.onServer(toRemove) && server.getType() == Servertype.BAUSERVER && ((Bauserver) server).getOwner().equals(p.getUniqueId()))) { + Subserver currentServer = Subserver.getSubserver(toRemove.getServer().getInfo()); + if (currentServer.getType() == Servertype.BAUSERVER && ((Bauserver) currentServer).getOwner().equals(p.getUniqueId())) { toRemove.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LOBBY_SERVER)); } } From c0366c4daa0c577c062bb9e5a6bef55ee6bb1884 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Tue, 18 May 2021 19:30:09 +0200 Subject: [PATCH 7/8] optimized imports --- pom.xml | 1 - src/de/steamwar/bungeecore/commands/BauCommand.java | 1 - 2 files changed, 2 deletions(-) diff --git a/pom.xml b/pom.xml index 859b262..dbf2760 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,6 @@ - clean verify -U src diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index 2c79a26..b736870 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -24,7 +24,6 @@ import de.steamwar.bungeecore.inventory.SWInventory; import de.steamwar.bungeecore.inventory.SWItem; import de.steamwar.bungeecore.sql.BauweltMember; import de.steamwar.bungeecore.sql.SteamwarUser; -import java.util.Collection; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.ChatEvent; From d1cb167039cee7d9a39e2f72c5f5b0a632a56117 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Tue, 18 May 2021 19:31:49 +0200 Subject: [PATCH 8/8] now currentServer != null --- src/de/steamwar/bungeecore/commands/BauCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index b736870..43944d7 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -221,7 +221,7 @@ public class BauCommand { if(toRemove != null){ Message.send("BAU_DELMEMBER_DELETED_TARGET", toRemove, p.getName()); Subserver currentServer = Subserver.getSubserver(toRemove.getServer().getInfo()); - if (currentServer.getType() == Servertype.BAUSERVER && ((Bauserver) currentServer).getOwner().equals(p.getUniqueId())) { + if (currentServer != null && currentServer.getType() == Servertype.BAUSERVER && ((Bauserver) currentServer).getOwner().equals(p.getUniqueId())) { toRemove.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LOBBY_SERVER)); } }