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

Fixes #426 #428

Merged
merged 5 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions Obsidian.API/_Interfaces/IServerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ public interface IServerConfiguration
/// </summary>
public RconConfig? Rcon { get; set; }

/// <summary>
/// The view distance of the server.
/// </summary>
/// <remarks>
/// Players with higher view distance will use the server's view distance.
/// </remarks>
public byte ViewDistance { get; set; }

public List<string> WhitelistedIPs { get; set; }
public List<WhitelistedPlayer> Whitelisted { get; set; }
}
2 changes: 1 addition & 1 deletion Obsidian/Net/Packets/ClientInformationPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async ValueTask HandleAsync(Server server, Player player)
player.ClientInformation = new()
{
Locale = this.Locale,
ViewDistance = this.ViewDistance,
ViewDistance = sbyte.Min(ViewDistance, (sbyte) server.Configuration.ViewDistance),
ChatMode = this.ChatMode,
ChatColors = this.ChatColors,
DisplayedSkinParts = this.DisplayedSkinParts,
Expand Down
11 changes: 11 additions & 0 deletions Obsidian/Utilities/ServerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public sealed class ServerConfiguration : IServerConfiguration

public bool AllowLan { get; set; } = true; // Enabled because it's super useful for debugging tbh

public byte ViewDistance
{
get => viewDistance;
set => viewDistance = value >= MinimumViewDistance ? value : MinimumViewDistance;
}

public int PregenerateChunkRange { get; set; } = 15; // by default, pregenerate range from -15 to 15

[JsonConverter(typeof(JsonStringEnumConverter))]
Expand All @@ -64,6 +70,11 @@ public sealed class ServerConfiguration : IServerConfiguration
public ServerListQuery ServerListQuery { get; set; } = ServerListQuery.Full;

public int TimeTickSpeedMultiplier { get; set; } = 1;

private byte viewDistance = 10;

// Anything lower than 3 will cause weird artifacts on the client.
private const byte MinimumViewDistance = 3;
}

public sealed class ServerWorld
Expand Down
Loading