13
0

Network Update
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
Chaoscaot 2022-06-07 21:02:41 +02:00
Ursprung ef236311b0
Commit 24b974d032
7 geänderte Dateien mit 40 neuen und 21 gelöschten Zeilen

Datei anzeigen

@ -20,10 +20,8 @@
package de.steamwar.lobby;
import com.google.common.io.ByteArrayDataInput;
import de.steamwar.comms.BungeeReceiver;
import de.steamwar.comms.PacketIdManager;
import de.steamwar.comms.packets.FightInfoPacket;
import de.steamwar.lobby.portal.FightserverPortal;
import de.steamwar.network.packets.common.FightInfoPacket;
import org.bukkit.Bukkit;
import java.time.Instant;
@ -36,17 +34,15 @@ public class Fightserver {
private static final Map<String, Fightserver> servers = new HashMap<>();
public static void init() {
BungeeReceiver.registerHandler(PacketIdManager.FIGHT_INFO, Fightserver::newFightInfo);
Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), Fightserver::removeStopped, 20, 20);
}
private static void newFightInfo(ByteArrayDataInput in) {
FightInfoPacket fightInfo = new FightInfoPacket(in);
Fightserver server = servers.get(fightInfo.getServerName());
public static void newFightInfo(FightInfoPacket in) {
Fightserver server = servers.get(in.getServerName());
if (server == null) {
new Fightserver(fightInfo);
new Fightserver(in);
} else {
server.update(fightInfo);
server.update(in);
}
}

Datei anzeigen

@ -0,0 +1,18 @@
package de.steamwar.lobby;
import de.steamwar.network.packets.PacketHandler;
import de.steamwar.network.packets.common.FightInfoPacket;
public class LobbyPacketHandler extends PacketHandler {
public LobbyPacketHandler() {
super();
this.register();
}
@Handler
public void handleFightserver(FightInfoPacket packet) {
Fightserver.newFightInfo(packet);
}
}

Datei anzeigen

@ -68,6 +68,7 @@ public class LobbySystem extends JavaPlugin {
new AlphaWall(l -> l.getX() < 2977, AlphaWall.REFLECT_X);
new AlphaWall(l -> l.getZ() > 892, AlphaWall.REFLECT_Z);
new AlphaWall(l -> l.getZ() < 1794, AlphaWall.REFLECT_Z);
new LobbyPacketHandler();
}
@Override

Datei anzeigen

@ -19,19 +19,20 @@
package de.steamwar.lobby;
import com.google.common.io.ByteArrayDataInput;
import de.steamwar.comms.BungeeReceiver;
import de.steamwar.comms.PacketIdManager;
import de.steamwar.network.packets.PacketHandler;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.network.packets.server.StartingServerPacket;
import org.bukkit.Bukkit;
import org.bukkit.event.player.PlayerTeleportEvent;
public class WaitingHall {
public class WaitingHall extends PacketHandler {
public WaitingHall() {
BungeeReceiver.registerHandler(PacketIdManager.STARTING_SERVER, this::serverStarting);
super();
this.register();
}
private void serverStarting(ByteArrayDataInput in) {
Bukkit.getPlayer(SteamwarUser.get(in.readInt()).getUUID()).teleport(LobbySystem.config().getWaitingHallSpawn(), PlayerTeleportEvent.TeleportCause.PLUGIN);
@Handler
private void serverStarting(StartingServerPacket in) {
Bukkit.getPlayer(SteamwarUser.get(in.getUser()).getUUID()).teleport(LobbySystem.config().getWaitingHallSpawn(), PlayerTeleportEvent.TeleportCause.PLUGIN);
}
}

Datei anzeigen

@ -19,9 +19,10 @@
package de.steamwar.lobby.listener;
import de.steamwar.comms.packets.ImALobbyPacket;
import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.util.ItemBuilder;
import de.steamwar.network.NetworkSender;
import de.steamwar.network.packets.client.ImALobbyPacket;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
@ -57,7 +58,7 @@ public class PlayerSpawn extends BasicListener {
player.setFoodLevel(20);
giveItems(player);
Bukkit.getScheduler().runTaskLater(LobbySystem.getPlugin(), () -> new ImALobbyPacket().send(player), 20);
Bukkit.getScheduler().runTaskLater(LobbySystem.getPlugin(), () -> NetworkSender.send(new ImALobbyPacket()), 20);
}
private void giveItems(Player player) {

Datei anzeigen

@ -19,10 +19,12 @@
package de.steamwar.lobby.portal;
import de.steamwar.comms.packets.ExecuteCommandPacket;
import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.command.ModifyCommand;
import de.steamwar.lobby.listener.Portals;
import de.steamwar.network.NetworkSender;
import de.steamwar.network.packets.client.ExecuteCommandPacket;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@ -82,7 +84,7 @@ public class CommandPortal implements PortalHandler {
if(ModifyCommand.modifying(player))
player.sendMessage("/" + cmd);
new ExecuteCommandPacket(player, cmd.toString()).send(player);
NetworkSender.send(new ExecuteCommandPacket(SteamwarUser.get(player).getId(), cmd.toString()));
}
@Override

Datei anzeigen

@ -19,11 +19,11 @@
package de.steamwar.lobby.portal;
import de.steamwar.comms.packets.FightInfoPacket;
import de.steamwar.lobby.Fightserver;
import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.display.Hologram;
import de.steamwar.lobby.display.NPC;
import de.steamwar.network.packets.common.FightInfoPacket;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Location;
import org.bukkit.entity.Player;