feat: add FourKit plugin host with dual server build

Adds the FourKit .NET 10 plugin host as a second dedicated server
build flavour alongside the existing vanilla server. Both flavours
build from the same source tree, with FourKit gated by the
MINECRAFT_SERVER_FOURKIT_BUILD preprocessor define.

Build layout:

  Minecraft.Server         vanilla, no plugin support, no .NET dep
  Minecraft.Server.FourKit FourKit-enabled, ships with bundled
                           .NET 10 self-contained runtime in runtime/
                           and an empty plugins/ folder

Both produce a Minecraft.Server.exe in their own per-target output
dir. The variant identity lives in the directory name, not the
binary name, so either flavour can be shipped as a drop-in.

Native bridge (Minecraft.Server/FourKit*.{cpp,h}):

* FourKitRuntime: hosts CoreCLR via hostfxr's command-line init API
  (the runtime-config API does not support self-contained components)
* FourKitBridge: ~50 Fire* event entry points, with inline no-op
  stubs for the standalone build so gameplay code can call them
  unconditionally
* FourKitNatives: ~80 native callbacks the managed side invokes
  for player/world/inventory mutations
* FourKitMappers: type and enum mapping helpers

Managed plugin host (Minecraft.Server.FourKit/):

* Bukkit-style API: Player, World, Block, Inventory, Command,
  Listener, EventHandler attribute, ~54 event classes
* PluginLoader with per-plugin AssemblyLoadContext
* FourKitHost as the [UnmanagedCallersOnly] entry point table
* Runtime resolves plugins relative to the host process so they
  always live next to Minecraft.Server.exe regardless of where the
  managed assembly itself is loaded from

Engine hooks (Minecraft.Client/, Minecraft.World/):

* Player lifecycle (PreLogin, Login, Join, Quit, Kick, Move,
  Teleport, Portal, Death) wired into PendingConnection and
  PlayerConnection without disturbing the cipher handshake or
  identity-token security flow
* Inventory open/click/drop hooks across every container menu type
* Block place/break/grow/burn/spread/from-to hooks across the
  full tile family
* Bed enter/leave, sign change, entity damage/death, ender pearl
  teleport hooks

Regression fixes preserved while applying donor diffs:

* ServerPlayer::die() retains the LCE-Revelations hardcore branch
  (setGameMode(ADVENTURE) + banPlayerForHardcoreDeath) in both the
  FourKit and non-FourKit code paths
* ServerLevel::entityAdded() retains the sub-entity ID reassignment
  loop required by the client's handleAddMob offset, fixing Ender
  Dragon and Wither boss multi-part hit detection
* LivingEntity::travel() retains the raw Player* cast and the
  cached frictionTile, both Revelations perf wins that the donor
  silently reverted
* ServerLogger.cpp keeps the file-logging code donor stripped
* PlayerList.cpp end portal transition fix and UIScene_EndPoem
  bounds-check are intact

Build system:

* Top-level CMakeLists.txt adds the Minecraft.Server.FourKit
  subdirectory and pulls in the new shared cmake/ServerTarget.cmake
  helper
* Minecraft.Server/cmake/sources/Common.cmake is now location
  independent (uses CMAKE_CURRENT_LIST_DIR) so the source list
  can be consumed from either server target's CMakeLists.txt
* The seven FourKit*.cpp/h files live in their own
  _MINECRAFT_SERVER_COMMON_SERVER_FOURKIT variable so the
  standalone target omits them
* configure-time .NET 10 SDK check fails fast with a clear
  download link if the SDK is missing
* global.json pins the SDK to 10.0.100 with latestFeature
  rollforward

Sample plugin (samples/HelloPlugin/) demonstrates the loader and
the PlayerJoinEvent listener pattern.

CI:

* nightly.yml builds both server flavours, ships
  LCE-Revelations-Server-Win64.zip and
  LCE-Revelations-Server-Win64-FourKit.zip, attests both, and
  updates release notes for the dual-flavour layout
* pull-request.yml pulls in actions/setup-dotnet so the FourKit
  publish step works in PR validation
* All zip artifacts and the client zip are renamed from
  LCREWindows64 to LCE-Revelations-{Client,Server}-Win64

