Add support for creating replay mod capture files (#1246)

* Add test replay handler
* Fix incorrect built raw packet
* Fix incorrect built raw packet
* Add filter
* Add not working zip lib
* Add dotNetZip lib and complete basic function
* Update ReplayHandler.cs
* Complete Replay handler
Without client player handling
* Complete replay mod
- New ChatBot OnNetworkPacket event
* Add auto-backup and command for Replay Mod
* Add ReplayMod description to readme
* Small naming changes, fix compile error on .NET4.0
* ReplayHandler slight optimizations
Use Path.Combine to automatically use Windows '\' or Linux '/'
Move re-usable common parts outside the Replay handler
Small optimizations in building JSON strings
Co-authored-by: ORelio <oreliogitantispam.l0gin@spamgourmet.com>
This commit is contained in:
ReinforceZwei 2020-09-07 03:51:42 +08:00 committed by GitHub
parent cd1badb9d6
commit 7e20e409a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
47 changed files with 32732 additions and 21 deletions

View file

@ -354,6 +354,18 @@ namespace MinecraftClient
/// <param name="protocolversion">Ptotocol version</param>
public virtual void OnEntityMetadata(Entity entity, Dictionary<int, object> metadata) { }
/// <summary>
/// Called when a network packet received or sent
/// </summary>
/// <remarks>
/// You need to enable this event by calling <see cref="SetNetworkPacketEventEnabled(bool)"/> with True before you can use this event
/// </remarks>
/// <param name="packetID">Packet ID</param>
/// <param name="packetData">A copy of Packet Data</param>
/// <param name="isLogin">The packet is login phase or playing phase</param>
/// <param name="isInbound">The packet is received from server or sent by client</param>
public virtual void OnNetworkPacket(int packetID, List<byte> packetData, bool isLogin, bool isInbound) { }
/* =================================================================== */
/* ToolBox - Methods below might be useful while creating your bot. */
/* You should not need to interact with other classes of the program. */
@ -1286,6 +1298,27 @@ namespace MinecraftClient
else return false;
}
/// <summary>
/// Enable or disable network packet event calling. If you want to capture every packet including login phase, please enable this in <see cref="Initialize()"/>
/// </summary>
/// <remarks>
/// Enable this may increase memory usage.
/// </remarks>
/// <param name="enabled"></param>
protected void SetNetworkPacketEventEnabled(bool enabled)
{
Handler.SetNetworkPacketCaptureEnabled(enabled);
}
/// <summary>
/// Get the minecraft protcol number currently in use
/// </summary>
/// <returns>Protcol number</returns>
protected int GetProtocolVersion()
{
return Handler.GetProtocolVersion();
}
/// <summary>
/// Command runner definition.
/// Returned string will be the output of the command