Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various improvements #71

Merged
merged 73 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
f94cb25
removed net7.0 because it is no longer supported
Klotzi111 Aug 6, 2024
0fbead2
moved NLog.config to MineSharp.Bot project
Klotzi111 Aug 6, 2024
74e467b
added GameEvent enum to GameEventPacket
Klotzi111 Aug 6, 2024
afe79ce
fix wrong health value upon joining server
Klotzi111 Aug 6, 2024
440c5f4
added ReadLongArray and WriteLongArray to PacketBuffer
Klotzi111 Aug 6, 2024
ecfe3fe
add new packet types for sound effects and particles
Klotzi111 Aug 6, 2024
a93f369
moved EnableDebugLogs to helper class
Klotzi111 Aug 6, 2024
7fe2be3
fixed chunk data parsing by using DimensionInfo
Klotzi111 Aug 6, 2024
e5c466e
fixed entity velocity handling
Klotzi111 Aug 6, 2024
475deec
fix NRE when receiving chat message
Klotzi111 Aug 6, 2024
5c36016
improved Raycast method
Klotzi111 Aug 6, 2024
ae65fa5
fix world loading bugs
Klotzi111 Aug 6, 2024
17b6fb2
reworked packet send/receive and gamestate logic; improved bot cancel…
Klotzi111 Aug 6, 2024
60fb49b
removed net7.0 for test projects
Klotzi111 Aug 6, 2024
7b2ebc4
improved PacketBuffer by using MemoryMarshal
Klotzi111 Aug 6, 2024
66374f6
fixed negated condition bug in AABB.IntersectsLine
Klotzi111 Aug 6, 2024
51b0720
created RaycastBlockResult record
Klotzi111 Aug 6, 2024
c9674dc
improved exception handling in HandleIncomingPacket + small cleanup
Klotzi111 Aug 6, 2024
24cba92
made packet handler dictionaries thread-safe
Klotzi111 Aug 6, 2024
ece2a50
improvements to Plugin and OnPacketAfterInitialization
Klotzi111 Aug 7, 2024
af2bd44
refactoring in EncryptionHelper
Klotzi111 Aug 7, 2024
c52d768
overhauled PacketPalette and added IPacket.StaticType
Klotzi111 Aug 7, 2024
6bff9f5
removed unused and nonsensical block parameter on AsyncEvent
Klotzi111 Aug 7, 2024
ca42d38
added ConcurrentHashSet nuget to make AsyncEventBase thread-safe
Klotzi111 Aug 7, 2024
4a33568
refactored all Packet classes to be sealed records + serialization im…
Klotzi111 Aug 7, 2024
3f2e3cb
fixed race condition bug in HandleUpdateAttributesPacket
Klotzi111 Aug 7, 2024
d6e2705
removed unnessecary CryptoActionV19
Klotzi111 Aug 7, 2024
2c70c40
fixed bug when parsing dimension
Klotzi111 Aug 7, 2024
441a153
suppress exception when tcp stream ends
Klotzi111 Aug 7, 2024
01bd4fd
performance optimization experiments (does not really gain much)
Klotzi111 Aug 7, 2024
f9254c9
added back minecraft prefix for constant identifiers
Klotzi111 Aug 7, 2024
a7624d0
created Identifier type and added methods to PacketBuffer
Klotzi111 Aug 7, 2024
ff352e7
using the new Identifier type everywhere
Klotzi111 Aug 7, 2024
cb2c70e
fix race condition bug in WindowPlugin
Klotzi111 Aug 7, 2024
016dbb7
fix regex validation in Identifier type
Klotzi111 Aug 7, 2024
fa8b72a
fixed problem with mismatching Identifiers in RegistryData when on a …
Klotzi111 Aug 7, 2024
be8b6a8
made loggings structured in WindowPlugin
Klotzi111 Aug 7, 2024
032f343
moved MinecraftVersion, PacketBuffer and friends to Core.Serialization
Klotzi111 Aug 8, 2024
c062387
made Attribute and Modifier ISerializable
Klotzi111 Aug 8, 2024
87d1b5e
fixed bug in Identifier.Equals and added EqualsStrict
Klotzi111 Aug 8, 2024
b512ad3
improved exception message in Identifier.Parse
Klotzi111 Aug 8, 2024
6c33c6e
fixed Identifier parsing logic
Klotzi111 Aug 8, 2024
e8237b7
created and implemented IAsyncWorld
Klotzi111 Aug 8, 2024
6cf904b
using new async methods from IAsyncWorld to prevent race conditions
Klotzi111 Aug 8, 2024
2ec3399
fixed low chance race condition in AbstractWorld.RegisterChunkAwaiter
Klotzi111 Aug 8, 2024
1ad3dc9
improved Uuid type using MemoryMarshal
Klotzi111 Aug 8, 2024
7bd051c
added ReadPosition and WritePosition methods to PacketBuffer
Klotzi111 Aug 8, 2024
dff40b9
added error log to GetPacketType in case of exception
Klotzi111 Aug 8, 2024
371e336
fix rare deadlock when tcp stream ends
Klotzi111 Aug 8, 2024
9458e9e
add missing null check when translating text component
Klotzi111 Aug 8, 2024
ac4e6d3
fix bug in EnsureOnlyRunOnceAsync that causes faulted tasks not to pr…
Klotzi111 Aug 8, 2024
84fe1f3
Plugins can now handle cancellation while initializing (fixes deadlock)
Klotzi111 Aug 8, 2024
2e74a36
extracted ParsePacket method + added unread packet bytes warning
Klotzi111 Aug 8, 2024
8f5616b
fixed problem with weird disconnect (login) packet
Klotzi111 Aug 8, 2024
27c5a0f
added missing Packets - Part 1
Klotzi111 Aug 8, 2024
2261f53
fixed PacketBuffer.WriteVarLong
Klotzi111 Aug 9, 2024
bbb768e
added BitSet type
Klotzi111 Aug 10, 2024
ff5087b
fixed CombatDeathPacket
Klotzi111 Aug 10, 2024
2d65b50
added missing Packets - Part 2
Klotzi111 Aug 10, 2024
cef45a0
fixed reading and writing of BitSet
Klotzi111 Aug 10, 2024
422a804
replaced IVersionAwareSerializable with ISerializableWithMinecraftData
Klotzi111 Aug 10, 2024
35be4a0
added missing Packets - Part 3
Klotzi111 Aug 10, 2024
54214b0
added EntityMetadata type
Klotzi111 Aug 10, 2024
47bc369
add SetEntityMetadataPacket
Klotzi111 Aug 10, 2024
a7d5f21
fixed some race condition bugs within ChunkSection
Klotzi111 Aug 10, 2024
45c4eaf
added OnPacketReceived method
Klotzi111 Aug 10, 2024
1b2626e
made Position a readonly struct + removed MutablePosition
Klotzi111 Aug 10, 2024
a471039
fix race condition with bundled packets
Klotzi111 Aug 10, 2024
c35c761
fixed bug with receiving invalid disconnect (login) packet
Klotzi111 Aug 11, 2024
6f77541
added missing Packets - Part 4
Klotzi111 Aug 11, 2024
1249d37
fix exception from StatusResponsePacket handler in RequestServerStatus
Klotzi111 Aug 14, 2024
52fd5bc
removed now unused method HandleOutgoing in GameStatePacketHandler
Klotzi111 Aug 14, 2024
f09627a
fixed wrong player health upon joining
Klotzi111 Aug 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Components/MineSharp.Auth/MineSharp.Auth.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>12</LangVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,16 @@ protected override string GetRawMessage(MinecraftData? data)
var with = With.Select(x => x.GetMessage(data)).ToArray();
if (data == null)
{
Logger.Warn("Cannot translate message because no minecraft data was provided!");
Logger.Warn("Cannot translate message because no minecraft data was provided! For: {TranslationKey}", Translation);
return string.Join(' ', with);
}