Documentation:

* COMPILE.md gets a VS 2022 quick start, .NET 10 prereq section,
  server flavours explanation, and a troubleshooting section
* docs/FOURKIT_PORT_RECON.md captures the file-by-file recon that
  drove the port
* docs/FOURKIT_PARITY.md is the canonical reference for which
  events FourKit fires

Docker:

* docker-compose.dedicated-server.yml MC_RUNTIME_DIR default points
  at the vanilla CMake output. The FourKit Docker image is
  intentionally NOT shipped yet because hosting .NET 10 self
  contained inside Wine has not been smoke-tested
This commit is contained in:
itsRevela
2026-04-08 03:02:48 -05:00
parent 5d56f5080f
commit 42a582fb9f
197 changed files with 20946 additions and 788 deletions
@@ -0,0 +1,33 @@
namespace Minecraft.Server.FourKit.Event.Player;
using Minecraft.Server.FourKit.Entity;
using Minecraft.Server.FourKit.Block;
/// <summary>
/// This event is fired when the player is almost about to enter the bed.
/// </summary>
public class PlayerBedEnterEvent : PlayerEvent, Cancellable
{
private readonly Block _bed;
private bool _cancelled;
internal PlayerBedEnterEvent(Player player, Block bed) : base(player)
{
_bed = bed;
}
/// <summary>
/// Returns the bed block involved in this event.
/// </summary>
/// <returns>the bed block involved in this event</returns>
public Block getBed() => _bed;
/// <inheritdoc />
public bool isCancelled() => _cancelled;
/// <inheritdoc />
public void setCancelled(bool cancel)
{
_cancelled = cancel;
}
}
@@ -0,0 +1,23 @@
namespace Minecraft.Server.FourKit.Event.Player;
using Minecraft.Server.FourKit.Entity;
using Minecraft.Server.FourKit.Block;
/// <summary>
/// This event is fired when the player is leaving a bed.
/// </summary>
public class PlayerBedLeaveEvent : PlayerEvent
{
private readonly Block _bed;
internal PlayerBedLeaveEvent(Player player, Block bed) : base(player)
{
_bed = bed;
}
/// <summary>
/// Returns the bed block involved in this event.
/// </summary>
/// <returns>the bed block involved in this event</returns>
public Block getBed() => _bed;
}
@@ -0,0 +1,74 @@
namespace Minecraft.Server.FourKit.Event.Player;
using Minecraft.Server.FourKit.Entity;
/// <summary>
/// Fired when a player sends a chat message.
///
/// <para>When the event finishes execution the server formats the final
/// output using the same format specifiers from Java.
/// <c>%1$s</c> is the player's display name and <c>%2$s</c> is the
/// message, exactly like Bukkits <c>PlayerChatEvent</c>.</para>
/// </summary>
public class PlayerChatEvent : PlayerEvent, Cancellable
{
private string _message;
private string _format;
private bool _cancelled;
internal PlayerChatEvent(Player player, string message) : base(player)
{
_message = message;
_format = "<%1$s> %2$s";
}
/// <summary>
/// Gets the message that the player is attempting to send.
/// This message will be used with <see cref="getFormat"/>.
/// </summary>
/// <returns>Message the player is attempting to send.</returns>
public string getMessage() => _message;
/// <summary>
/// Sets the message that the player will send.
/// This message will be used with <see cref="getFormat"/>.
/// </summary>
/// <param name="message">New message that the player will send.</param>
public void setMessage(string message)
{
_message = message;
}
/// <summary>
/// Gets the format used to display this chat message.
///
/// <para>When this event finishes execution, the first format parameter
/// (<c>%1$s</c>) is <c>Player.getDisplayName()</c> and the second
/// parameter (<c>%2$s</c>) is <c>getMessage()</c>.</para>
/// </summary>
/// <returns>A Java-style positional format string compatible with Bukkit.</returns>
public string getFormat() => _format;
/// <summary>
/// Sets the format used to display this chat message.
///
/// <para>When this event finishes execution, the first format parameter
/// (<c>%1$s</c>) is <c>Player.getDisplayName()</c> and the second
/// parameter (<c>%2$s</c>) is <c>getMessage()</c>.</para>
/// </summary>
/// <param name="format">A Java-style positional format string (e.g. <c>"&lt;%1$s&gt; %2$s"</c>).</param>
/// <exception cref="ArgumentNullException">If format is <c>null</c>.</exception>
public void setFormat(string format)
{
ArgumentNullException.ThrowIfNull(format);
_format = format;
}
/// <inheritdoc />
public bool isCancelled() => _cancelled;
/// <inheritdoc />
public void setCancelled(bool cancel)
{
_cancelled = cancel;
}
}
@@ -0,0 +1,53 @@
namespace Minecraft.Server.FourKit.Event.Player;
using Minecraft.Server.FourKit.Entity;
/// <summary>
/// Called early in the command handling process. This event is only for very
/// exceptional cases and you should not normally use it.
///
/// <para>If a PlayerCommandPreprocessEvent is cancelled, the command will not
/// be executed in the server, but will still pass to other plugins.</para>
/// </summary>
public class PlayerCommandPreprocessEvent : PlayerEvent, Cancellable
{
private string _message;
private bool _cancel;
internal PlayerCommandPreprocessEvent(Player player, string message) : base(player)
{
_message = message;
_cancel = false;
}
/// <inheritdoc/>
public bool isCancelled() => _cancel;
/// <inheritdoc/>
public void setCancelled(bool cancel)
{
_cancel = cancel;
}
/// <summary>
/// Gets the command that the player is attempting to send. All commands
/// begin with a special character; implementations do not consider the
/// first character when executing the content.
/// </summary>
/// <returns>Message the player is attempting to send.</returns>
public string getMessage() => _message;
/// <summary>
/// Sets the command that the player will send. All commands begin with a
/// special character; implementations do not consider the first character
/// when executing the content.
/// </summary>
/// <param name="command">New message that the player will send.</param>
/// <exception cref="ArgumentException">If command is null or empty.</exception>
public void setMessage(string command)
{
if (string.IsNullOrEmpty(command))
throw new ArgumentException("Command may not be null or empty", nameof(command));
_message = command;
}
}
@@ -0,0 +1,46 @@
namespace Minecraft.Server.FourKit.Event.Player;
using Minecraft.Server.FourKit.Entity;
using Minecraft.Server.FourKit.Inventory;
// Yo this event pissed me the fuck off
/// <summary>
/// Fired when a player drops an item from their inventory.
/// If cancelled, the item will not be dropped and the player keeps it.
/// The dropped item can be modified by plugins.
/// </summary>
public class PlayerDropItemEvent : PlayerEvent, Cancellable
{
private ItemStack _itemDrop;
private bool _cancelled;
internal PlayerDropItemEvent(Player player, ItemStack drop)
: base(player)
{
_itemDrop = drop;
}
/// <summary>
/// Gets the ItemDrop created by the player.
/// </summary>
/// <returns>The ItemStack being dropped.</returns>
public ItemStack getItemDrop() => _itemDrop;
/// <summary>
/// Sets the item to be dropped. Plugins can modify which item
/// is actually dropped.
/// </summary>
/// <param name="item">The new item to drop.</param>
public void setItemDrop(ItemStack item)
{
_itemDrop = item;
}
/// <inheritdoc/>
public bool isCancelled() => _cancelled;
/// <inheritdoc/>
public void setCancelled(bool cancel)
{
_cancelled = cancel;
}
}
@@ -0,0 +1,19 @@
namespace Minecraft.Server.FourKit.Event.Player;
using Minecraft.Server.FourKit.Entity;
/// <summary>
/// Base class for events related to a <see cref="FourKit.Player"/>.
/// </summary>
public abstract class PlayerEvent : Event
{
private readonly Player _player;
internal protected PlayerEvent(Player player)
{
_player = player;
}
/// <summary>Returns the player involved in this event.</summary>
public Player getPlayer() => _player;
}
@@ -0,0 +1,32 @@
namespace Minecraft.Server.FourKit.Event.Player;
using Minecraft.Server.FourKit.Entity;
/// <summary>
/// Represents an event that is called when a player right clicks an entity.
/// </summary>
public class PlayerInteractEntityEvent : PlayerEvent, Cancellable
{
/// <summary>The entity that was right-clicked.</summary>
protected Entity clickedEntity;
private bool _cancelled;
internal PlayerInteractEntityEvent(Player who, Entity clickedEntity)
: base(who)
{
this.clickedEntity = clickedEntity;
}
/// <inheritdoc/>
public bool isCancelled() => _cancelled;
/// <inheritdoc/>
public void setCancelled(bool cancel) => _cancelled = cancel;
/// <summary>
/// Gets the entity that was right-clicked by the player.
/// </summary>
/// <returns>entity right clicked by player</returns>
public Entity getRightClicked() => clickedEntity;
}
@@ -0,0 +1,111 @@
namespace Minecraft.Server.FourKit.Event.Player;
using Minecraft.Server.FourKit.Block;
using Minecraft.Server.FourKit.Entity;
using Minecraft.Server.FourKit.Inventory;
using FourKitBlock = Minecraft.Server.FourKit.Block.Block;
/// <summary>
/// Called when a player interacts with an object or air.
/// </summary>
public class PlayerInteractEvent : PlayerEvent, Cancellable
{
private readonly Action _action;
private readonly ItemStack? _item;
private readonly FourKitBlock? _clickedBlock;
private readonly BlockFace _clickedFace;
private bool _cancelled;
private bool _useItemInHand = true;
internal PlayerInteractEvent(Player who, Action action, ItemStack? item, FourKitBlock? clickedBlock, BlockFace clickedFace)
: base(who)
{
_action = action;
_item = item;
_clickedBlock = clickedBlock;
_clickedFace = clickedFace;
}
/// <summary>
/// Returns the action type.
/// </summary>
/// <returns>Action returns the type of interaction.</returns>
public Action getAction() => _action;
/// <inheritdoc/>
public bool isCancelled() => _cancelled;
/// <summary>
/// Sets the cancellation state of this event. A canceled event will not be
/// executed in the server, but will still pass to other plugins.
///
/// Canceling this event will prevent use of food (player won't lose the
/// food item), prevent bows/snowballs/eggs from firing, etc. (player won't
/// lose the ammo).
/// </summary>
/// <param name="cancel">true if you wish to cancel this event.</param>
public void setCancelled(bool cancel) => _cancelled = cancel;
/// <summary>
/// Returns the item in hand represented by this event.
/// </summary>
/// <returns>ItemStack the item used.</returns>
public ItemStack? getItem() => _item;
/// <summary>
/// Convenience method. Returns the material of the item represented by this event.
/// </summary>
/// <returns>Material the material of the item used.</returns>
public Material getMaterial() => _item?.getType() ?? Material.AIR;
/// <summary>
/// Check if this event involved a block.
/// </summary>
/// <returns>true if it did.</returns>
public bool hasBlock() => _clickedBlock != null;
/// <summary>
/// Check if this event involved an item.
/// </summary>
/// <returns>true if it did.</returns>
public bool hasItem() => _item != null;
/// <summary>
/// Convenience method to inform the user whether this was a block placement event.
/// </summary>
/// <returns>true if the item in hand was a block.</returns>
public bool isBlockInHand()
{
if (_item == null) return false;
int id = (int)_item.getType();
return id >= 1 && id <= 255;
}
/// <summary>
/// Returns the clicked block.
/// </summary>
/// <returns>Block returns the block clicked with this item.</returns>
public FourKitBlock? getClickedBlock() => _clickedBlock;
/// <summary>
/// Returns the face of the block that was clicked.
/// </summary>
/// <returns>BlockFace returns the face of the block that was clicked.</returns>
public BlockFace getBlockFace() => _clickedFace;
/// <summary>
/// This controls the action to take with the item the player is holding.
/// This includes both blocks and items (such as flint and steel or records).
/// When this is set to default, it will be allowed if no action is taken on
/// the interacted block.
/// </summary>
/// <returns>the action to take with the item in hand.</returns>
public bool useItemInHand() => _useItemInHand;
/// <summary>
/// Sets whether to use the item in hand.
/// </summary>
/// <param name="useItemInHand">the action to take with the item in hand.</param>
public void setUseItemInHand(bool useItemInHand) => _useItemInHand = useItemInHand;
}
@@ -0,0 +1,30 @@
namespace Minecraft.Server.FourKit.Event.Player;
using Minecraft.Server.FourKit.Entity;
/// <summary>
/// Called when a player joins a server
/// </summary>
public class PlayerJoinEvent : PlayerEvent
{
private string _joinMessage;
internal PlayerJoinEvent(Player player) : base(player)
{
_joinMessage = $"{player.getName()} joined the game";
}
/// <summary>
/// Gets the join message to send to all online players
/// </summary>
/// <returns>string join message</returns>
public string getJoinMessage() => _joinMessage;
/// <summary>
/// Sets the join message to send to all online players
/// </summary>
/// <param name="joinMessage">join message.</param>
public void setJoinMessage(string? joinMessage)
{
_joinMessage = joinMessage ?? string.Empty;
}
}
@@ -0,0 +1,62 @@
namespace Minecraft.Server.FourKit.Event.Player;
using Minecraft.Server.FourKit.Entity;
/// <summary>
/// Fired when a player is kicked from the server.
/// If cancelled, the kick will not take place and the player remains connected.
/// Plugins may modify the kick reason and the leave message broadcast to
/// all online players.
/// </summary>
public class PlayerKickEvent : PlayerEvent, Cancellable
{
private DisconnectReason _reason;
private string _leaveMessage;
private bool _cancelled;
internal PlayerKickEvent(Player playerKicked, DisconnectReason kickReason, string leaveMessage)
: base(playerKicked)
{
_reason = kickReason;
_leaveMessage = leaveMessage;
}
/// <summary>
/// Gets the reason why the player is getting kicked.
/// </summary>
/// <returns>The disconnect reason.</returns>
public DisconnectReason getReason() => _reason;
/// <summary>
/// Sets the reason why the player is getting kicked.
/// </summary>
/// <param name="kickReason">The new disconnect reason.</param>
public void setReason(DisconnectReason kickReason)
{
_reason = kickReason;
}
/// <summary>
/// Gets the leave message sent to all online players.
/// </summary>
/// <returns>The leave message.</returns>
public string getLeaveMessage() => _leaveMessage;
/// <summary>
/// Sets the leave message sent to all online players.
/// </summary>
/// <param name="leaveMessage">The new leave message.</param>
public void setLeaveMessage(string leaveMessage)
{
_leaveMessage = leaveMessage;
}
/// <inheritdoc/>
public bool isCancelled() => _cancelled;
/// <inheritdoc/>
public void setCancelled(bool cancel)
{
_cancelled = cancel;
}
}
@@ -0,0 +1,93 @@
namespace Minecraft.Server.FourKit.Event.Player;
using Minecraft.Server.FourKit.Enums;
using Minecraft.Server.FourKit.Net;
/// <summary>
/// Stores details for players attempting to log in.
/// </summary>
public class PlayerLoginEvent : Event, Cancellable
{
private string name;
private InetSocketAddress ipAddress; //bukkit uses InetAddress but we expose port also
private ulong onlineXuid;
private ulong offlineXuid;
private bool changedXuidValues;
private LoginType loginType;
private bool _cancelled;
internal PlayerLoginEvent(string name, InetSocketAddress ipAddress, LoginType type, ulong onlineXuid, ulong offlineXuid) : base()
{
this.name = name;
this.ipAddress = ipAddress;
this.onlineXuid = onlineXuid;
this.offlineXuid = offlineXuid;
this.changedXuidValues = false;
this.loginType = type;
}
public LoginType getLoginType() => loginType;
/// <summary>
/// <b>Experimental.</b> Gets the online XUID (Xbox User ID), used for guests (splitscreen users).
/// </summary>
/// <returns>The online XUID value.</returns>
public ulong getOnlineXuid() => onlineXuid;
/// <summary>
/// <b>Experimental.</b> Sets the online XUID (Xbox User ID). Marks XUID values as changed.
/// </summary>
/// <param name="newXuid">The new online XUID value.</param>
public void setOnlineXuid(ulong newXuid)
{
this.onlineXuid = newXuid;
this.changedXuidValues = true;
}
/// <summary>
/// <b>Experimental.</b> Gets the offline XUID (Xbox User ID), which is the main XUID used by the client.
/// </summary>
/// <returns>The offline XUID value.</returns>
public ulong getOfflineXuid() => offlineXuid;
/// <summary>
/// <b>Experimental.</b> Sets the offline XUID (Xbox User ID). Marks XUID values as changed.
/// </summary>
/// <param name="newXuid">The new offline XUID value.</param>
public void setOfflineXuid(ulong newXuid)
{
this.offlineXuid = newXuid;
this.changedXuidValues = true;
}
/// <summary>
/// <b>Experimental.</b> Returns true if either XUID value has been changed via setters.
/// </summary>
/// <returns>True if XUID values have been changed; otherwise, false.</returns>
public bool hasChangedXuidValues() => changedXuidValues;
/// <summary>
/// Gets the player's name.
/// </summary>
/// <returns>The player's name.</returns>
public string getName() => name;
/// <summary>
/// Gets the player IP address.
/// </summary>
/// <returns>The IP address.</returns>
public InetSocketAddress getAddress() => ipAddress;
/// <inheritdoc/>
public bool isCancelled() => _cancelled;
/// <inheritdoc/>
public void setCancelled(bool cancel) => _cancelled = cancel;
}
@@ -0,0 +1,59 @@
namespace Minecraft.Server.FourKit.Event.Player;
using Minecraft.Server.FourKit.Entity;
/// <summary>
/// Fired when a player moves. Plugins may modify the destination
/// or cancel the movement entirely.
/// </summary>
public class PlayerMoveEvent : PlayerEvent, Cancellable
{
private Location _from;
private Location _to;
private bool _cancelled;
internal PlayerMoveEvent(Player player, Location from, Location to) : base(player)
{
_from = from;
_to = to;
}
/// <summary>
/// Gets the location this player moved from.
/// </summary>
/// <returns>The from location.</returns>
public Location getFrom() => _from;
/// <summary>
/// Gets the location this player moved to.
/// </summary>
/// <returns>The to location.</returns>
public Location getTo() => _to;
/// <summary>
/// Sets the location to mark as where the player moved from.
/// </summary>
/// <param name="from">The new from location.</param>
public void setFrom(Location from)
{
_from = from;
}
/// <summary>
/// Sets the location that this player will move to.
/// </summary>
/// <param name="to">The new to location.</param>
public void setTo(Location to)
{
_to = to;
}
/// <inheritdoc />
public bool isCancelled() => _cancelled;
/// <inheritdoc />
public void setCancelled(bool cancel)
{
_cancelled = cancel;
}
}
@@ -0,0 +1,41 @@
namespace Minecraft.Server.FourKit.Event.Player;
using Minecraft.Server.FourKit.Entity;
/// <summary>
/// Thrown when a player picks an item up from the ground.
/// If cancelled the item will not be picked up.
/// </summary>
public class PlayerPickupItemEvent : PlayerEvent, Cancellable
{
private readonly Item _item;
private readonly int _remaining;
private bool _cancelled;
internal PlayerPickupItemEvent(Player player, Item item, int remaining)
: base(player)
{
_item = item;
_remaining = remaining;
}
/// <summary>
/// Gets the Item picked up by the player.
/// </summary>
/// <returns>The <see cref="Item"/> entity.</returns>
public Item getItem() => _item;
/// <summary>
/// Gets the amount remaining on the ground, if any.
/// </summary>
/// <returns>Amount remaining on the ground.</returns>
public int getRemaining() => _remaining;
/// <inheritdoc/>
public bool isCancelled() => _cancelled;
/// <inheritdoc/>
public void setCancelled(bool cancel)
{
_cancelled = cancel;
}
}
@@ -0,0 +1,22 @@
namespace Minecraft.Server.FourKit.Event.Player;
using Minecraft.Server.FourKit.Entity;
/// <summary>
/// Called when a player is about to teleport because it is in contact with a portal.
/// </summary>
public class PlayerPortalEvent : PlayerTeleportEvent
{
internal PlayerPortalEvent(Player player, Location from, Location to)
: base(player, from, to, TeleportCause.UNKNOWN) { }
/// <summary>
/// Constructs a new PlayerPortalEvent with the given cause.
/// </summary>
/// <param name="player">The player entering the portal.</param>
/// <param name="from">The location the player is coming from.</param>
/// <param name="to">The location the player is teleporting to.</param>
/// <param name="cause">The cause of this teleportation (should be a portal-related cause).</param>
public PlayerPortalEvent(Player player, Location from, Location to, TeleportCause cause)
: base(player, from, to, cause) { }
}
@@ -0,0 +1,40 @@
namespace Minecraft.Server.FourKit.Event.Player;
using Minecraft.Server.FourKit.Net;
/// <summary>
/// Stores details for players attempting to log in.
/// </summary>
public class PlayerPreLoginEvent : Event, Cancellable
{
private string name;
private InetSocketAddress ipAddress; //bukkit uses InetAddress but we expose port also
private bool _cancelled;
internal PlayerPreLoginEvent(string name, InetSocketAddress ipAddress) : base()
{
this.name = name;
this.ipAddress = ipAddress;
}
/// <summary>
/// Gets the player's name.
/// </summary>
/// <returns>The player's name.</returns>
public string getName() => name;
/// <summary>
/// Gets the player IP address.
/// </summary>
/// <returns>The IP address.</returns>
public InetSocketAddress getAddress() => ipAddress;
/// <inheritdoc/>
public bool isCancelled() => _cancelled;
/// <inheritdoc/>
public void setCancelled(bool cancel) => _cancelled = cancel;
}
@@ -0,0 +1,32 @@
namespace Minecraft.Server.FourKit.Event.Player;
using Minecraft.Server.FourKit.Entity;
/// <summary>
/// Fired when a player disconnects from the server.
/// Plugins may read or modify the quit message that is broadcast to all
/// online players.
/// </summary>
public class PlayerQuitEvent : PlayerEvent
{
private string _quitMessage;
internal PlayerQuitEvent(Player player) : base(player)
{
_quitMessage = $"{player.getName()} left the game";
}
/// <summary>
/// Gets the quit message to send to all online players.
/// </summary>
/// <returns>The quit message.</returns>
public string getQuitMessage() => _quitMessage;
/// <summary>
/// Sets the quit message to send to all online players.
/// </summary>
/// <param name="quitMessage">The new quit message, or <c>null</c> to suppress it.</param>
public void setQuitMessage(string? quitMessage)
{
_quitMessage = quitMessage ?? string.Empty;
}
}
@@ -0,0 +1,44 @@
namespace Minecraft.Server.FourKit.Event.Player;
using Minecraft.Server.FourKit.Entity;
/// <summary>
/// Holds information for player teleport events.
/// </summary>
public class PlayerTeleportEvent : PlayerMoveEvent
{
/// <summary>
/// Represents the cause of a player teleportation.
/// </summary>
public enum TeleportCause
{
/// <summary>Indicates the teleportation was caused by a player throwing an Ender Pearl.</summary>
ENDER_PEARL,
/// <summary>Indicates the teleportation was caused by a player executing a command.</summary>
COMMAND,
/// <summary>Indicates the teleportation was caused by a plugin.</summary>
PLUGIN,
/// <summary>Indicates the teleportation was caused by a player entering a Nether portal.</summary>
NETHER_PORTAL,
/// <summary>Indicates the teleportation was caused by a player entering an End portal.</summary>
END_PORTAL,
/// <summary>Indicates the teleportation was caused by an event not covered by this enum.</summary>
UNKNOWN,
}
private readonly TeleportCause _cause;
internal PlayerTeleportEvent(Player player, Location from, Location to)
: this(player, from, to, TeleportCause.UNKNOWN) { }
internal PlayerTeleportEvent(Player player, Location from, Location to, TeleportCause cause)
: base(player, from, to)
{
_cause = cause;
}
/// <summary>
/// Gets the cause of this teleportation event.
/// </summary>
/// <returns>The cause of the event.</returns>
public TeleportCause getCause() => _cause;
}