Merge pull request 'Better replay debugging with skipping' (#331) from betterReplayDebug into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #331 Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
Commit
5350ee6e21
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.fightsystem.commands;
|
package de.steamwar.fightsystem.commands;
|
||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
|
import de.steamwar.fightsystem.record.PacketProcessor;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -40,7 +41,11 @@ public class SkipCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if(PacketProcessor.isReplaying()) {
|
||||||
|
PacketProcessor.currentReplay().skipToSubtitle();
|
||||||
|
} else {
|
||||||
Commands.toggleSkip(player);
|
Commands.toggleSkip(player);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,22 +45,22 @@ import org.bukkit.scheduler.BukkitTask;
|
|||||||
|
|
||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class PacketProcessor {
|
public class PacketProcessor {
|
||||||
|
|
||||||
|
private static final World world = Bukkit.getWorlds().get(0);
|
||||||
|
|
||||||
static boolean replaying = false;
|
private static PacketProcessor currentProcessor = null;
|
||||||
|
|
||||||
public static boolean isReplaying(){
|
public static PacketProcessor currentReplay() {
|
||||||
return replaying;
|
return currentProcessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final World world = Bukkit.getWorlds().get(0);
|
public static boolean isReplaying(){
|
||||||
|
return currentProcessor != null;
|
||||||
|
}
|
||||||
|
|
||||||
private final PacketParser[] packetDecoder = new PacketParser[256];
|
private final PacketParser[] packetDecoder = new PacketParser[256];
|
||||||
|
|
||||||
@ -76,12 +76,14 @@ public class PacketProcessor {
|
|||||||
private int arenaMinY = Config.BluePasteRegion.getMinY();
|
private int arenaMinY = Config.BluePasteRegion.getMinY();
|
||||||
private int arenaMinZ = Config.ArenaRegion.getMinZ();
|
private int arenaMinZ = Config.ArenaRegion.getMinZ();
|
||||||
|
|
||||||
|
private boolean skipToSubtitle = false;
|
||||||
|
|
||||||
private boolean tickFinished = false;
|
private boolean tickFinished = false;
|
||||||
private int lastPacket = -1;
|
private final List<Integer> lastPackets = new LinkedList<>();
|
||||||
|
|
||||||
public PacketProcessor(PacketSource source){
|
public PacketProcessor(PacketSource source){
|
||||||
this.source = source;
|
this.source = source;
|
||||||
replaying = true;
|
currentProcessor = this;
|
||||||
|
|
||||||
packetDecoder[0x00] = this::playerJoins;
|
packetDecoder[0x00] = this::playerJoins;
|
||||||
packetDecoder[0x01] = this::entityMoves;
|
packetDecoder[0x01] = this::entityMoves;
|
||||||
@ -134,6 +136,10 @@ public class PacketProcessor {
|
|||||||
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::process, 1, 1);
|
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::process, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void skipToSubtitle() {
|
||||||
|
skipToSubtitle = true;
|
||||||
|
}
|
||||||
|
|
||||||
private void winMessage() throws IOException {
|
private void winMessage() throws IOException {
|
||||||
byte team = source.readByte();
|
byte team = source.readByte();
|
||||||
Message message = readMessage();
|
Message message = readMessage();
|
||||||
@ -455,6 +461,7 @@ public class PacketProcessor {
|
|||||||
String subtitle = source.readUTF();
|
String subtitle = source.readUTF();
|
||||||
|
|
||||||
FightUI.addSubtitle("OLD_STRING", subtitle);
|
FightUI.addSubtitle("OLD_STRING", subtitle);
|
||||||
|
skipToSubtitle = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printWin() throws IOException {
|
private void printWin() throws IOException {
|
||||||
@ -472,7 +479,7 @@ public class PacketProcessor {
|
|||||||
freezer.disable();
|
freezer.disable();
|
||||||
FightSystem.getMessage().broadcast("REPLAY_ENDS");
|
FightSystem.getMessage().broadcast("REPLAY_ENDS");
|
||||||
FightState.setFightState(FightState.SPECTATE);
|
FightState.setFightState(FightState.SPECTATE);
|
||||||
replaying = false;
|
currentProcessor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bow() throws IOException {
|
private void bow() throws IOException {
|
||||||
@ -498,7 +505,7 @@ public class PacketProcessor {
|
|||||||
|
|
||||||
private void tick(){
|
private void tick(){
|
||||||
execSync(REntity::tickFire);
|
execSync(REntity::tickFire);
|
||||||
if(!source.async())
|
if(!source.async() && !skipToSubtitle)
|
||||||
tickFinished = true;
|
tickFinished = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,16 +518,18 @@ public class PacketProcessor {
|
|||||||
if(parser != null){
|
if(parser != null){
|
||||||
parser.process();
|
parser.process();
|
||||||
}else{
|
}else{
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Unknown packet " + packetType + " recieved, closing. LastPacket: " + lastPacket);
|
Bukkit.getLogger().log(Level.SEVERE, "Unknown packet " + packetType + " recieved, closing. LastPacket: " + Arrays.toString(lastPackets.toArray()));
|
||||||
source.close();
|
source.close();
|
||||||
}
|
}
|
||||||
lastPacket = packetType;
|
lastPackets.add(packetType);
|
||||||
|
if (lastPackets.size() > 10)
|
||||||
|
lastPackets.remove(0);
|
||||||
}
|
}
|
||||||
} catch (EOFException e) {
|
} catch (EOFException e) {
|
||||||
Bukkit.getLogger().log(Level.INFO, "The FightServer is offline");
|
Bukkit.getLogger().log(Level.INFO, "The FightServer is offline");
|
||||||
source.close();
|
source.close();
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Could not recieve packet, LastPacket: " + lastPacket, e);
|
Bukkit.getLogger().log(Level.WARNING, "Could not recieve packet, LastPacket: " + Arrays.toString(lastPackets.toArray()), e);
|
||||||
source.close();
|
source.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren