Skip to content

Commit

Permalink
Improved RunCommand and PlayerCheckReservedSlot event, bumped version (
Browse files Browse the repository at this point in the history
  • Loading branch information
zabszk authored Nov 12, 2022
1 parent c3b82e1 commit a62b15c
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 7 deletions.
2 changes: 1 addition & 1 deletion NwPluginAPI/Core/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public static void Shutdown(ushort redirectPort)
/// </summary>
/// <param name="command">The command name.</param>
/// <param name="sender">The <see cref="CommandSender"/> running the command.</param>
public static void RunCommand(string command, CommandSender sender = null) => GameCore.Console.singleton.TypeCommand(command, sender);
public static string RunCommand(string command, CommandSender sender = null) => ServerConsole.EnterCommand(command, sender);

/// <summary>
/// Shows a broadcast to the player.
Expand Down
4 changes: 2 additions & 2 deletions NwPluginAPI/Core/Zones/Light/Rooms/LczScp914.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ namespace PluginAPI.Core.Zones.Light.Rooms

public class LczScp914 : LczRoom
{
internal static LczScp914 Instance;
/*internal static LczScp914 Instance;
public static RoomLight RoomLights => Instance.Lights;
public static RoomIdentifier RoomIdentifier => Instance.Identifier;
public static PryableDoor Gate => null;
public static PryableDoor Gate => null;*/

/// <summary>
/// Gets the intake chamber <see cref="Transform"/>.
Expand Down
4 changes: 2 additions & 2 deletions NwPluginAPI/Core/Zones/UnknownZone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ namespace PluginAPI.Core.Zones
/// </summary>
public class UnknownZone : FacilityZone
{
internal static UnknownZone Instance;
/*internal static UnknownZone Instance;
/// <inheritdoc/>
public override MapGeneration.FacilityZone ZoneType { get; } = MapGeneration.FacilityZone.Other;
public override MapGeneration.FacilityZone ZoneType { get; } = MapGeneration.FacilityZone.Other;*/
}
}
40 changes: 40 additions & 0 deletions NwPluginAPI/Events/IEventCancellation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public interface IEventCancellation
/// </summary>
/// <param name="seconds">The delay in seconds.</param>
/// <param name="isForced">Indicates whether the player has to be rejected forcefully or not.</param>
/// <returns>Event cancellation data</returns>
public static PreauthCancellationData RejectDelay(byte seconds, bool isForced)
{
if (seconds < 1 || seconds > 25)
Expand All @@ -46,6 +47,7 @@ public static PreauthCancellationData RejectDelay(byte seconds, bool isForced)
/// </summary>
/// <param name="port">The new server port.</param>
/// <param name="isForced">Indicates whether the player has to be rejected forcefully or not.</param>
/// <returns>Event cancellation data</returns>
public static PreauthCancellationData RejectRedirect(ushort port, bool isForced) => new PreauthCancellationData(RejectionReason.Redirect, isForced, port: port);

/// <summary>
Expand All @@ -54,6 +56,7 @@ public static PreauthCancellationData RejectDelay(byte seconds, bool isForced)
/// <param name="banReason">The ban reason.</param>
/// <param name="expiration">The ban expiration time.</param>
/// <param name="isForced">Indicates whether the player has to be rejected forcefully or not.</param>
/// <returns>Event cancellation data</returns>
public static PreauthCancellationData RejectBanned(string banReason, DateTime expiration, bool isForced) =>
RejectBanned(banReason, expiration.Ticks, isForced);

Expand All @@ -63,6 +66,7 @@ public static PreauthCancellationData RejectBanned(string banReason, DateTime ex
/// <param name="banReason">The ban reason.</param>
/// <param name="expiration">The ban expiration time in .NET Ticks.</param>
/// <param name="isForced">Indicates whether the player has to be rejected forcefully or not.</param>
/// <returns>Event cancellation data</returns>
// ReSharper disable once MemberCanBePrivate.Global
public static PreauthCancellationData RejectBanned(string banReason, long expiration, bool isForced)
{
Expand All @@ -77,6 +81,7 @@ public static PreauthCancellationData RejectBanned(string banReason, long expira
/// </summary>
/// <param name="customReason">Custom rejection reason.</param>
/// <param name="isForced">Indicates whether the player has to be rejected forcefully or not.</param>
/// <returns>Event cancellation data</returns>
public static PreauthCancellationData Reject(string customReason, bool isForced)
{
if (string.IsNullOrEmpty(customReason) || customReason.Length > 400)
Expand All @@ -90,6 +95,7 @@ public static PreauthCancellationData Reject(string customReason, bool isForced)
/// </summary>
/// <param name="reason">Rejection reason.</param>
/// <param name="isForced">Indicates whether the player has to be rejected forcefully or not.</param>
/// <returns>Event cancellation data</returns>
public static PreauthCancellationData Reject(RejectionReason reason, bool isForced)
{
switch (reason)
Expand All @@ -110,11 +116,13 @@ public static PreauthCancellationData Reject(RejectionReason reason, bool isForc
/// </summary>
/// <param name="writer">The <see cref="NetDataWriter"/> instance.</param>
/// <param name="isForced">Indicates whether the player has to be rejected forcefully or not.</param>
/// <returns>Event cancellation data</returns>
public static PreauthCancellationData Reject(NetDataWriter writer, bool isForced) => new PreauthCancellationData(RejectionReason.NotSpecified, isForced, writer: writer);

/// <summary>
/// Accepts the connection.
/// </summary>
/// <returns>Event cancellation data</returns>
public static PreauthCancellationData Accept() =>
new PreauthCancellationData(RejectionReason.NotSpecified, false, isCancelled: false);

Expand Down Expand Up @@ -177,4 +185,36 @@ public NetDataWriter GenerateWriter(out bool forced)
return writer;
}
}

/// <summary>
/// Preauth Event Cancellation Data
/// </summary>
public readonly struct PlayerCheckReservedSlotCancellationData : IEventCancellation
{
public bool IsCancelled { get; }

// ReSharper disable once MemberCanBePrivate.Global
public readonly bool HasReservedSlot;

private PlayerCheckReservedSlotCancellationData(bool isCancelled, bool hasReservedSlot)
{
IsCancelled = isCancelled;
HasReservedSlot = hasReservedSlot;
}

/// <summary>
/// Doesn't override the reserved slot check.
/// </summary>
/// <returns>Event cancellation data</returns>
public static PlayerCheckReservedSlotCancellationData LeaveUnchanged() =>
new PlayerCheckReservedSlotCancellationData(false, false);

/// <summary>
/// Overrides reserved slot check.
/// </summary>
/// <param name="hasReservedSlot">Indicates whether the player has a reserved slot or not.</param>
/// <returns>Event cancellation data</returns>
public static PlayerCheckReservedSlotCancellationData Override(bool hasReservedSlot) =>
new PlayerCheckReservedSlotCancellationData(true, hasReservedSlot);
}
}
2 changes: 1 addition & 1 deletion NwPluginAPI/NwPluginAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Title>Northwood.PluginAPI</Title>
<Copyright>Copyright by Hubert Moszka Northwood, 2022</Copyright>
<PackageVersion>12.0.0-beta6</PackageVersion>
<PackageVersion>12.0.0-beta7</PackageVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion NwPluginAPI/PluginApiVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
internal static class PluginApiVersion
{
internal const string Version = "12.0.0"; //major.minor.patch ONLY
internal const string VersionString = "12.0.0-beta6";
internal const string VersionString = "12.0.0-beta7";

//PackageVersion needs to be set to the same value as VersionString MANUALLY IN .csproj
}
Expand Down

0 comments on commit a62b15c

Please sign in to comment.