SteamWar/BungeeCore
Archiviert
13
2

Merge pull request 'Remove bau passthrough' (#210) from noBauPassthrough into master

Reviewed-on: #210
Dieser Commit ist enthalten in:
Lixfel 2021-09-07 07:43:32 +02:00
Commit 1852b667b8
5 geänderte Dateien mit 93 neuen und 57 gelöschten Zeilen

Datei anzeigen

@ -130,6 +130,7 @@ public class BungeeCore extends Plugin {
new VerifyCommand(); new VerifyCommand();
if(!EVENT_MODE){ if(!EVENT_MODE){
new BauCommand();
new WebregisterCommand(); new WebregisterCommand();
new FightCommand(); new FightCommand();
new ChallengeCommand(); new ChallengeCommand();

Datei anzeigen

@ -20,38 +20,38 @@
package de.steamwar.bungeecore.commands; package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.*;
import de.steamwar.bungeecore.comms.packets.BaumemberUpdatePacket;
import de.steamwar.bungeecore.inventory.SWInventory; import de.steamwar.bungeecore.inventory.SWInventory;
import de.steamwar.bungeecore.inventory.SWItem; import de.steamwar.bungeecore.inventory.SWItem;
import de.steamwar.bungeecore.sql.BauweltMember; import de.steamwar.bungeecore.sql.BauweltMember;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.ChatEvent;
public class BauCommand { public class BauCommand extends BasicCommand {
private BauCommand(){} public BauCommand(){
super("bau", null, "b", "gs");
}
public static void onBau(ChatEvent e, String[] command){ @Override
if(BungeeCore.EVENT_MODE) public void execute(CommandSender sender, String[] args) {
if(!(sender instanceof ProxiedPlayer))
return; return;
ProxiedPlayer p = (ProxiedPlayer) e.getSender(); ProxiedPlayer p = (ProxiedPlayer) sender;
Subserver server = Subserver.getSubserver(p);
Bauserver bau = (server != null && server.getType() == Servertype.BAUSERVER) ? (Bauserver)server : null;
boolean ownBau = bau != null && bau.getOwner().equals(p.getUniqueId());
e.setCancelled(true);
BungeeCore.log(p, e.getMessage());
if(command.length == 1){ if(args.length == 0){
if(bau15(p, command, 1)) if(bau15(p, args, 0))
SubserverSystem.sendToBau15(p, p.getUniqueId()); SubserverSystem.sendToBau15(p, p.getUniqueId());
else else
SubserverSystem.sendToBauServer(p, p.getUniqueId()); SubserverSystem.sendToBauServer(p, p.getUniqueId());
return; return;
} }
switch(command[1].toLowerCase()){ switch(args[0].toLowerCase()){
case "ws": case "ws":
case "warship": case "warship":
case "12": case "12":
@ -72,52 +72,44 @@ public class BauCommand {
SubserverSystem.sendToBau15paper(p, p.getUniqueId()); SubserverSystem.sendToBau15paper(p, p.getUniqueId());
break; break;
case "addmember": case "addmember":
addmember(p, command); addmember(p, args);
break; break;
case "tp": case "tp":
case "teleport": case "teleport":
teleport(p, command); teleport(p, args);
break; break;
case "info": case "info":
if (bau != null) { p.chat("/bauinfo");
e.setCancelled(false);
}
break; break;
case "togglewe": case "togglewe":
if(ownBau && command.length > 2) togglewe(p, args);
e.setCancelled(false);
else
togglewe(p, command);
break; break;
case "toggleworld": case "toggleworld":
if(ownBau && command.length > 2) toggleworld(p, args);
e.setCancelled(false);
else
toggleworld(p, command);
break; break;
case "delmember": case "delmember":
delmember(p, command); delmember(p, args);
break; break;
case "resetall": case "resetall":
case "delete": case "delete":
delete(p, command); delete(p, args);
break; break;
case "testarena": case "testarena":
case "test": case "test":
testarena(p, command); testarena(p, args);
break; break;
default: default:
HelpCommand.sendBauHelp(p); HelpCommand.sendBauHelp(p);
} }
} }
private static void addmember(ProxiedPlayer p, String[] command){ private static void addmember(ProxiedPlayer p, String[] args){
if (command.length == 2) { if (args.length == 1) {
Message.send("BAU_ADDMEMBER_USAGE", p); Message.send("BAU_ADDMEMBER_USAGE", p);
return; return;
} }
SteamwarUser target = SteamwarUser.get(command[2]); SteamwarUser target = SteamwarUser.get(args[1]);
if (target == null) { if (target == null) {
Message.send("UNKNOWN_PLAYER", p); Message.send("UNKNOWN_PLAYER", p);
return; return;
@ -137,13 +129,13 @@ public class BauCommand {
Message.send("BAU_ADDMEMBER_ADDED_TARGET", z, p.getName()); Message.send("BAU_ADDMEMBER_ADDED_TARGET", z, p.getName());
} }
private static void teleport(ProxiedPlayer p, String[] command){ private static void teleport(ProxiedPlayer p, String[] args){
if (command.length == 2) { if (args.length == 1) {
Message.send("BAU_TP_USAGE", p); Message.send("BAU_TP_USAGE", p);
return; return;
} }
SteamwarUser worldOwner = SteamwarUser.get(command[2]); SteamwarUser worldOwner = SteamwarUser.get(args[1]);
if (worldOwner == null) { if (worldOwner == null) {
Message.send("UNKNOWN_PLAYER", p); Message.send("UNKNOWN_PLAYER", p);
return; return;
@ -153,7 +145,7 @@ public class BauCommand {
return; return;
} }
if(bau15(p, command, 3)) if(bau15(p, args, 2))
SubserverSystem.sendToBau15(p, worldOwner.getUuid()); SubserverSystem.sendToBau15(p, worldOwner.getUuid());
else else
SubserverSystem.sendToBauServer(p, worldOwner.getUuid()); SubserverSystem.sendToBauServer(p, worldOwner.getUuid());
@ -183,31 +175,43 @@ public class BauCommand {
} }
} }
private static void togglewe(ProxiedPlayer p, String[] command){ private static void togglewe(ProxiedPlayer p, String[] args){
BauweltMember target = toggle(p, command, "togglewe"); BauweltMember target = toggle(p, args, "togglewe");
if(target == null) if(target == null)
return; return;
target.setWorldEdit(!target.isWorldEdit()); target.setWorldEdit(!target.isWorldEdit());
clearMembercache(p);
isAllowedTo(target.isWorldEdit(), p, target, "WorldEdit verwenden"); isAllowedTo(target.isWorldEdit(), p, target, "WorldEdit verwenden");
} }
private static void toggleworld(ProxiedPlayer p, String[] command){ private static void toggleworld(ProxiedPlayer p, String[] args){
BauweltMember target = toggle(p, command, "toggleworld"); BauweltMember target = toggle(p, args, "toggleworld");
if(target == null) if(target == null)
return; return;
target.setWorld(!target.isWorld()); target.setWorld(!target.isWorld());
clearMembercache(p);
isAllowedTo(target.isWorld(), p, target, "Einstellungen vornehmen"); isAllowedTo(target.isWorld(), p, target, "Einstellungen vornehmen");
} }
private static void delmember(ProxiedPlayer p, String[] command){ private static void clearMembercache(ProxiedPlayer p){
if (command.length == 2) { for(ServerInfo info : ProxyServer.getInstance().getServers().values()){
Subserver server = Subserver.getSubserver(info);
if(server != null && server.getType() == Servertype.BAUSERVER && ((Bauserver)server).getOwner().equals(p.getUniqueId())){
info.getPlayers().stream().findAny().ifPresent(player -> new BaumemberUpdatePacket().send(player));
break;
}
}
}
private static void delmember(ProxiedPlayer p, String[] args){
if (args.length == 1) {
Message.send("BAU_DELMEMBER_USAGE", p); Message.send("BAU_DELMEMBER_USAGE", p);
return; return;
} }
BauweltMember target = member(p, SteamwarUser.get(command[2])); BauweltMember target = member(p, SteamwarUser.get(args[1]));
if(target == null) if(target == null)
return; return;
@ -228,13 +232,13 @@ public class BauCommand {
Message.send("BAU_DELMEMBER_DELETED", p); Message.send("BAU_DELMEMBER_DELETED", p);
} }
private static void delete(ProxiedPlayer p, String[] command){ private static void delete(ProxiedPlayer p, String[] args){
SWInventory inventory = new SWInventory(p, 9, Message.parse("BAU_DELETE_GUI_NAME", p)); SWInventory inventory = new SWInventory(p, 9, Message.parse("BAU_DELETE_GUI_NAME", p));
inventory.addItem(8, new SWItem(Message.parse("BAU_DELETE_GUI_CANCEL", p), 1), click -> inventory.addItem(8, new SWItem(Message.parse("BAU_DELETE_GUI_CANCEL", p), 1), click ->
inventory.close() inventory.close()
); );
inventory.addItem(0, new SWItem(Message.parse("BAU_DELETE_GUI_DELETE", p), 10), click -> { inventory.addItem(0, new SWItem(Message.parse("BAU_DELETE_GUI_DELETE", p), 10), click -> {
if(bau15(p, command, 2)){ if(bau15(p, args, 1)){
SteamwarUser user = SteamwarUser.get(p.getUniqueId()); SteamwarUser user = SteamwarUser.get(p.getUniqueId());
deleteWorld(p, BungeeCore.USERWORLDS15 + user.getId()); deleteWorld(p, BungeeCore.USERWORLDS15 + user.getId());
}else{ }else{
@ -275,8 +279,8 @@ public class BauCommand {
} }
} }
private static void testarena(ProxiedPlayer p, String[] command){ private static void testarena(ProxiedPlayer p, String[] args){
FightCommand.createArena(p, "/bau testarena ", command, 2, false, (player, mode, map) -> ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> { FightCommand.createArena(p, "/bau testarena ", args, 1, false, (player, mode, map) -> ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
stopBauserver(p); stopBauserver(p);
SubserverSystem.startTestServer(p, mode, map, 0, 0); SubserverSystem.startTestServer(p, mode, map, 0, 0);
})); }));
@ -296,13 +300,13 @@ public class BauCommand {
return target; return target;
} }
private static BauweltMember toggle(ProxiedPlayer p, String[] command, String subcommand){ private static BauweltMember toggle(ProxiedPlayer p, String[] args, String subcommand){
if (command.length == 2) { if (args.length == 1) {
Message.send("BAU_MEMBER_TOGGLE_USAGE", p, subcommand); Message.send("BAU_MEMBER_TOGGLE_USAGE", p, subcommand);
return null; return null;
} }
SteamwarUser member = SteamwarUser.get(command[2]); SteamwarUser member = SteamwarUser.get(args[1]);
return member(p, member); return member(p, member);
} }

Datei anzeigen

@ -25,6 +25,7 @@ public class PacketIdManager {
public static final byte PING_PACKET = 0x01; public static final byte PING_PACKET = 0x01;
public static final byte TABLIST_NAME = 0x02; public static final byte TABLIST_NAME = 0x02;
public static final byte PREPARE_SCHEM = 0x03; public static final byte PREPARE_SCHEM = 0x03;
public static final byte BAUMEMBER_UPDATE = 0x04;
//0x1(X) Bungee Inventory //0x1(X) Bungee Inventory
public static final byte INVENTORY_PACKET = 0x10; public static final byte INVENTORY_PACKET = 0x10;

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.comms.packets;
import com.google.common.io.ByteArrayDataOutput;
import de.steamwar.bungeecore.comms.BungeePacket;
import de.steamwar.bungeecore.comms.PacketIdManager;
public class BaumemberUpdatePacket extends BungeePacket {
@Override
public int getId() {
return PacketIdManager.BAUMEMBER_UPDATE;
}
@Override
public void writeVars(ByteArrayDataOutput byteArrayDataOutput) {
// empty
}
}

Datei anzeigen

@ -22,7 +22,6 @@ package de.steamwar.bungeecore.listeners;
import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.*;
import de.steamwar.bungeecore.bot.SteamwarDiscordBot; import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
import de.steamwar.bungeecore.bot.listeners.IngameChatListener; import de.steamwar.bungeecore.bot.listeners.IngameChatListener;
import de.steamwar.bungeecore.commands.BauCommand;
import de.steamwar.bungeecore.commands.TpCommand; import de.steamwar.bungeecore.commands.TpCommand;
import de.steamwar.bungeecore.comms.packets.PingPacket; import de.steamwar.bungeecore.comms.packets.PingPacket;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
@ -82,11 +81,6 @@ public class ChatListener extends BasicListener {
} }
switch(command[0].toLowerCase()){ switch(command[0].toLowerCase()){
case "/bau":
case "/b":
case "/gs":
BauCommand.onBau(e, command);
break;
case "/bc": case "/bc":
case "/bauchat": case "/bauchat":
case "/local": case "/local":