var rule = data.Language.GetTranslation(Translation)!;
if (rule == null)
{
Logger.Warn("Cannot translate message because no translation string was found! For: {TranslationKey}", Translation);
return string.Join(' ', with);
}
return TranslateString(rule, with);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TargetFrameworks>net8.0;net7.0</TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageReadmeFile>README.md</PackageReadmeFile>

Expand Down
5 changes: 3 additions & 2 deletions Components/MineSharp.Commands/CommandTree.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using MineSharp.Commands.Parser;
using MineSharp.Core;
using MineSharp.Core.Common;
using MineSharp.Core.Serialization;
using MineSharp.Data;

namespace MineSharp.Commands;
Expand Down Expand Up @@ -74,12 +75,12 @@ private static CommandNode ReadNode(PacketBuffer buffer, MinecraftData data)
return null;
}

string name;
Identifier name;

if (data.Version.Protocol < ProtocolVersion.V_1_19)
{
// in 1.18.x, the parser was specified by its name.
name = buffer.ReadString();
name = buffer.ReadIdentifier();
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Components/MineSharp.Commands/MineSharp.Commands.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<AssemblyName>MineSharp.Commands</AssemblyName>
<RootNamespace>MineSharp.Commands</RootNamespace>
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>12</LangVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand Down
7 changes: 5 additions & 2 deletions Components/MineSharp.Commands/Parser/BlockPositionParser.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
using MineSharp.Core.Common;
using MineSharp.Core.Serialization;
using MineSharp.Data;

namespace MineSharp.Commands.Parser;

public class BlockPositionParser : IParser
{
public string GetName()
public static readonly Identifier BlockPosIdentifier = Identifier.Parse("minecraft:block_pos");

public Identifier GetName()
{
return "minecraft:block_pos";
return BlockPosIdentifier;
}

public int GetArgumentCount()
Expand Down
7 changes: 5 additions & 2 deletions Components/MineSharp.Commands/Parser/ColumnPosParser.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
using MineSharp.Core.Common;
using MineSharp.Core.Serialization;
using MineSharp.Data;

namespace MineSharp.Commands.Parser;

public class ColumnPosParser : IParser
{
public string GetName()
public static readonly Identifier ColumnPosIdentifier = Identifier.Parse("minecraft:column_pos");

public Identifier GetName()
{
return "minecraft:column_pos";
return ColumnPosIdentifier;
}

public int GetArgumentCount()
Expand Down
7 changes: 5 additions & 2 deletions Components/MineSharp.Commands/Parser/DoubleParser.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
using MineSharp.Core.Common;
using MineSharp.Core.Serialization;
using MineSharp.Data;

namespace MineSharp.Commands.Parser;

public class DoubleParser : IParser
{
public static readonly Identifier BrigadierDoubleIdentifier = Identifier.Parse("brigadier:double");

public double Min { get; private set; }
public double Max { get; private set; }

public string GetName()
public Identifier GetName()
{
return "brigadier:double";
return BrigadierDoubleIdentifier;
}

public int GetArgumentCount()
Expand Down
5 changes: 3 additions & 2 deletions Components/MineSharp.Commands/Parser/EmptyParser.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using MineSharp.Core.Common;
using MineSharp.Core.Serialization;
using MineSharp.Data;

namespace MineSharp.Commands.Parser;

public class EmptyParser : IParser
{
public string GetName()
public Identifier GetName()
{
return string.Empty;
return Identifier.Empty;
}

public int GetArgumentCount()
Expand Down
7 changes: 5 additions & 2 deletions Components/MineSharp.Commands/Parser/EntityParser.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
using MineSharp.Core.Common;
using MineSharp.Core.Serialization;
using MineSharp.Data;

namespace MineSharp.Commands.Parser;

public class EntityParser : IParser
{
public static readonly Identifier EntityIdentifier = Identifier.Parse("minecraft:entity");

public byte Flags { get; private set; }

public string GetName()
public Identifier GetName()
{
return "minecraft:entity";
return EntityIdentifier;
}

public int GetArgumentCount()
Expand Down
7 changes: 5 additions & 2 deletions Components/MineSharp.Commands/Parser/FloatParser.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
using MineSharp.Core.Common;
using MineSharp.Core.Serialization;
using MineSharp.Data;

namespace MineSharp.Commands.Parser;

public class FloatParser : IParser
{
public static readonly Identifier BrigadierFloatIdentifier = Identifier.Parse("brigadier:float");

public float Min { get; private set; }
public float Max { get; private set; }

public string GetName()
public Identifier GetName()
{
return "brigadier:float";
return BrigadierFloatIdentifier;
}

public int GetArgumentCount()
Expand Down
3 changes: 2 additions & 1 deletion Components/MineSharp.Commands/Parser/IParser.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using MineSharp.Core.Common;
using MineSharp.Core.Serialization;
using MineSharp.Data;

namespace MineSharp.Commands.Parser;

public interface IParser
{
public string GetName();
public Identifier GetName();
public int GetArgumentCount();

public void ReadProperties(PacketBuffer buffer, MinecraftData data);
Expand Down
7 changes: 5 additions & 2 deletions Components/MineSharp.Commands/Parser/IntegerParser.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
using MineSharp.Core.Common;
using MineSharp.Core.Serialization;
using MineSharp.Data;

namespace MineSharp.Commands.Parser;

public class IntegerParser : IParser
{
public static readonly Identifier BrigadierIntegerIdentifier = Identifier.Parse("brigadier:integer");

public int Min { get; private set; }
public int Max { get; private set; }

public string GetName()
public Identifier GetName()
{
return "brigadier:integer";
return BrigadierIntegerIdentifier;
}

public int GetArgumentCount()
Expand Down
7 changes: 5 additions & 2 deletions Components/MineSharp.Commands/Parser/LongParser.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
using MineSharp.Core.Common;
using MineSharp.Core.Serialization;
using MineSharp.Data;

namespace MineSharp.Commands.Parser;

public class LongParser : IParser
{
public static readonly Identifier BrigadierLongIdentifier = Identifier.Parse("brigadier:long");

public long Min { get; private set; }
public long Max { get; private set; }

public string GetName()
public Identifier GetName()
{
return "brigadier:long";
return BrigadierLongIdentifier;
}

public int GetArgumentCount()
Expand Down
7 changes: 5 additions & 2 deletions Components/MineSharp.Commands/Parser/MessageParser.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
using MineSharp.Core.Common;
using MineSharp.Core.Serialization;
using MineSharp.Data;

namespace MineSharp.Commands.Parser;

public class MessageParser : IParser
{
public string GetName()
public static readonly Identifier MessageIdentifier = Identifier.Parse("minecraft:message");

public Identifier GetName()
{
return "minecraft:message";
return MessageIdentifier;
}

public int GetArgumentCount()
Expand Down
Loading