Dieser Commit ist enthalten in:
Commit
584b8197aa
@ -1 +1 @@
|
||||
Subproject commit 919c4d525ea39756b24bd961bb72d8d58bdd5bd4
|
||||
Subproject commit 492894ca8d41ee0bde4dcb9d520db5f7478c50c7
|
@ -22,9 +22,9 @@ package de.steamwar.bungeecore;
|
||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||
import de.steamwar.bungeecore.commands.*;
|
||||
import de.steamwar.bungeecore.comms.SpigotReceiver;
|
||||
import de.steamwar.bungeecore.listeners.*;
|
||||
import de.steamwar.bungeecore.listeners.mods.*;
|
||||
import de.steamwar.bungeecore.network.NetworkReceiver;
|
||||
import de.steamwar.bungeecore.sql.*;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
@ -156,7 +156,7 @@ public class BungeeCore extends Plugin {
|
||||
|
||||
new EventStarter();
|
||||
new SessionManager();
|
||||
new SpigotReceiver();
|
||||
new NetworkReceiver();
|
||||
new TablistManager();
|
||||
new SettingsChangedListener();
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class ServerStarter {
|
||||
private static final String EVENT_PATH = BACKBONE + "event/";
|
||||
public static final String TEMP_WORLD_PATH = BACKBONE + "arenaserver/";
|
||||
public static final String TUTORIAL_PATH = BACKBONE + "tutorials/";
|
||||
public static final String WORLDS18_PATH = BACKBONE + "userworlds18/";
|
||||
public static final String WORLDS19_PATH = BACKBONE + "userworlds19/";
|
||||
|
||||
private File directory = null;
|
||||
private String worldDir = null;
|
||||
@ -109,10 +109,10 @@ public class ServerStarter {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ServerStarter build18(UUID owner) {
|
||||
directory = new File(SERVER_PATH, "Bau18");
|
||||
serverJar = "paper-1.18.2.jar";
|
||||
worldDir = WORLDS18_PATH;
|
||||
public ServerStarter build19(UUID owner) {
|
||||
directory = new File(SERVER_PATH, "Bau19");
|
||||
serverJar = "paper-1.19.jar";
|
||||
worldDir = WORLDS19_PATH;
|
||||
worldName = String.valueOf(SteamwarUser.get(owner).getId());
|
||||
buildWithWorld(owner, new File(directory, "Bauwelt").getPath());
|
||||
return this;
|
||||
|
@ -19,10 +19,11 @@
|
||||
|
||||
package de.steamwar.bungeecore;
|
||||
|
||||
import de.steamwar.bungeecore.comms.handlers.FightInfoHandler;
|
||||
import de.steamwar.bungeecore.comms.packets.StartingServerPacket;
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
import de.steamwar.bungeecore.network.handlers.FightInfoHandler;
|
||||
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.network.packets.server.StartingServerPacket;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
@ -53,6 +54,6 @@ public class SubserverSystem {
|
||||
public static void sendPlayer(Subserver subserver, ProxiedPlayer player) {
|
||||
subserver.sendPlayer(player);
|
||||
if(!subserver.hasStarted() && FightInfoHandler.onLobby(player))
|
||||
new StartingServerPacket(SteamwarUser.get(player.getUniqueId())).send(player);
|
||||
NetworkSender.send(player, new StartingServerPacket(SteamwarUser.get(player.getUniqueId()).getId()));
|
||||
}
|
||||
}
|
||||
|
@ -20,12 +20,13 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.comms.packets.BaumemberUpdatePacket;
|
||||
import de.steamwar.bungeecore.inventory.SWInventory;
|
||||
import de.steamwar.bungeecore.inventory.SWItem;
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
import de.steamwar.bungeecore.sql.BauweltMember;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
@ -46,7 +47,7 @@ public class BauCommand extends BasicCommand {
|
||||
ProxiedPlayer p = (ProxiedPlayer) sender;
|
||||
|
||||
versionSelector(p, args, 0,
|
||||
() -> new ServerStarter().build18(p.getUniqueId()).send(p).start(),
|
||||
() -> new ServerStarter().build19(p.getUniqueId()).send(p).start(),
|
||||
() -> new ServerStarter().build15(p.getUniqueId()).send(p).start(),
|
||||
() -> new ServerStarter().build12(p.getUniqueId()).send(p).start(),
|
||||
() -> {
|
||||
@ -128,13 +129,13 @@ public class BauCommand extends BasicCommand {
|
||||
}
|
||||
|
||||
versionSelector(p, args, 2,
|
||||
() -> new ServerStarter().build18(worldOwner.getUuid()).send(p).start(),
|
||||
() -> new ServerStarter().build19(worldOwner.getUuid()).send(p).start(),
|
||||
() -> new ServerStarter().build15(worldOwner.getUuid()).send(p).start(),
|
||||
() -> new ServerStarter().build12(worldOwner.getUuid()).send(p).start(),
|
||||
() -> HelpCommand.sendBauHelp(ChatSender.of(p)));
|
||||
}
|
||||
|
||||
private static void versionSelector(ProxiedPlayer p, String[] args, int pos, Runnable run18, Runnable run15, Runnable run12, Runnable runElse) {
|
||||
private static void versionSelector(ProxiedPlayer p, String[] args, int pos, Runnable run19, Runnable run15, Runnable run12, Runnable runElse) {
|
||||
if(args.length <= pos) {
|
||||
int version = p.getPendingConnection().getVersion();
|
||||
if(version > 340) { // Version > 1.12.2
|
||||
@ -146,9 +147,11 @@ public class BauCommand extends BasicCommand {
|
||||
}
|
||||
|
||||
switch (args[pos].toLowerCase()) {
|
||||
case "19":
|
||||
case "1.19":
|
||||
case "18":
|
||||
case "1.18":
|
||||
run18.run();
|
||||
run19.run();
|
||||
break;
|
||||
case "ws":
|
||||
case "warship":
|
||||
@ -195,7 +198,7 @@ public class BauCommand extends BasicCommand {
|
||||
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));
|
||||
info.getPlayers().stream().findAny().ifPresent(player -> NetworkSender.send(player, new BaumemberUpdatePacket()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -231,7 +234,7 @@ public class BauCommand extends BasicCommand {
|
||||
private static void delete(ProxiedPlayer p, String[] args){
|
||||
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
|
||||
versionSelector(p, args, 1,
|
||||
() -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS18_PATH + user.getId())),
|
||||
() -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS19_PATH + user.getId())),
|
||||
() -> deleteConfirmation(p, () -> deleteWorld(p, BungeeCore.USERWORLDS15 + user.getId())),
|
||||
() -> deleteConfirmation(p, () -> deleteWorld(p, BungeeCore.WORLD_FOLDER + p.getUniqueId().toString())),
|
||||
() -> HelpCommand.sendBauHelp(ChatSender.of(p)));
|
||||
|
@ -31,6 +31,7 @@ import net.md_5.bungee.UserConnection;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.ServerConnectRequest;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
@ -565,6 +566,11 @@ public class TeamCommand extends BasicCommand {
|
||||
}
|
||||
|
||||
private void tp(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
||||
if (!user.getUserGroup().isAdminGroup()) {
|
||||
Message.send("DISABLED", player);
|
||||
return;
|
||||
}
|
||||
|
||||
if(args.length == 1){
|
||||
if(notInTeam(player, user))
|
||||
return;
|
||||
@ -590,14 +596,32 @@ public class TeamCommand extends BasicCommand {
|
||||
ProxyServer.getInstance().getServers().put(info.getName(), info);
|
||||
return info;
|
||||
});
|
||||
player.connect(ServerConnectRequest.builder()
|
||||
.target(serverInfo)
|
||||
.connectTimeout(BungeeCord.getInstance().getConfig().getServerConnectTimeout())
|
||||
.retry(false)
|
||||
.reason(ServerConnectEvent.Reason.PLUGIN)
|
||||
.callback((success, error) -> {
|
||||
if (error != null) {
|
||||
Message.send("TEAM_OFFLINE", player);
|
||||
}
|
||||
})
|
||||
.build());
|
||||
/*
|
||||
((UserConnection) player).connect(serverInfo, (success, error) -> {
|
||||
if (error != null) {
|
||||
Message.send("TEAM_OFFLINE", player);
|
||||
}
|
||||
}, false, ServerConnectEvent.Reason.PLUGIN, BungeeCord.getInstance().getConfig().getServerConnectTimeout(), false);
|
||||
*/
|
||||
}
|
||||
|
||||
private void server(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
||||
if (!user.getUserGroup().isAdminGroup()) {
|
||||
Message.send("DISABLED", player);
|
||||
return;
|
||||
}
|
||||
|
||||
if(notLeader(player, user, team))
|
||||
return;
|
||||
if (user.isPunishedWithMessage(ChatSender.of(player), Punishment.PunishmentType.NoTeamServer)) {
|
||||
|
@ -21,6 +21,7 @@ package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.sql.*;
|
||||
import de.steamwar.bungeecore.util.Chat19;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
@ -55,7 +56,7 @@ public class TpCommand extends BasicCommand {
|
||||
|
||||
//Give control of teleport command to server
|
||||
if(server == null) {
|
||||
player.chat("/tp " + String.join(" ", args));
|
||||
Chat19.chat(player, "/tp " + String.join(" ", args));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -103,6 +103,9 @@ public class WhoisCommand extends BasicCommand {
|
||||
if (!all && !punishment.getType().isMulti() && !found.add(punishment.getType())) {
|
||||
continue;
|
||||
}
|
||||
if (!all && !punishment.isCurrent()) {
|
||||
continue;
|
||||
}
|
||||
Message.sendPrefixless("WHOIS_PUNISHMENT", player, SteamwarUser.get(punishment.getPunisher()).getUserName(), punishment.getType().name(), punishment.getBantime(punishment.getStartTime(), false), punishment.getBantime(punishment.getEndTime(), punishment.isPerma()), punishment.getReason());
|
||||
isPunished = true;
|
||||
}
|
||||
|
@ -1,47 +0,0 @@
|
||||
/*
|
||||
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;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.connection.Server;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
public abstract class BungeePacket {
|
||||
|
||||
public void send(Server server) {
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeByte(getId());
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
writeVars(out);
|
||||
out.writeUTF(outputStream.toByteArray().toString());
|
||||
server.sendData("sw:bridge", out.toByteArray());
|
||||
}
|
||||
|
||||
public void send(ProxiedPlayer player) {
|
||||
send(player.getServer());
|
||||
}
|
||||
|
||||
public abstract int getId();
|
||||
|
||||
public abstract void writeVars(ByteArrayDataOutput byteArrayDataOutput);
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
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;
|
||||
|
||||
public class PacketIdManager {
|
||||
|
||||
//0x0(X) Standalone Packets
|
||||
public static final byte PING_PACKET = 0x01;
|
||||
public static final byte TABLIST_NAME = 0x02;
|
||||
public static final byte PREPARE_SCHEM = 0x03;
|
||||
public static final byte BAUMEMBER_UPDATE = 0x04;
|
||||
public static final byte EXECUTE_COMMAND = 0x05;
|
||||
|
||||
public static final byte LOCALE_INVALIDATION = 0x06;
|
||||
|
||||
//0x1(X) Bungee Inventory
|
||||
public static final byte INVENTORY_PACKET = 0x10;
|
||||
public static final byte INVENTORY_CALLBACK_PACKET = 0x11;
|
||||
public static final byte INVENTORY_CLOSE_PACKET = 0x12;
|
||||
|
||||
//0x2(X) Server Information System
|
||||
public static final byte I_AM_A_LOBBY = 0x20;
|
||||
public static final byte FIGHT_INFO = 0x21;
|
||||
public static final byte FIGHT_ENDS = 0x22;
|
||||
public static final byte STARTING_SERVER = 0x23;
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
/*
|
||||
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;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
|
||||
public interface SpigotHandler {
|
||||
|
||||
void handle(ByteArrayDataInput in, ServerInfo info);
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
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;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.comms.handlers.*;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.Server;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SpigotReceiver extends BasicListener {
|
||||
|
||||
private static final Map<Byte, SpigotHandler> handlerMap = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void onPluginMessage(PluginMessageEvent event) {
|
||||
if(!event.getTag().equalsIgnoreCase("sw:bridge"))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
if(!(event.getSender() instanceof Server))
|
||||
return;
|
||||
|
||||
ByteArrayDataInput in = ByteStreams.newDataInput(event.getData());
|
||||
Byte handler = in.readByte();
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> handlerMap.get(handler).handle(in, ((Server) event.getSender()).getInfo()));
|
||||
}
|
||||
|
||||
public static void registerHandler(Byte id, SpigotHandler handler) {
|
||||
handlerMap.put(id, handler);
|
||||
}
|
||||
|
||||
static {
|
||||
registerHandler(PacketIdManager.INVENTORY_CALLBACK_PACKET, new InventoryCallbackHandler());
|
||||
registerHandler(PacketIdManager.TABLIST_NAME, (in, info) -> {});
|
||||
registerHandler(PacketIdManager.PREPARE_SCHEM, new PrepareSchemHandler());
|
||||
registerHandler(PacketIdManager.I_AM_A_LOBBY, new ImALobbyHandler());
|
||||
registerHandler(PacketIdManager.FIGHT_INFO, new FightInfoHandler());
|
||||
registerHandler(PacketIdManager.EXECUTE_COMMAND, new ExecuteCommandHandler());
|
||||
registerHandler(PacketIdManager.FIGHT_ENDS, new FightEndsHandler());
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
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
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
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 CloseInventoryPacket extends BungeePacket {
|
||||
|
||||
final int player;
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return PacketIdManager.INVENTORY_CLOSE_PACKET;
|
||||
}
|
||||
|
||||
public CloseInventoryPacket(int player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeVars(ByteArrayDataOutput byteArrayDataOutput) {
|
||||
byteArrayDataOutput.writeInt(player);
|
||||
}
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
/*
|
||||
* 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.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import de.steamwar.bungeecore.comms.BungeePacket;
|
||||
import de.steamwar.bungeecore.comms.PacketIdManager;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public class FightEndsPacket extends BungeePacket {
|
||||
|
||||
private byte win;
|
||||
private int blueSchem;
|
||||
private int redSchem;
|
||||
private List<Integer> bluePlayers;
|
||||
private List<Integer> redPlayers;
|
||||
private String gameMode;
|
||||
|
||||
public FightEndsPacket(ByteArrayDataInput byteArrayDataInput) {
|
||||
win = byteArrayDataInput.readByte();
|
||||
blueSchem = byteArrayDataInput.readInt();
|
||||
redSchem = byteArrayDataInput.readInt();
|
||||
int blueSize = byteArrayDataInput.readInt();
|
||||
bluePlayers = new ArrayList<>(blueSize);
|
||||
for (int i = 0; i < blueSize; i++) {
|
||||
bluePlayers.add(byteArrayDataInput.readInt());
|
||||
}
|
||||
int redSize = byteArrayDataInput.readInt();
|
||||
redPlayers = new ArrayList<>(redSize);
|
||||
for (int i = 0; i < redSize; i++) {
|
||||
redPlayers.add(byteArrayDataInput.readInt());
|
||||
}
|
||||
gameMode = byteArrayDataInput.readUTF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return PacketIdManager.FIGHT_ENDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeVars(ByteArrayDataOutput byteArrayDataOutput) {
|
||||
byteArrayDataOutput.writeByte(win);
|
||||
byteArrayDataOutput.writeInt(blueSchem);
|
||||
byteArrayDataOutput.writeInt(redSchem);
|
||||
byteArrayDataOutput.writeInt(bluePlayers.size());
|
||||
for (int i : bluePlayers) {
|
||||
byteArrayDataOutput.writeInt(i);
|
||||
}
|
||||
byteArrayDataOutput.writeInt(redPlayers.size());
|
||||
for (int i : redPlayers) {
|
||||
byteArrayDataOutput.writeInt(i);
|
||||
}
|
||||
byteArrayDataOutput.writeUTF(gameMode);
|
||||
}
|
||||
}
|
@ -1,183 +0,0 @@
|
||||
/*
|
||||
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.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import de.steamwar.bungeecore.comms.BungeePacket;
|
||||
import de.steamwar.bungeecore.comms.PacketIdManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FightInfoPacket extends BungeePacket {
|
||||
|
||||
private String serverName; // Name of the Server
|
||||
private final String gameMode; // GameMode aka Schematictype (if known, else "")
|
||||
private final String arena; // Name of the arena
|
||||
private final String blueName; // Name of the blue team, expected to begin with "§a" colorcode
|
||||
private final String redName; // Name of the red team, expected to begin with "§a" colorcode
|
||||
private final String fightState; // Fight state (technical term) (if known, else "")
|
||||
private final int countdown; // Countdown state in seconds (if known, else 0)
|
||||
private final int blueLeader; // SWUserID of the blue team leader (if known, else 0)
|
||||
private final int redLeader; // SWUserID of the red team leader (if known, else 0)
|
||||
private final int blueSchem; // Blue SchemID (if known, else 0)
|
||||
private final int redSchem; // Red SchemID (if known, else 0)
|
||||
private final List<Integer> bluePlayers; // List of Blue SWUserIDs
|
||||
private final List<Integer> redPlayers; // List of Red SWUserIDs
|
||||
private final List<Integer> spectators; // List of Spectator SWUserIDs
|
||||
|
||||
public FightInfoPacket(String serverName, String gameMode, String arena, String blueName, String redName, String fightState, int countdown, int blueLeader, int redLeader, int blueSchem, int redSchem, List<Integer> bluePlayers, List<Integer> redPlayers, List<Integer> spectators) {
|
||||
this.serverName = serverName;
|
||||
this.gameMode = gameMode;
|
||||
this.arena = arena;
|
||||
this.blueName = blueName;
|
||||
this.redName = redName;
|
||||
this.fightState = fightState;
|
||||
this.countdown = countdown;
|
||||
this.blueLeader = blueLeader;
|
||||
this.redLeader = redLeader;
|
||||
this.blueSchem = blueSchem;
|
||||
this.redSchem = redSchem;
|
||||
this.bluePlayers = bluePlayers;
|
||||
this.redPlayers = redPlayers;
|
||||
this.spectators = spectators;
|
||||
}
|
||||
|
||||
public FightInfoPacket(ByteArrayDataInput in) {
|
||||
this.serverName = in.readUTF();
|
||||
this.gameMode = in.readUTF();
|
||||
this.arena = in.readUTF();
|
||||
this.blueName = in.readUTF();
|
||||
this.redName = in.readUTF();
|
||||
this.fightState = in.readUTF();
|
||||
this.countdown = in.readInt();
|
||||
this.blueLeader = in.readInt();
|
||||
this.redLeader = in.readInt();
|
||||
this.blueSchem = in.readInt();
|
||||
this.redSchem = in.readInt();
|
||||
this.bluePlayers = readPlayerList(in);
|
||||
this.redPlayers = readPlayerList(in);
|
||||
this.spectators = readPlayerList(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return PacketIdManager.FIGHT_INFO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeVars(ByteArrayDataOutput out) {
|
||||
out.writeUTF(serverName);
|
||||
out.writeUTF(gameMode);
|
||||
out.writeUTF(arena);
|
||||
out.writeUTF(blueName);
|
||||
out.writeUTF(redName);
|
||||
out.writeUTF(fightState);
|
||||
out.writeInt(countdown);
|
||||
out.writeInt(blueLeader);
|
||||
out.writeInt(redLeader);
|
||||
out.writeInt(blueSchem);
|
||||
out.writeInt(redSchem);
|
||||
writePlayerList(out, bluePlayers);
|
||||
writePlayerList(out, redPlayers);
|
||||
writePlayerList(out, spectators);
|
||||
}
|
||||
|
||||
public String getServerName() {
|
||||
return serverName;
|
||||
}
|
||||
|
||||
public void setServerName(String serverName) {
|
||||
this.serverName = serverName;
|
||||
}
|
||||
|
||||
public String getGameMode() {
|
||||
return gameMode;
|
||||
}
|
||||
|
||||
public String getArena() {
|
||||
return arena;
|
||||
}
|
||||
|
||||
public String getBlueName() {
|
||||
return blueName;
|
||||
}
|
||||
|
||||
public String getRedName() {
|
||||
return redName;
|
||||
}
|
||||
|
||||
public String getFightState() {
|
||||
return fightState;
|
||||
}
|
||||
|
||||
public int getCountdown() {
|
||||
return countdown;
|
||||
}
|
||||
|
||||
public int getBlueLeader() {
|
||||
return blueLeader;
|
||||
}
|
||||
|
||||
public int getRedLeader() {
|
||||
return redLeader;
|
||||
}
|
||||
|
||||
public int getBlueSchem() {
|
||||
return blueSchem;
|
||||
}
|
||||
|
||||
public int getRedSchem() {
|
||||
return redSchem;
|
||||
}
|
||||
|
||||
public List<Integer> getBluePlayers() {
|
||||
return bluePlayers;
|
||||
}
|
||||
|
||||
public List<Integer> getRedPlayers() {
|
||||
return redPlayers;
|
||||
}
|
||||
|
||||
public List<Integer> getSpectators() {
|
||||
return spectators;
|
||||
}
|
||||
|
||||
public int playerSize(){
|
||||
return bluePlayers.size() + redPlayers.size() + spectators.size();
|
||||
}
|
||||
|
||||
private static List<Integer> readPlayerList(ByteArrayDataInput in) {
|
||||
int length = in.readInt();
|
||||
List<Integer> players = new ArrayList<>(length);
|
||||
for(int i = 0; i < length; i++) {
|
||||
players.add(in.readInt());
|
||||
}
|
||||
return players;
|
||||
}
|
||||
|
||||
private void writePlayerList(ByteArrayDataOutput out, List<Integer> players) {
|
||||
out.writeInt(players.size());
|
||||
for(Integer player : players) {
|
||||
out.writeInt(player);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
/*
|
||||
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 com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import de.steamwar.bungeecore.comms.PacketIdManager;
|
||||
import de.steamwar.bungeecore.inventory.SWInventory;
|
||||
import de.steamwar.bungeecore.inventory.SWItem;
|
||||
import de.steamwar.bungeecore.comms.BungeePacket;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class InventoryPacket extends BungeePacket {
|
||||
|
||||
final String title;
|
||||
final int player;
|
||||
final int size;
|
||||
final Map<Integer, SWItem> items;
|
||||
|
||||
public InventoryPacket(int size, String title, ProxiedPlayer player) {
|
||||
items = new HashMap<>();
|
||||
this.title = title;
|
||||
this.size = size;
|
||||
this.player = SteamwarUser.get(player).getId();
|
||||
}
|
||||
|
||||
public InventoryPacket(SWInventory inventory) {
|
||||
items = inventory.getItems();
|
||||
this.title = inventory.getTitle();
|
||||
this.size = inventory.getSize();
|
||||
this.player = SteamwarUser.get(inventory.getPlayer()).getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return PacketIdManager.INVENTORY_PACKET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeVars(ByteArrayDataOutput byteArrayDataOutput) {
|
||||
JsonObject object = new JsonObject();
|
||||
object.addProperty("id", player);
|
||||
object.addProperty("title", title);
|
||||
object.addProperty("size", size);
|
||||
object.addProperty("itemcount", items.size());
|
||||
JsonArray array = new JsonArray();
|
||||
for (int i = 0; i < size; i++) {
|
||||
if(items.get(i) != null)
|
||||
array.add(items.get(i).writeToString(i));
|
||||
}
|
||||
object.add("items", array);
|
||||
byteArrayDataOutput.writeUTF(object.toString());
|
||||
}
|
||||
|
||||
public void setItem(int index, SWItem item) {
|
||||
items.put(index, item);
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
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 PingPacket extends BungeePacket {
|
||||
|
||||
final int id;
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return PacketIdManager.PING_PACKET;
|
||||
}
|
||||
|
||||
public PingPacket(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeVars(ByteArrayDataOutput byteArrayDataOutput) {
|
||||
byteArrayDataOutput.writeInt(id);
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package de.steamwar.bungeecore.comms.packets;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import de.steamwar.bungeecore.comms.BungeePacket;
|
||||
import de.steamwar.bungeecore.comms.PacketIdManager;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
|
||||
public class StartingServerPacket extends BungeePacket {
|
||||
|
||||
private final int user;
|
||||
|
||||
public StartingServerPacket(SteamwarUser user) {
|
||||
this.user = user.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return PacketIdManager.STARTING_SERVER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeVars(ByteArrayDataOutput out) {
|
||||
out.writeInt(user);
|
||||
}
|
||||
}
|
@ -19,10 +19,11 @@
|
||||
|
||||
package de.steamwar.bungeecore.inventory;
|
||||
|
||||
import de.steamwar.bungeecore.comms.handlers.InventoryCallbackHandler;
|
||||
import de.steamwar.bungeecore.comms.packets.CloseInventoryPacket;
|
||||
import de.steamwar.bungeecore.comms.packets.InventoryPacket;
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
import de.steamwar.bungeecore.network.handlers.InventoryCallbackHandler;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.network.packets.server.CloseInventoryPacket;
|
||||
import de.steamwar.network.packets.server.InventoryPacket;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -30,6 +31,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
public class SWInventory {
|
||||
|
||||
@ -120,8 +122,14 @@ public class SWInventory {
|
||||
}
|
||||
|
||||
public void open() {
|
||||
InventoryPacket inv = new InventoryPacket(this);
|
||||
inv.send(player);
|
||||
InventoryPacket inv = new InventoryPacket(title, SteamwarUser.get(player).getId(), size, map(itemMap, (integer, swItem) -> swItem.writeToString(integer).getAsString()));
|
||||
NetworkSender.send(player, inv);
|
||||
}
|
||||
|
||||
private static <T, K, J> Map<T, J> map(Map<T, K> map, BiFunction<T, K, J> function) {
|
||||
Map<T, J> result = new HashMap<>();
|
||||
map.forEach((key, value) -> result.put(key, function.apply(key, value)));
|
||||
return result;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
@ -129,7 +137,7 @@ public class SWInventory {
|
||||
}
|
||||
|
||||
public static void close(ProxiedPlayer player) {
|
||||
new CloseInventoryPacket(SteamwarUser.get(player).getId()).send(player);
|
||||
NetworkSender.send(player, new CloseInventoryPacket(SteamwarUser.get(player).getId()));
|
||||
}
|
||||
|
||||
public void setClose(InvCallback close) {
|
||||
|
@ -50,6 +50,7 @@ public class BanListener extends BasicListener {
|
||||
user.updateBanIP(event.getConnection().getAddress().getAddress().getHostAddress());
|
||||
event.setCancelled(true);
|
||||
ChatSender.of(event).system(user.punishmentMessage(Punishment.PunishmentType.Ban));
|
||||
event.completeIntent(BungeeCore.get());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -21,9 +21,11 @@ package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||
import de.steamwar.bungeecore.comms.packets.PingPacket;
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
import de.steamwar.bungeecore.sql.*;
|
||||
import de.steamwar.bungeecore.util.Chat19;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.network.packets.server.PingPacket;
|
||||
import net.md_5.bungee.api.*;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.ChatEvent;
|
||||
@ -123,7 +125,7 @@ public class ChatListener extends BasicListener {
|
||||
return;
|
||||
}
|
||||
|
||||
player.chat(message);
|
||||
Chat19.chat(player, message);
|
||||
}
|
||||
|
||||
private static String modifyFilter(ChatSender sender, String message) {
|
||||
@ -202,7 +204,7 @@ public class ChatListener extends BasicListener {
|
||||
String mark = "@" + player.user().getUserName();
|
||||
return Arrays.stream(message.split(" ")).map(cur -> {
|
||||
if(cur.equalsIgnoreCase(mark)) {
|
||||
new PingPacket(player.user().getId()).send(player.user().getPlayer());
|
||||
NetworkSender.send(player.user().getPlayer(), new PingPacket(player.user().getId()));
|
||||
return "§e" + cur + returnColor;
|
||||
}
|
||||
return cur;
|
||||
|
@ -26,15 +26,13 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.SettingsChangedEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class SettingsChangedListener extends BasicListener {
|
||||
|
||||
@EventHandler
|
||||
public void onSettingsChanged(SettingsChangedEvent event) {
|
||||
BungeeCord.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
SteamwarUser.get(player).setLocale(Objects.requireNonNull(player.getLocale()), false);
|
||||
SteamwarUser.get(player).setLocale(player.getLocale(), false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,12 @@
|
||||
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import io.github.waterfallmc.waterfall.utils.UUIDUtils;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.event.LoginEvent;
|
||||
import net.md_5.bungee.connection.InitialHandler;
|
||||
import net.md_5.bungee.connection.LoginResult;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.protocol.Property;
|
||||
import net.md_5.bungee.util.AddressUtil;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@ -49,12 +49,19 @@ public class SubserverProtocolFixer extends BasicListener {
|
||||
@EventHandler
|
||||
public void loginEvent(LoginEvent e) {
|
||||
InitialHandler initialHandler = ((InitialHandler) e.getConnection());
|
||||
LoginResult.Property[] properties = initialHandler.getLoginProfile().getProperties();
|
||||
try {
|
||||
String extraData = "\00" + AddressUtil.sanitizeAddress(inetSocketAddress) + "\00" + UUIDUtils.undash(initialHandler.getUniqueId().toString());
|
||||
|
||||
String undashedUUID = initialHandler.getUniqueId().toString().replace("-", "");
|
||||
String extraData = "\00" + AddressUtil.sanitizeAddress(inetSocketAddress) + "\00" + undashedUUID;
|
||||
|
||||
LoginResult result = initialHandler.getLoginProfile();
|
||||
if (result != null) {
|
||||
Property[] properties = result.getProperties();
|
||||
if (properties.length > 0) {
|
||||
extraData += "\00" + BungeeCord.getInstance().gson.toJson(properties);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
field.set(initialHandler, extraData);
|
||||
} catch (IllegalAccessException ex) {
|
||||
BungeeCord.getInstance().getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
||||
|
@ -26,9 +26,10 @@ import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.Servertype;
|
||||
import de.steamwar.bungeecore.Subserver;
|
||||
import de.steamwar.bungeecore.comms.packets.FightInfoPacket;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.sql.UserGroup;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import de.steamwar.network.packets.common.FightInfoPacket;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
@ -48,7 +49,11 @@ public class TablistManager extends BasicListener {
|
||||
|
||||
@EventHandler
|
||||
public synchronized void onJoin(PostLoginEvent e){
|
||||
tablists.put(e.getPlayer(), new Tablist(e.getPlayer()));
|
||||
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||
if (e.getPlayer().isConnected()) {
|
||||
tablists.put(e.getPlayer(), new Tablist(e.getPlayer()));
|
||||
}
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -88,7 +93,7 @@ public class TablistManager extends BasicListener {
|
||||
//Calculate server-player-map
|
||||
tablist = new TablistGroup(true, "");
|
||||
TablistGroup bau = new TablistGroup(false, "Bau");
|
||||
for (ServerInfo server : ProxyServer.getInstance().getServersCopy().values()){
|
||||
for (ServerInfo server : new ArrayList<>(ProxyServer.getInstance().getServers().values())){
|
||||
if(server.getPlayers().isEmpty())
|
||||
continue;
|
||||
|
||||
|
@ -41,6 +41,7 @@ import java.nio.charset.UnsupportedCharsetException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Fabric extends BasicListener {
|
||||
|
||||
@ -59,7 +60,7 @@ public class Fabric extends BasicListener {
|
||||
continue;
|
||||
}
|
||||
if (System.currentTimeMillis() - entry.getValue() > TimeUnit.SECONDS.toMillis(20)) {
|
||||
banPlayer(SteamwarUser.get(entry.getKey()), entry.getKey());
|
||||
banPlayer(SteamwarUser.get(entry.getKey()), entry.getKey(), "Expected message not received");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -82,7 +83,7 @@ public class Fabric extends BasicListener {
|
||||
if (!Storage.fabricCheckedPlayers.containsKey(player)) {
|
||||
synchronized (Storage.fabricExpectPluginMessage) {
|
||||
if (Storage.fabricExpectPluginMessage.containsKey(player)) {
|
||||
banPlayer(user, player);
|
||||
banPlayer(user, player, "Was not fabric checked but send message nonetheless");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -95,7 +96,7 @@ public class Fabric extends BasicListener {
|
||||
Utils.VarInt varInt = Utils.readVarInt(data,0);
|
||||
|
||||
if(data.length != varInt.length + varInt.value) {
|
||||
banPlayer(user,player);
|
||||
banPlayer(user,player, "Invalid message length");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -106,7 +107,7 @@ public class Fabric extends BasicListener {
|
||||
try{
|
||||
dataString = new String(data, StandardCharsets.UTF_8);
|
||||
}catch (UnsupportedCharsetException exception) {
|
||||
banPlayer(user, player);
|
||||
banPlayer(user, player, "Unsupported charset");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -115,7 +116,7 @@ public class Fabric extends BasicListener {
|
||||
try {
|
||||
array = new JsonParser().parse(dataString).getAsJsonArray();
|
||||
}catch (JsonSyntaxException exception) {
|
||||
banPlayer(user, player);
|
||||
banPlayer(user, player, "Invalid json");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -126,12 +127,12 @@ public class Fabric extends BasicListener {
|
||||
boolean isSorted = isSortedAlphabetically(mods);
|
||||
|
||||
if(!isSorted) {
|
||||
banPlayer(user, player);
|
||||
banPlayer(user, player, "Mods are not sorted alphabetically: " + mods.stream().map(Mod::getModName).collect(Collectors.joining(", ")));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!neededModsContained(mods)) {
|
||||
banPlayer(user, player);
|
||||
banPlayer(user, player, "Needed mods are not contained");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -139,7 +140,7 @@ public class Fabric extends BasicListener {
|
||||
if (Storage.fabricCheckedPlayers.containsKey(player)) {
|
||||
long current = Storage.fabricCheckedPlayers.get(player);
|
||||
if (current != dataString.hashCode()) {
|
||||
banPlayer(user, player);
|
||||
banPlayer(user, player, "");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@ -176,11 +177,11 @@ public class Fabric extends BasicListener {
|
||||
.count() == neededMods.size();
|
||||
}
|
||||
|
||||
public void banPlayer(SteamwarUser user, ProxiedPlayer player) {
|
||||
public void banPlayer(SteamwarUser user, ProxiedPlayer player, String reason) {
|
||||
user.punishPerma(Punishment.PunishmentType.Ban,
|
||||
Message.parse("MODIFICATION_BAN_MESSAGE", player, user.getUserName(), user.getId()),
|
||||
0);
|
||||
BungeeCore.log(Level.SEVERE,Message.parse("MODIFICATION_BAN_LOG", player, user.getUserName()));
|
||||
BungeeCore.log(Level.SEVERE,Message.parse("MODIFICATION_BAN_LOG", player, user.getUserName(), reason));
|
||||
}
|
||||
|
||||
public static void remove(ProxiedPlayer player) {
|
||||
|
35
src/de/steamwar/bungeecore/network/BungeeNetworkHandler.java
Normale Datei
35
src/de/steamwar/bungeecore/network/BungeeNetworkHandler.java
Normale Datei
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2022 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.bungeecore.network.handlers.*;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
@UtilityClass
|
||||
public class BungeeNetworkHandler {
|
||||
public static void register() {
|
||||
new ExecuteCommandHandler().register();
|
||||
new FightEndsHandler().register();
|
||||
new FightInfoHandler().register();
|
||||
new ImALobbyHandler().register();
|
||||
new InventoryCallbackHandler().register();
|
||||
new PrepareSchemHandler().register();
|
||||
}
|
||||
}
|
61
src/de/steamwar/bungeecore/network/NetworkReceiver.java
Normale Datei
61
src/de/steamwar/bungeecore/network/NetworkReceiver.java
Normale Datei
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2022 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.bungeecore.BungeeCore;
|
||||
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;
|
||||
import net.md_5.bungee.event.EventPriority;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class NetworkReceiver extends BasicListener {
|
||||
|
||||
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)
|
||||
public synchronized void onPluginMessage(PluginMessageEvent event) {
|
||||
if (blockedTags.contains(event.getTag()) && !allowedAddresses.contains(((InetSocketAddress) event.getSender().getSocketAddress()).getHostString())) {
|
||||
BungeeCore.log(Level.SEVERE, ((InetSocketAddress) event.getSender().getSocketAddress()).getHostString() + " tried to send a plugin message with tag " + event.getTag());
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if(!event.getTag().equalsIgnoreCase("sw:bridge"))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
if(!(event.getSender() instanceof Server))
|
||||
return;
|
||||
|
||||
sender = ((Server) event.getSender()).getInfo();
|
||||
NetworkPacket.handle(event.getData());
|
||||
sender = null;
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2022 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
|
||||
@ -17,27 +17,22 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.comms.packets;
|
||||
package de.steamwar.bungeecore.network;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import de.steamwar.bungeecore.comms.BungeePacket;
|
||||
import de.steamwar.bungeecore.comms.PacketIdManager;
|
||||
import de.steamwar.network.packets.NetworkPacket;
|
||||
import lombok.SneakyThrows;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
public class LocaleInvalidationPacket extends BungeePacket {
|
||||
public class NetworkSender {
|
||||
|
||||
private int userId;
|
||||
|
||||
public LocaleInvalidationPacket(int userId) {
|
||||
this.userId = userId;
|
||||
@SneakyThrows
|
||||
public static void send(ProxiedPlayer player, NetworkPacket packet) {
|
||||
player.sendData("sw:bridge", packet.serialize());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return PacketIdManager.LOCALE_INVALIDATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeVars(ByteArrayDataOutput byteArrayDataOutput) {
|
||||
byteArrayDataOutput.writeInt(userId);
|
||||
public static void send(ServerInfo serverInfo, NetworkPacket packet) {
|
||||
ProxiedPlayer player = serverInfo.getPlayers().iterator().next();
|
||||
send(player, packet);
|
||||
}
|
||||
}
|
@ -17,19 +17,19 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.comms.handlers;
|
||||
package de.steamwar.bungeecore.network.handlers;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import de.steamwar.bungeecore.comms.SpigotHandler;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.network.packets.PacketHandler;
|
||||
import de.steamwar.network.packets.client.ExecuteCommandPacket;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
|
||||
public class ExecuteCommandHandler implements SpigotHandler {
|
||||
@Override
|
||||
public void handle(ByteArrayDataInput in, ServerInfo info) {
|
||||
SteamwarUser target = SteamwarUser.get(in.readInt());
|
||||
String command = in.readUTF();
|
||||
public class ExecuteCommandHandler extends PacketHandler {
|
||||
|
||||
@Handler
|
||||
public void handle(ExecuteCommandPacket packet) {
|
||||
SteamwarUser target = SteamwarUser.get(packet.getPlayerId());
|
||||
String command = packet.getCommand();
|
||||
|
||||
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getPlayer(target.getUuid()), command);
|
||||
}
|
@ -17,20 +17,18 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.comms.handlers;
|
||||
package de.steamwar.bungeecore.network.handlers;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import de.steamwar.bungeecore.ArenaMode;
|
||||
import de.steamwar.bungeecore.comms.SpigotHandler;
|
||||
import de.steamwar.bungeecore.comms.packets.FightEndsPacket;
|
||||
import de.steamwar.bungeecore.sql.*;
|
||||
import de.steamwar.network.packets.PacketHandler;
|
||||
import de.steamwar.network.packets.common.FightEndsPacket;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class FightEndsHandler implements SpigotHandler {
|
||||
public class FightEndsHandler extends PacketHandler {
|
||||
|
||||
private Map<String, LinkedList<Game>> gameModeGames = new HashMap<>();
|
||||
|
||||
@ -46,10 +44,8 @@ public class FightEndsHandler implements SpigotHandler {
|
||||
fightCounts.put("miniwargear", 3L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(ByteArrayDataInput in, ServerInfo info) {
|
||||
FightEndsPacket fightEndsPacket = new FightEndsPacket(in);
|
||||
|
||||
@Handler
|
||||
public void handle(FightEndsPacket fightEndsPacket) {
|
||||
if (!ArenaMode.getBySchemType(SchematicType.fromDB(fightEndsPacket.getGameMode())).isRanked()) {
|
||||
return;
|
||||
}
|
@ -17,12 +17,13 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.comms.handlers;
|
||||
package de.steamwar.bungeecore.network.handlers;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import de.steamwar.bungeecore.comms.SpigotHandler;
|
||||
import de.steamwar.bungeecore.comms.packets.FightInfoPacket;
|
||||
import de.steamwar.bungeecore.listeners.TablistManager;
|
||||
import de.steamwar.bungeecore.network.NetworkReceiver;
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
import de.steamwar.network.packets.PacketHandler;
|
||||
import de.steamwar.network.packets.common.FightInfoPacket;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
@ -30,7 +31,7 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
public class FightInfoHandler implements SpigotHandler {
|
||||
public class FightInfoHandler extends PacketHandler {
|
||||
|
||||
private static final Set<ServerInfo> lobbys = new HashSet<>();
|
||||
|
||||
@ -42,10 +43,11 @@ public class FightInfoHandler implements SpigotHandler {
|
||||
return lobbys.contains(player.getServer().getInfo());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(ByteArrayDataInput in, ServerInfo info) {
|
||||
FightInfoPacket packet = new FightInfoPacket(in);
|
||||
packet.setServerName(info.getName());
|
||||
@Handler
|
||||
public void handle(FightInfoPacket packet) {
|
||||
ServerInfo info = NetworkReceiver.sender;
|
||||
|
||||
FightInfoPacket lobbyPacket = packet.withServerName(info.getName());
|
||||
|
||||
TablistManager.newFightInfo(info, packet);
|
||||
|
||||
@ -58,7 +60,7 @@ public class FightInfoHandler implements SpigotHandler {
|
||||
continue;
|
||||
}
|
||||
|
||||
packet.send(it.next());
|
||||
NetworkSender.send(lobby, lobbyPacket);
|
||||
}
|
||||
}
|
||||
}
|
@ -17,16 +17,16 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.comms.handlers;
|
||||
package de.steamwar.bungeecore.network.handlers;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import de.steamwar.bungeecore.comms.SpigotHandler;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import de.steamwar.bungeecore.network.NetworkReceiver;
|
||||
import de.steamwar.network.packets.PacketHandler;
|
||||
import de.steamwar.network.packets.client.ImALobbyPacket;
|
||||
|
||||
public class ImALobbyHandler implements SpigotHandler {
|
||||
public class ImALobbyHandler extends PacketHandler {
|
||||
|
||||
@Override
|
||||
public void handle(ByteArrayDataInput in, ServerInfo info) {
|
||||
FightInfoHandler.addLobby(info);
|
||||
@Handler
|
||||
public void handle(ImALobbyPacket packet) {
|
||||
FightInfoHandler.addLobby(NetworkReceiver.sender);
|
||||
}
|
||||
}
|
@ -17,41 +17,42 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.comms.handlers;
|
||||
package de.steamwar.bungeecore.network.handlers;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.comms.SpigotHandler;
|
||||
import de.steamwar.bungeecore.comms.packets.CloseInventoryPacket;
|
||||
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.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;
|
||||
|
||||
public class InventoryCallbackHandler implements SpigotHandler {
|
||||
public class InventoryCallbackHandler extends PacketHandler {
|
||||
|
||||
public static final Map<Integer, SWInventory> inventoryHashMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void handle(ByteArrayDataInput in, ServerInfo info) {
|
||||
SteamwarUser owner = SteamwarUser.get(in.readInt());
|
||||
CallbackType type = CallbackType.valueOf(in.readUTF());
|
||||
@Handler
|
||||
public void handle(InventoryCallbackPacket packet) {
|
||||
SteamwarUser owner = SteamwarUser.get(packet.getOwner());
|
||||
InventoryCallbackPacket.CallbackType type = packet.getType();
|
||||
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 == CallbackType.CLICK) {
|
||||
new CloseInventoryPacket(owner.getId()).send(ProxyServer.getInstance().getPlayer(owner.getUuid()));
|
||||
if(type == InventoryCallbackPacket.CallbackType.CLICK) {
|
||||
NetworkSender.send(NetworkReceiver.sender, new CloseInventoryPacket(owner.getId()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(type == CallbackType.CLICK) {
|
||||
int pos = in.readInt();
|
||||
InvCallback.ClickType clickType = InvCallback.ClickType.valueOf(in.readUTF());
|
||||
if(type == InventoryCallbackPacket.CallbackType.CLICK) {
|
||||
int pos = packet.getPosition();
|
||||
InvCallback.ClickType clickType = InvCallback.ClickType.valueOf(packet.getClickType().name());
|
||||
inventoryHashMap.get(owner.getId()).handleCallback(clickType, pos);
|
||||
}else if(type == CallbackType.CLOSE) {
|
||||
}else if(type == InventoryCallbackPacket.CallbackType.CLOSE) {
|
||||
if(inventoryHashMap.get(owner.getId()).isNext()) {
|
||||
inventoryHashMap.get(owner.getId()).handleClose();
|
||||
return;
|
||||
@ -59,9 +60,4 @@ public class InventoryCallbackHandler implements SpigotHandler {
|
||||
inventoryHashMap.get(owner.getId()).setNext(true);
|
||||
}
|
||||
}
|
||||
|
||||
public enum CallbackType {
|
||||
CLICK,
|
||||
CLOSE,
|
||||
}
|
||||
}
|
@ -17,24 +17,24 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.comms.handlers;
|
||||
package de.steamwar.bungeecore.network.handlers;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import de.steamwar.bungeecore.ArenaMode;
|
||||
import de.steamwar.bungeecore.ServerStarter;
|
||||
import de.steamwar.bungeecore.comms.SpigotHandler;
|
||||
import de.steamwar.bungeecore.sql.SchematicType;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.network.packets.PacketHandler;
|
||||
import de.steamwar.network.packets.client.PrepareSchemPacket;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
public class PrepareSchemHandler implements SpigotHandler {
|
||||
@Override
|
||||
public void handle(ByteArrayDataInput in, ServerInfo info) {
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(in.readInt()).getUuid());
|
||||
int schematicID = in.readInt();
|
||||
ArenaMode mode = ArenaMode.getBySchemType(SchematicType.fromDB(in.readUTF()));
|
||||
public class PrepareSchemHandler extends PacketHandler {
|
||||
|
||||
@Handler
|
||||
public void handle(PrepareSchemPacket packet) {
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(packet.getPlayer()).getUuid());
|
||||
int schematicID = packet.getSchem();
|
||||
ArenaMode mode = ArenaMode.getBySchemType(SchematicType.fromDB(packet.getSchemType()));
|
||||
|
||||
new ServerStarter().test(mode, mode.getRandomMap(), player).prepare(schematicID).start();
|
||||
}
|
@ -115,7 +115,7 @@ public class Statement implements AutoCloseable {
|
||||
}
|
||||
|
||||
synchronized (connections) {
|
||||
connections.push(connection);
|
||||
connections.addLast(connection);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -23,9 +23,10 @@ import com.google.gson.JsonParser;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.commands.WebregisterCommand;
|
||||
import de.steamwar.bungeecore.comms.packets.LocaleInvalidationPacket;
|
||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.network.packets.server.LocaleInvalidationPacket;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.PendingConnection;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
@ -382,12 +383,12 @@ public class SteamwarUser {
|
||||
}
|
||||
|
||||
public void setLocale(Locale locale, boolean manualLocale) {
|
||||
if (this.manualLocale && !manualLocale)
|
||||
if (locale == null || (this.manualLocale && !manualLocale))
|
||||
return;
|
||||
|
||||
this.locale = locale;
|
||||
this.manualLocale = manualLocale;
|
||||
updateLocale.update(locale.toLanguageTag(), manualLocale, id);
|
||||
new LocaleInvalidationPacket(id).send(getPlayer());
|
||||
NetworkSender.send(getPlayer(), new LocaleInvalidationPacket(id));
|
||||
}
|
||||
}
|
||||
|
67
src/de/steamwar/bungeecore/util/Chat19.java
Normale Datei
67
src/de/steamwar/bungeecore/util/Chat19.java
Normale Datei
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2022 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.util;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.md_5.bungee.ServerConnection;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.protocol.PacketWrapper;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.packet.Chat;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
public class Chat19 extends Chat {
|
||||
|
||||
public static void chat(ProxiedPlayer p, String message) {
|
||||
if(p.getPendingConnection().getVersion() >= 759) {
|
||||
Chat19 packet = new Chat19(message);
|
||||
|
||||
ByteBuf buf = Unpooled.buffer();
|
||||
writeVarInt(0x04, buf);
|
||||
packet.write(buf, ProtocolConstants.Direction.TO_SERVER, p.getPendingConnection().getVersion());
|
||||
((ServerConnection) p.getServer()).getCh().write(new PacketWrapper(packet, buf));
|
||||
} else {
|
||||
p.chat(message);
|
||||
}
|
||||
}
|
||||
|
||||
private final Instant timestamp = Instant.now();
|
||||
private final long salt = 0L;
|
||||
private final byte[] signature = new byte[0];
|
||||
private final boolean signedPreview = false;
|
||||
|
||||
public Chat19 (String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
|
||||
if (direction == ProtocolConstants.Direction.TO_CLIENT || protocolVersion != 759)
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
writeString(getMessage(), buf);
|
||||
buf.writeLong(timestamp.toEpochMilli());
|
||||
buf.writeLong(salt);
|
||||
writeArray(signature, buf);
|
||||
buf.writeBoolean(signedPreview);
|
||||
}
|
||||
}
|
@ -13,6 +13,8 @@ STEAMWAR_BRAND=§eSteam§8War.de §7({0}) §r<- §e{1} §7({2})§r
|
||||
DEV_NO_SERVER=§cThe server is currently not available.
|
||||
DEV_UNKNOWN_SERVER=§cPlease specify a dev server.
|
||||
|
||||
DISABLED=§cCurrently disabled.
|
||||
|
||||
#ModLoader blocker
|
||||
MODLOADER_INSTALLED=§7You play with §e{0} §7client. Therefore you can't join arenas.
|
||||
MODLOADER_INSTALLED_FABRIC=§7You play with §e{0} §7client. You can only join arenas with the SteamWar Modsender installed.
|
||||
@ -210,7 +212,7 @@ BAU_MEMBER_TOGGLE_WORLD_EDIT = use WorldEdit
|
||||
BAU_MEMBER_TOGGLE_WORLD = change Settings
|
||||
|
||||
#ChallengeCommand
|
||||
CHALLENGE_USAGE=§8/§7challenge §8[§eSpieler§8]
|
||||
CHALLENGE_USAGE=§8/§7challenge §8[§eplayer§8]
|
||||
CHALLENGE_OFFLINE=§cThe challenged player isn't online.
|
||||
CHALLENGE_SELF=§cSchizophrenia?
|
||||
CHALLENGE_IGNORED=§cThe challenged player has blocked you.
|
||||
@ -292,7 +294,7 @@ HISTORIC_BROADCAST_HOVER=§afight against §7{1}
|
||||
JOIN_PLAYER_BLOCK=§cYou currently cannot follow this player.
|
||||
|
||||
#JoinmeCommand
|
||||
JOINME_USAGE=§8/§7join §8[§eSpieler§8].
|
||||
JOINME_USAGE=§8/§7join §8[§eplayer§8].
|
||||
JOINME_BROADCAST=§7Click §ehere§8 §7to join §e{0} §7on §e{1}§8!
|
||||
JOINME_BROADCAST_HOVER=§aJoin player
|
||||
JOINME_PLAYER_OFFLINE=§cThis player is offline.
|
||||
@ -614,7 +616,7 @@ RANK_NEEDED_FIGHTS_LEFT={0} §8(§e{1}§7 fights needed§8)
|
||||
|
||||
#Fabric Mod Sender
|
||||
MODIFICATION_BAN_MESSAGE=You tried to bypass / modify the FabricModSender!
|
||||
MODIFICATION_BAN_LOG={0} has tried to edit / bypass the FabricModSender!
|
||||
MODIFICATION_BAN_LOG={0} has tried to edit / bypass the FabricModSender! Reason: {1}
|
||||
MODIFICATION_CHECK_SUCCESS=§eYour mods have been checked and you are now allowed to join arenas!
|
||||
|
||||
#Arena Merging
|
||||
|
@ -10,6 +10,8 @@ INVALID_TIME=§cUngültige Zeitangabe.
|
||||
DEV_NO_SERVER=§cDer Server ist derzeit nicht erreichbar.
|
||||
DEV_UNKNOWN_SERVER=§cBitte gib einen DevServer an.
|
||||
|
||||
DISABLED=§cDerzeit deaktiviert.
|
||||
|
||||
#ModLoader blocker
|
||||
MODLOADER_INSTALLED=§7Du spielst mit §e{0} §7Client. Daher kannst du keinen Arenen beitreten.
|
||||
MODLOADER_INSTALLED_FABRIC=§7Du spielst mit §e{0} §7Client. Nur mit dem SteamWarModSender kannst du Arenen beitreten.
|
||||
@ -594,7 +596,7 @@ RANK_NEEDED_FIGHTS_LEFT={0} §8(§7noch §e{1}§7 Kämpfe nötig§8)
|
||||
|
||||
#Fabric Mod Sender
|
||||
MODIFICATION_BAN_MESSAGE=Du hast probiert den FabricModSender zu umgehen / zu modifizieren!
|
||||
MODIFICATION_BAN_LOG={0} hat probiert den Fabric Mod Sender zu editieren / umzugehen!
|
||||
MODIFICATION_BAN_LOG={0} hat probiert den Fabric Mod Sender zu editieren / umzugehen! Grund: {1}
|
||||
MODIFICATION_CHECK_SUCCESS=§eDeine Mods wurden geprüft und du darfst nun auf Arenen joinen!
|
||||
|
||||
#Arena Merging
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren