Skip to content

Commit 8722d19

Browse files
authored
Server refactor (#484)
1 parent de19806 commit 8722d19

File tree

573 files changed

+34381
-4918
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

573 files changed

+34381
-4918
lines changed

.github/workflows/dotnet.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: .NET Build
22

33
on:
4+
workflow_dispatch:
45
push:
56
branches: [ 1.* ]
67
paths:
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Obsidian.API.Utilities;
2+
3+
namespace Obsidian.API.ChunkData;
4+
public abstract class DataContainer<T>
5+
{
6+
public bool IsEmpty { get; }
7+
public byte BitsPerEntry => (byte)DataArray.BitsPerEntry;
8+
9+
public abstract IPalette<T> Palette { get; internal set; }
10+
11+
internal abstract DataArray DataArray { get; private protected set; }
12+
13+
public virtual int GetIndex(int x, int y, int z) => (y << this.BitsPerEntry | z) << this.BitsPerEntry | x;
14+
15+
public void GrowDataArray()
16+
{
17+
if (Palette.BitCount <= DataArray.BitsPerEntry)
18+
return;
19+
20+
DataArray = DataArray.Grow(Palette.BitCount);
21+
}
22+
23+
public abstract void Set(int x, int y, int z, T blockState);
24+
25+
public abstract T Get(int x, int y, int z);
26+
27+
public abstract void WriteTo(INetStreamWriter writer);
28+
29+
public abstract DataContainer<T> Clone();
30+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace Obsidian.API.ChunkData;
2+
3+
public interface IBlockUpdate
4+
{
5+
public IBlock? Block { get; set; }
6+
7+
public IWorld World { get; }
8+
public Vector Position { get; set; }
9+
10+
public int Delay { get; set; }
11+
public int DelayCounter { get; set; }
12+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
namespace Obsidian.API.ChunkData;
2+
public interface IChunkSection
3+
{
4+
public int? YBase { get; }
5+
6+
public DataContainer<IBlock> BlockStateContainer { get; }
7+
public DataContainer<Biome> BiomeContainer { get; }
8+
9+
public bool HasSkyLight { get; }
10+
public ReadOnlyMemory<byte> SkyLightArray { get; }
11+
12+
public bool HasBlockLight { get; }
13+
public ReadOnlyMemory<byte> BlockLightArray { get; }
14+
15+
public bool IsEmpty { get; }
16+
17+
public IBlock GetBlock(Vector position);
18+
public IBlock GetBlock(int x, int y, int z);
19+
20+
public Biome GetBiome(Vector position);
21+
public Biome GetBiome(int x, int y, int z);
22+
23+
public void SetBlock(Vector position, IBlock block);
24+
public void SetBlock(int x, int y, int z, IBlock block);
25+
26+
public void SetBiome(Vector position, Biome biome);
27+
public void SetBiome(int x, int y, int z, Biome biome);
28+
29+
public void SetLightLevel(Vector position, LightType lt, int level);
30+
public void SetLightLevel(int x, int y, int z, LightType lt, int level);
31+
32+
public int GetLightLevel(Vector position, LightType lt);
33+
public int GetLightLevel(int x, int y, int z, LightType lt);
34+
35+
36+
public void SetLight(byte[] data, LightType lt);
37+
public IChunkSection Clone();
38+
}

Obsidian/ChunkData/IPalette.cs renamed to Obsidian.API/ChunkData/IPalette.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using Obsidian.Net;
2-
3-
namespace Obsidian.ChunkData;
4-
1+
namespace Obsidian.API.ChunkData;
52
public interface IPalette<T>
63
{
74
public int[] Values { get; }

Obsidian/Commands/Framework/Entities/Command.cs renamed to Obsidian.API/Commands/Command.cs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
using Microsoft.Extensions.DependencyInjection;
2-
using Microsoft.Extensions.Logging;
2+
using Obsidian.API.Commands.Exceptions;
3+
using Obsidian.API.Plugins;
34
using Obsidian.API.Utilities;
4-
using Obsidian.Commands.Framework.Exceptions;
5-
using Obsidian.Plugins;
6-
using Obsidian.Utilities.Interfaces;
5+
using Obsidian.API.Utilities.Interfaces;
76
using System.Diagnostics.CodeAnalysis;
87
using System.Reflection;
98

10-
namespace Obsidian.Commands.Framework.Entities;
11-
9+
namespace Obsidian.API.Commands;
1210
public sealed class Command
1311
{
14-
internal CommandIssuers AllowedIssuers { get; init; }
15-
16-
private ILogger? Logger => this.CommandHandler.logger;
12+
public CommandIssuers AllowedIssuers { get; init; }
1713

18-
public required CommandHandler CommandHandler { get; init; }
19-
public required PluginContainer? PluginContainer { get; init; }
14+
public required ICommandHandler CommandHandler { get; init; }
15+
public required IPluginContainer? PluginContainer { get; init; }
2016
public required string Name { get; init; }
2117

2218
public string[] Aliases { get; init; } = [];
@@ -85,7 +81,7 @@ public async Task ExecuteAsync(CommandContext context, string[] args)
8581
{
8682
await context.Sender.SendMessageAsync(ChatMessage.Simple($"Correct usage: {Usage}", ChatColor.Red));
8783
return;
88-
}
84+
}
8985

9086
await this.ExecuteAsync(executor, context, args);
9187
}

Obsidian/Commands/Framework/Entities/CommandSender.cs renamed to Obsidian.API/Commands/CommandSender.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
using Microsoft.Extensions.Logging;
2-
3-
namespace Obsidian.Commands.Framework.Entities;
4-
5-
public class CommandSender(CommandIssuers issuer, IPlayer? player, ILogger logger) : ICommandSender
1+
namespace Obsidian.API.Commands;
2+
public class CommandSender(CommandIssuers issuer, IPlayer? player) : ICommandSender
63
{
7-
private readonly ILogger logger = logger;
8-
94
public IPlayer? Player { get; } = player;
105
public CommandIssuers Issuer { get; } = issuer;
116

@@ -22,8 +17,6 @@ public async Task SendMessageAsync(ChatMessage message)
2217
var messageString = message.Text;
2318
foreach (var extra in message.GetExtras())
2419
messageString += extra.Text;
25-
26-
this.logger.LogInformation("{message}", messageString);
2720
}
2821

2922
public Task SendMessageAsync(ChatMessage message, Guid sender) => throw new NotImplementedException();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Obsidian.API.Commands.Exceptions;
2+
3+
public class CommandArgumentParsingException : Exception
4+
{
5+
public CommandArgumentParsingException(string message) : base(message)
6+
{
7+
8+
}
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Obsidian.API.Commands.Exceptions;
2+
3+
public class CommandExecutionCheckException : Exception
4+
{
5+
public CommandExecutionCheckException(string message) : base(message)
6+
{
7+
8+
}
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Obsidian.API.Commands.Exceptions;
2+
3+
public class CommandNotFoundException : Exception
4+
{
5+
public CommandNotFoundException(string message) : base(message)
6+
{
7+
8+
}
9+
}

0 commit comments

Comments
 (0)