Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

Commit a795446

Browse files
committed
yse
1 parent e0ef3d2 commit a795446

File tree

7 files changed

+33
-25
lines changed

7 files changed

+33
-25
lines changed

TestingDummies/Commands/DummyStats.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,21 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
2121
response = "You do not have the needed permissions to run this command! Needed perms : devdummies";
2222
return false;
2323
}
24+
2425
if (arguments.Count != 1)
2526
{
2627
response = "Incorrect arguments. Usage: dummystats [dummyID]";
2728
return false;
2829
}
30+
2931
Player Dummy = Player.Get(arguments.At(0));
32+
3033
if (Dummy == null)
3134
{
3235
response = $"The player with the specified ID, '{arguments.At(0)}', dosent exist!";
3336
return false;
3437
}
38+
3539
if (Dummy.IsNPC)
3640
{
3741
List<string> effectNames = Dummy.ActiveEffects.Select(effect => effect.name).ToList();

TestingDummies/Commands/RemoveDummy.cs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,39 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
1717
{
1818
if (!Extensions.HasDummyPermissions(Player.Get(sender)))
1919
{
20-
response = "You do not have the needed permissions to run this command! Needed perms : devdummies";
20+
response = "You do not have the needed permissions to run this command! Needed perms: devdummies";
2121
return false;
2222
}
23+
2324
if (arguments.Count != 1)
2425
{
2526
response = "Insufficient arguments. Usage: removedummy [dummyID]";
2627
return false;
2728
}
28-
Player Dummy = Player.Get(arguments.At(0));
29-
if(Dummy == null)
29+
30+
Player dummy = Player.Get(arguments.At(0));
31+
32+
if (dummy == null)
3033
{
31-
response = $"The player with the specified ID, '{arguments.At(0)}', dosent exist!";
34+
response = $"The player with the specified ID, '{arguments.At(0)}', doesn't exist!";
3235
return false;
3336
}
34-
if(Dummy.IsNPC)
37+
38+
if (dummy.IsNPC)
3539
{
36-
Dummy.ReferenceHub.OnDestroy();
40+
Npc npcDummy = dummy as Npc;
41+
npcDummy.Destroy();
3742

38-
LeftEventArgs newLeft = new(Dummy);
43+
LeftEventArgs newLeft = new(npcDummy);
3944
Exiled.Events.Handlers.Player.OnLeft(newLeft);
4045

41-
response = $"Removed {Dummy.Nickname}!";
46+
response = $"Removed {dummy.Nickname}!";
4247
return true;
4348
}
4449
else
4550
{
46-
response = $"ID : '{Dummy.Id}', Nickname : '{Dummy.Nickname}' is not a dummy or you entered a incorrect ID!";
51+
response = $"ID: '{dummy.Id}', Nickname: '{dummy.Nickname}' is not a dummy or you entered an incorrect ID!";
4752
return false;
4853
}
4954
}
50-
5155
}

TestingDummies/Commands/SpawnDummy.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Exiled.API.Features;
33
using PlayerRoles;
44
using System;
5+
using TestingDummies.SpawningHandler;
56

67
namespace TestingDummies.Commands;
78

@@ -14,33 +15,38 @@ public class SpawnDummy : ICommand
1415
public string Description => "Spawns a dummy for development or testing purposes, it has 0 logic";
1516

1617
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
17-
{
18+
{
1819
if (arguments.Count != 3)
1920
{
20-
response = "Incorrect arguments. Usage: spawndummy [name] [role] [playerID] OR [playerNickname]";
21+
response = "Incorrect arguments. Usage: spawndummy [name] [role] ([playerID] or [playerNickname])";
2122
return false;
2223
}
24+
2325
string name = arguments.At(0);
2426
string roleString = arguments.At(1);
2527
Player player = Player.Get(arguments.At(2));
28+
2629
if (!Enum.TryParse(roleString, out RoleTypeId role))
2730
{
2831
response = $"Invalid role: {roleString}";
2932
return false;
3033
}
34+
3135
if (player == null)
3236
{
3337
response = $"Invalid player with the specified ID or Nickname: {arguments.At(2)}";
3438
return false;
3539
}
40+
3641
if (!Extensions.HasDummyPermissions(player))
3742
{
38-
response = "You do not have the needed permissions to run this command! Needed perms : devdummies";
43+
response = "You do not have the needed permissions to run this command! Needed perms: devdummies";
3944
return false;
4045
}
41-
Plugin.Instance.spawning.SpawnDummy(name, role, player);
46+
47+
Spawn.SpawnDummy(name, role, player);
48+
4249
response = $"Spawned dummy with name '{name}', role '{role}', for player '{player.Nickname}'";
4350
return true;
4451
}
45-
4652
}

TestingDummies/Config.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class Config : IConfig
2323
[Description("Gives spawned NPCs AFK Immunity (HIGHLY RECOMMENED TO KEEP TRUE AS NPCS ARE CONSTANTLY AFK)")]
2424
public bool NPCAFKImmunity { get; set; } = true;
2525

26+
[Description("Gets or sets if using DevDummy commands require the 'devdummies' permission.")]
2627
public bool RequirePermission { get; set; } = false;
2728
}
2829
}

TestingDummies/Plugin.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using Exiled.API.Enums;
22
using Exiled.API.Features;
33
using System;
4-
using TestingDummies.SpawningHandler;
5-
using HarmonyLib;
64
using Exiled.Permissions.Extensions;
75
using UnityEngine;
86

@@ -11,7 +9,6 @@ namespace TestingDummies;
119
public class Plugin : Plugin<Config>
1210
{
1311
public static Plugin Instance;
14-
public Spawn spawning;
1512

1613
public override string Name => "Dev Dummies";
1714
public override string Prefix => Name;
@@ -23,16 +20,13 @@ public class Plugin : Plugin<Config>
2320
public override void OnEnabled()
2421
{
2522
Instance = this;
26-
spawning = new Spawn();
27-
2823
base.OnEnabled();
29-
3024
Log.Warn($"{Name.ToUpper()} DOES AND WILL VIOLATE NORTHWOOD VSR WHEN DUMMIES ARE SPAWNED. USE ON PRIVATE SERVERS ONLY AND AT YOUR OWN RISK.");
3125
}
3226

3327
public override void OnDisabled()
3428
{
35-
spawning = null;
29+
Instance = null;
3630
base.OnDisabled();
3731
}
3832
}
@@ -50,7 +44,6 @@ public static bool HasDummyPermissions(this Player player)
5044
return true;
5145
}
5246

53-
//Needed to properly rotate dummies
5447
public static (ushort horizontal, ushort vertical) ToClientUShorts(this Quaternion rotation)
5548
{
5649
const float ToHorizontal = ushort.MaxValue / 360f;

TestingDummies/SpawningHandler/Spawn.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace TestingDummies.SpawningHandler;
55

66
public class Spawn
77
{
8-
public void SpawnDummy(string Name, RoleTypeId Role, Player Target)
8+
public static void SpawnDummy(string Name, RoleTypeId Role, Player Target)
99
{
1010
Npc GeneratedNPC = Npc.Spawn(Name, Role, position: Target.Position);
1111
if (Plugin.Instance.Config.NPCAFKImmunity) GeneratedNPC.RemoteAdminPermissions = PlayerPermissions.AFKImmunity;

TestingDummies/TestingDummies.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
</ItemGroup>
8484
<ItemGroup>
8585
<PackageReference Include="EXILED">
86-
<Version>8.2.1</Version>
86+
<Version>8.3.9</Version>
8787
</PackageReference>
8888
</ItemGroup>
8989
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

0 commit comments

Comments
 (0)