// Generated by `wit-bindgen` 0.57.1. DO NOT EDIT! // #nullable enable namespace PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0; public interface IServerImports { /** * Represents the difficulty setting of a Minecraft server. */ public enum Difficulty { PEACEFUL, EASY, NORMAL, HARD } /** * Represents the three main Minecraft dimensions. */ public enum Dimension { OVERWORLD, NETHER, END } public class CommandSender { public readonly byte Tag; private readonly object? value; private CommandSender(byte tag, object? value) { this.Tag = tag; this.value = value; } public static CommandSender Console() { return new CommandSender(Tags.Console, null); } public static CommandSender Player(global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IPlayerImports.Player player) { return new CommandSender(Tags.Player, player); } public global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IPlayerImports.Player AsPlayer { get { if (Tag == Tags.Player) return (global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IPlayerImports.Player)value!; else throw new global::System.ArgumentException("expected Player, got " + Tag); } } public class Tags { public const byte Console = 0; public const byte Player = 1; } } /** * Represents the global server instance. */ public class Server: global::System.IDisposable { internal int Handle { get; set; } public readonly record struct THandle(int Handle); public Server(THandle handle) { Handle = handle.Handle; } public void Dispose() { Dispose(true); } [global::System.Runtime.InteropServices.DllImportAttribute("pumpkin:plugin/server@0.1.0", EntryPoint = "[resource-drop]server"), global::System.Runtime.InteropServices.WasmImportLinkageAttribute] private static extern void wasmImportResourceDrop(int p0); protected virtual void Dispose(bool disposing) { if (disposing && Handle != 0) { wasmImportResourceDrop(Handle); Handle = 0; } } public unsafe global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IServerImports.Difficulty GetDifficulty() { var handle = this.Handle; var result = ServerImportsInterop.Server.GetDifficultyWasmInterop.wasmImportGetDifficulty(handle); return (global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IServerImports.Difficulty)result; } public unsafe uint GetPlayerCount() { var handle = this.Handle; var result = ServerImportsInterop.Server.GetPlayerCountWasmInterop.wasmImportGetPlayerCount(handle); return unchecked((uint)(result)); } public unsafe double GetMspt() { var handle = this.Handle; var result = ServerImportsInterop.Server.GetMsptWasmInterop.wasmImportGetMspt(handle); return result; } public unsafe double GetTps() { var handle = this.Handle; var result = ServerImportsInterop.Server.GetTpsWasmInterop.wasmImportGetTps(handle); return result; } public unsafe global::System.Collections.Generic.List GetAllPlayers() { var handle = this.Handle; var retArea = stackalloc uint[3]; var ptr = (nint)MemoryHelper.AlignStackPtr(retArea, 4); ServerImportsInterop.Server.GetAllPlayersWasmInterop.wasmImportGetAllPlayers(handle, ptr); var array = new global::System.Collections.Generic.List(new global::System.Span((void*)((byte*)ptr + 4), 1)[0]); for (int index = 0; index < new global::System.Span((void*)((byte*)ptr + 4), 1)[0]; ++index) { nint basePtr = new global::System.Span((void*)((byte*)ptr + 0), 1)[0] + (index * 4); var resource = new global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IPlayerImports.Player(new global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IPlayerImports.Player.THandle(new global::System.Span((void*)((byte*)basePtr + 0), 1)[0])); array.Add(resource); } if (new global::System.Span((void*)((byte*)ptr + 4), 1)[0] > 0) { global::System.Runtime.InteropServices.NativeMemory.Free((void*)new global::System.Span((void*)((byte*)ptr + 0), 1)[0]); } return array; } public unsafe global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IPlayerImports.Player? GetPlayerByName(string name) { var cleanups = new global::System.Collections.Generic.List(); var handle = this.Handle; var utf8Bytes = global::System.Text.Encoding.UTF8.GetBytes(name); var length = utf8Bytes.Length; var gcHandle = global::System.Runtime.InteropServices.GCHandle.Alloc(utf8Bytes, global::System.Runtime.InteropServices.GCHandleType.Pinned); var strPtr = gcHandle.AddrOfPinnedObject(); cleanups.Add(()=> gcHandle.Free()); var retArea = stackalloc uint[3]; var ptr = (nint)MemoryHelper.AlignStackPtr(retArea, 4); ServerImportsInterop.Server.GetPlayerByNameWasmInterop.wasmImportGetPlayerByName(handle, strPtr.ToInt32(), length, ptr); global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IPlayerImports.Player? lifted; switch (new global::System.Span((byte*)ptr + 0, 1)[0]) { case 0: { lifted = null; break; } case 1: { var resource = new global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IPlayerImports.Player(new global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IPlayerImports.Player.THandle(new global::System.Span((void*)((byte*)ptr + 4), 1)[0])); lifted = resource; break; } default: throw new global::System.ArgumentException("invalid discriminant: " + (new global::System.Span((byte*)ptr + 0, 1)[0])); } foreach (var cleanup in cleanups) { cleanup(); } return lifted; } public unsafe global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IPlayerImports.Player? GetPlayerByUuid(string id) { var cleanups = new global::System.Collections.Generic.List(); var handle = this.Handle; var utf8Bytes = global::System.Text.Encoding.UTF8.GetBytes(id); var length = utf8Bytes.Length; var gcHandle = global::System.Runtime.InteropServices.GCHandle.Alloc(utf8Bytes, global::System.Runtime.InteropServices.GCHandleType.Pinned); var strPtr = gcHandle.AddrOfPinnedObject(); cleanups.Add(()=> gcHandle.Free()); var retArea = stackalloc uint[3]; var ptr = (nint)MemoryHelper.AlignStackPtr(retArea, 4); ServerImportsInterop.Server.GetPlayerByUuidWasmInterop.wasmImportGetPlayerByUuid(handle, strPtr.ToInt32(), length, ptr); global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IPlayerImports.Player? lifted; switch (new global::System.Span((byte*)ptr + 0, 1)[0]) { case 0: { lifted = null; break; } case 1: { var resource = new global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IPlayerImports.Player(new global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IPlayerImports.Player.THandle(new global::System.Span((void*)((byte*)ptr + 4), 1)[0])); lifted = resource; break; } default: throw new global::System.ArgumentException("invalid discriminant: " + (new global::System.Span((byte*)ptr + 0, 1)[0])); } foreach (var cleanup in cleanups) { cleanup(); } return lifted; } public unsafe global::System.Collections.Generic.List GetAllWorlds() { var handle = this.Handle; var retArea = stackalloc uint[3]; var ptr = (nint)MemoryHelper.AlignStackPtr(retArea, 4); ServerImportsInterop.Server.GetAllWorldsWasmInterop.wasmImportGetAllWorlds(handle, ptr); var array = new global::System.Collections.Generic.List(new global::System.Span((void*)((byte*)ptr + 4), 1)[0]); for (int index = 0; index < new global::System.Span((void*)((byte*)ptr + 4), 1)[0]; ++index) { nint basePtr = new global::System.Span((void*)((byte*)ptr + 0), 1)[0] + (index * 4); var resource = new global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IWorldImports.World(new global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IWorldImports.World.THandle(new global::System.Span((void*)((byte*)basePtr + 0), 1)[0])); array.Add(resource); } if (new global::System.Span((void*)((byte*)ptr + 4), 1)[0] > 0) { global::System.Runtime.InteropServices.NativeMemory.Free((void*)new global::System.Span((void*)((byte*)ptr + 0), 1)[0]); } return array; } public unsafe global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IWorldImports.World? GetWorldByName(string name) { var cleanups = new global::System.Collections.Generic.List(); var handle = this.Handle; var utf8Bytes = global::System.Text.Encoding.UTF8.GetBytes(name); var length = utf8Bytes.Length; var gcHandle = global::System.Runtime.InteropServices.GCHandle.Alloc(utf8Bytes, global::System.Runtime.InteropServices.GCHandleType.Pinned); var strPtr = gcHandle.AddrOfPinnedObject(); cleanups.Add(()=> gcHandle.Free()); var retArea = stackalloc uint[3]; var ptr = (nint)MemoryHelper.AlignStackPtr(retArea, 4); ServerImportsInterop.Server.GetWorldByNameWasmInterop.wasmImportGetWorldByName(handle, strPtr.ToInt32(), length, ptr); global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IWorldImports.World? lifted; switch (new global::System.Span((byte*)ptr + 0, 1)[0]) { case 0: { lifted = null; break; } case 1: { var resource = new global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IWorldImports.World(new global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IWorldImports.World.THandle(new global::System.Span((void*)((byte*)ptr + 4), 1)[0])); lifted = resource; break; } default: throw new global::System.ArgumentException("invalid discriminant: " + (new global::System.Span((byte*)ptr + 0, 1)[0])); } foreach (var cleanup in cleanups) { cleanup(); } return lifted; } public unsafe void ExecuteCommand(string command, global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IServerImports.CommandSender sender) { var cleanups = new global::System.Collections.Generic.List(); var handle = this.Handle; var utf8Bytes = global::System.Text.Encoding.UTF8.GetBytes(command); var length = utf8Bytes.Length; var gcHandle = global::System.Runtime.InteropServices.GCHandle.Alloc(utf8Bytes, global::System.Runtime.InteropServices.GCHandleType.Pinned); var strPtr = gcHandle.AddrOfPinnedObject(); cleanups.Add(()=> gcHandle.Free()); int lowered; int lowered4; switch (sender.Tag) { case 0: { lowered = 0; lowered4 = 0; break; } case 1: { global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IPlayerImports.Player payload2 = sender.AsPlayer; var handle3 = payload2.Handle; payload2.Handle = 0; lowered = 1; lowered4 = handle3; break; } default: throw new global::System.ArgumentException("invalid discriminant: " + sender); } ServerImportsInterop.Server.ExecuteCommandWasmInterop.wasmImportExecuteCommand(handle, strPtr.ToInt32(), length, lowered, lowered4); foreach (var cleanup in cleanups) { cleanup(); } } public unsafe global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IWorldImports.World CreateWorld(string name, global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IServerImports.Dimension dimension) { var cleanups = new global::System.Collections.Generic.List(); var handle = this.Handle; var utf8Bytes = global::System.Text.Encoding.UTF8.GetBytes(name); var length = utf8Bytes.Length; var gcHandle = global::System.Runtime.InteropServices.GCHandle.Alloc(utf8Bytes, global::System.Runtime.InteropServices.GCHandleType.Pinned); var strPtr = gcHandle.AddrOfPinnedObject(); cleanups.Add(()=> gcHandle.Free()); var result = ServerImportsInterop.Server.CreateWorldWasmInterop.wasmImportCreateWorld(handle, strPtr.ToInt32(), length, (int)dimension); var resource = new global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IWorldImports.World(new global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.IWorldImports.World.THandle(result)); foreach (var cleanup in cleanups) { cleanup(); } return resource; } public unsafe void Broadcast(string message) { var cleanups = new global::System.Collections.Generic.List(); var handle = this.Handle; var utf8Bytes = global::System.Text.Encoding.UTF8.GetBytes(message); var length = utf8Bytes.Length; var gcHandle = global::System.Runtime.InteropServices.GCHandle.Alloc(utf8Bytes, global::System.Runtime.InteropServices.GCHandleType.Pinned); var strPtr = gcHandle.AddrOfPinnedObject(); cleanups.Add(()=> gcHandle.Free()); ServerImportsInterop.Server.BroadcastWasmInterop.wasmImportBroadcast(handle, strPtr.ToInt32(), length); foreach (var cleanup in cleanups) { cleanup(); } } public unsafe void BroadcastTabListHeaderFooter(global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.ITextImports.TextComponent header, global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.ITextImports.TextComponent footer) { var handle = this.Handle; var handle0 = header.Handle; header.Handle = 0; var handle1 = footer.Handle; footer.Handle = 0; ServerImportsInterop.Server.BroadcastTabListHeaderFooterWasmInterop.wasmImportBroadcastTabListHeaderFooter(handle, handle0, handle1); } public unsafe uint GetMaxPlayers() { var handle = this.Handle; var result = ServerImportsInterop.Server.GetMaxPlayersWasmInterop.wasmImportGetMaxPlayers(handle); return unchecked((uint)(result)); } public unsafe bool IsHardcore() { var handle = this.Handle; var result = ServerImportsInterop.Server.IsHardcoreWasmInterop.wasmImportIsHardcore(handle); return (result != 0); } public unsafe bool IsOnlineMode() { var handle = this.Handle; var result = ServerImportsInterop.Server.IsOnlineModeWasmInterop.wasmImportIsOnlineMode(handle); return (result != 0); } public unsafe string GetMotd() { var handle = this.Handle; var retArea = stackalloc uint[3]; var ptr = (nint)MemoryHelper.AlignStackPtr(retArea, 4); ServerImportsInterop.Server.GetMotdWasmInterop.wasmImportGetMotd(handle, ptr); var str = global::System.Text.Encoding.UTF8.GetString((byte*)new global::System.Span((void*)((byte*)ptr + 0), 1)[0], new global::System.Span((void*)((byte*)ptr + 4), 1)[0]); if (new global::System.Span((void*)((byte*)ptr + 4), 1)[0] > 0) { global::System.Runtime.InteropServices.NativeMemory.Free((void*)new global::System.Span((void*)((byte*)ptr + 0), 1)[0]); } return str; } public unsafe bool HasWhitelist() { var handle = this.Handle; var result = ServerImportsInterop.Server.HasWhitelistWasmInterop.wasmImportHasWhitelist(handle); return (result != 0); } public unsafe bool GetAllowNether() { var handle = this.Handle; var result = ServerImportsInterop.Server.GetAllowNetherWasmInterop.wasmImportGetAllowNether(handle); return (result != 0); } public unsafe bool GetAllowEnd() { var handle = this.Handle; var result = ServerImportsInterop.Server.GetAllowEndWasmInterop.wasmImportGetAllowEnd(handle); return (result != 0); } public unsafe byte GetViewDistance() { var handle = this.Handle; var result = ServerImportsInterop.Server.GetViewDistanceWasmInterop.wasmImportGetViewDistance(handle); return ((byte)result); } public unsafe byte GetSimulationDistance() { var handle = this.Handle; var result = ServerImportsInterop.Server.GetSimulationDistanceWasmInterop.wasmImportGetSimulationDistance(handle); return ((byte)result); } public unsafe global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.ICommonImports.GameMode GetDefaultGamemode() { var handle = this.Handle; var result = ServerImportsInterop.Server.GetDefaultGamemodeWasmInterop.wasmImportGetDefaultGamemode(handle); return (global::PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0.ICommonImports.GameMode)result; } } }