mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Refactored to share the new utilities between the MCP and the Chat Bot API
This commit is contained in:
parent
a88ca3cb71
commit
dfef24ad10
12 changed files with 2225 additions and 1027 deletions
63
MinecraftClient/Scripting/MccGameResult.cs
Normal file
63
MinecraftClient/Scripting/MccGameResult.cs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
using System;
|
||||
|
||||
namespace MinecraftClient.Scripting;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the outcome of a shared MCC game operation.
|
||||
/// </summary>
|
||||
public class MccGameResult
|
||||
{
|
||||
public bool Success { get; init; }
|
||||
public string? ErrorCode { get; init; }
|
||||
public string? Message { get; init; }
|
||||
|
||||
public static MccGameResult Ok(string? message = null)
|
||||
{
|
||||
return new MccGameResult
|
||||
{
|
||||
Success = true,
|
||||
Message = message
|
||||
};
|
||||
}
|
||||
|
||||
public static MccGameResult Fail(string errorCode, string? message = null)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrEmpty(errorCode);
|
||||
return new MccGameResult
|
||||
{
|
||||
Success = false,
|
||||
ErrorCode = errorCode,
|
||||
Message = message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the outcome of a shared MCC game operation with typed payload data.
|
||||
/// </summary>
|
||||
public sealed class MccGameResult<T> : MccGameResult
|
||||
{
|
||||
public T? Data { get; init; }
|
||||
|
||||
public static MccGameResult<T> Ok(T? data, string? message = null)
|
||||
{
|
||||
return new MccGameResult<T>
|
||||
{
|
||||
Success = true,
|
||||
Data = data,
|
||||
Message = message
|
||||
};
|
||||
}
|
||||
|
||||
public static MccGameResult<T> Fail(string errorCode, string? message = null, T? data = default)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrEmpty(errorCode);
|
||||
return new MccGameResult<T>
|
||||
{
|
||||
Success = false,
|
||||
ErrorCode = errorCode,
|
||||
Message = message,
|
||||
Data = data
|
||||
};
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue