Skip to content

Commit

Permalink
Ready to release
Browse files Browse the repository at this point in the history
  • Loading branch information
NaoUnderscore committed Sep 16, 2024
1 parent ed7eb54 commit 902ba15
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 17 deletions.
31 changes: 30 additions & 1 deletion AdminTools/Enums.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,45 @@
namespace AdminTools
{
/// <summary>
/// Represents the possible axes in a 3D space.
/// </summary>
public enum VectorAxis
{
/// <summary>
/// The X-axis.
/// </summary>
X,

/// <summary>
/// The Y-axis.
/// </summary>
Y,

/// <summary>
/// The Z-axis.
/// </summary>
Z
}

/// <summary>
/// Specifies the type of modification applied to a position.
/// </summary>
public enum PositionModifier
{
/// <summary>
/// Sets a position.
/// </summary>
Set,

/// <summary>
/// Retrieves a position.
/// </summary>
Get,
Add,

/// <summary>
/// Adds to a position.
/// </summary>
Add
}

}
26 changes: 14 additions & 12 deletions AdminTools/EventHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using Exiled.API.Features;
using Exiled.API.Features.Doors;
using Exiled.API.Interfaces;
using Exiled.CustomModules;
using Exiled.CustomModules.API.Features;
using Exiled.Events.EventArgs.Player;
using Exiled.Events.EventArgs.Server;
using PlayerRoles;
Expand All @@ -18,7 +20,7 @@ public class EventHandlers
{
private readonly Main plugin;

public EventHandlers(Main main)
internal EventHandlers(Main main)
{
plugin = main;

Expand Down Expand Up @@ -47,19 +49,19 @@ public EventHandlers(Main main)
Handlers.Player.ChangingRole -= OnChangingRole;
}

public void OnInteractingDoor(InteractingDoorEventArgs ev)
internal void OnInteractingDoor(InteractingDoorEventArgs ev)
{
if (Main.PryGate.Contains(ev.Player) && ev.Door is Gate gate)
gate.TryPry();
}

public static void OnHurting(HurtingEventArgs ev)
internal static void OnHurting(HurtingEventArgs ev)
{
if (ev.Attacker != ev.Player && Main.InstantKill.Contains(ev.Attacker))
ev.Amount = StandardDamageHandler.KillValue;
}

public void OnPlayerDestroying(DestroyingEventArgs ev)
internal void OnPlayerDestroying(DestroyingEventArgs ev)
{
if (Main.RoundStartMutes.Remove(ev.Player))
{
Expand All @@ -69,7 +71,7 @@ public void OnPlayerDestroying(DestroyingEventArgs ev)
ev.Player.SavingPlayerData();
}

public void OnPlayerVerified(VerifiedEventArgs ev)
internal void OnPlayerVerified(VerifiedEventArgs ev)
{
if (Main.JailedPlayers.ContainsKey(ev.Player.UserId))
Jail.DoJail(ev.Player, true);
Expand All @@ -88,7 +90,7 @@ public void OnPlayerVerified(VerifiedEventArgs ev)
}
}

public void OnRoundStarted()
internal void OnRoundStarted()
{
foreach (Player ply in Main.RoundStartMutes)
{
Expand All @@ -100,7 +102,7 @@ public void OnRoundStarted()
Main.RoundStartMutes.Clear();
}

public void OnRoundEnded(RoundEndedEventArgs ev)
internal void OnRoundEnded(RoundEndedEventArgs ev)
{
// Update all the jails that it is no longer the current round, so when they are unjailed they don't teleport into the void.
foreach (Jailed jail in Main.JailedPlayers.Values)
Expand All @@ -115,19 +117,19 @@ public void OnRoundEnded(RoundEndedEventArgs ev)
File.WriteAllLines(plugin.OverwatchFilePath, Main.Overwatch);
}

public void OnTriggeringTesla(TriggeringTeslaEventArgs ev)
internal void OnTriggeringTesla(TriggeringTeslaEventArgs ev)
{
if (ev.Player.IsGodModeEnabled)
ev.IsAllowed = false;
}

public void OnChangingRole(ChangingRoleEventArgs ev)
internal void OnChangingRole(ChangingRoleEventArgs ev)
{
if (plugin.Config.GodTuts && (ev.Reason == SpawnReason.ForceClass || ev.Reason == SpawnReason.None))
ev.Player.IsGodModeEnabled = ev.NewRole == RoleTypeId.Tutorial;
ev.Player.IsGodModeEnabled = ev.NewRole == RoleTypeId.Tutorial && !ev.Player.Is(out Pawn _);
}

public void OnWaitingForPlayers()
internal void OnWaitingForPlayers()
{
Main.InstantKill.Clear();
Main.BreakDoors.Clear();
Expand All @@ -143,7 +145,7 @@ public void OnWaitingForPlayers()
}
}

public void OnPlayerInteractingDoor(InteractingDoorEventArgs ev)
internal void OnPlayerInteractingDoor(InteractingDoorEventArgs ev)
{
if (Main.BreakDoors.Contains(ev.Player) && ev.Door is IDamageableDoor damageableDoor)
damageableDoor.Break();
Expand Down
32 changes: 30 additions & 2 deletions AdminTools/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,17 @@

namespace AdminTools
{
/// <summary>
/// Provides extension methods for various game-related functionalities.
/// </summary>
public static class Extensions
{
/// <summary>
/// Formats the arguments of a sentence starting from the specified index.
/// </summary>
/// <param name="sentence">The array segment containing the sentence.</param>
/// <param name="index">The starting index for formatting.</param>
/// <returns>A formatted string of the sentence from the specified index.</returns>
public static string FormatArguments(this ArraySegment<string> sentence, int index)
{
StringBuilder sb = new();
Expand All @@ -24,8 +33,18 @@ public static string FormatArguments(this ArraySegment<string> sentence, int ind
return msg;
}

public static string LogPlayers(this IEnumerable<Player> players) => string.Join("\n - ", players.Select(x => $"{x.Nickname}({x.Id})"));
/// <summary>
/// Logs the players with their nickname and ID.
/// </summary>
/// <param name="players">The collection of players to log.</param>
/// <returns>A string containing player nicknames and IDs.</returns>
public static string LogPlayers(this IEnumerable<Player> players) =>
string.Join("\n - ", players.Select(x => $"{x.Nickname}({x.Id})"));

/// <summary>
/// Saves the player's overwatch state to the configuration.
/// </summary>
/// <param name="player">The player whose data is being saved.</param>
public static void SavingPlayerData(this Player player)
{
List<string> overwatchRead = Main.Overwatch;
Expand All @@ -38,8 +57,17 @@ public static void SavingPlayerData(this Player player)
Log.Debug($"{player.Nickname}({player.UserId}) has added their overwatch.");
}
else if (!player.IsOverwatchEnabled && overwatchRead.Remove(userId))
Log.Debug($"{player.Nickname}({player.UserId}) has remove their overwatch.");
Log.Debug($"{player.Nickname}({player.UserId}) has removed their overwatch.");
}

/// <summary>
/// Spawns a workbench at the specified position, rotation, and size.
/// </summary>
/// <param name="ply">The player who is spawning the workbench.</param>
/// <param name="position">The position to spawn the workbench at.</param>
/// <param name="rotation">The rotation of the workbench.</param>
/// <param name="size">The size of the workbench.</param>
/// <param name="benchIndex">The index of the spawned workbench in the player's workbench list.</param>
public static void SpawnWorkbench(Player ply, Vector3 position, Vector3 rotation, Vector3 size, out int benchIndex)
{
try
Expand Down
2 changes: 0 additions & 2 deletions AdminTools/Jailed.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System.Collections.Generic;
using Exiled.API.Enums;
using Exiled.API.Features;
using Exiled.API.Features.Items;
using PlayerRoles;
using RelativePositioning;

namespace AdminTools
Expand Down

0 comments on commit 902ba15

Please sign in to comment.