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

Commit

Permalink
Synapse3
Browse files Browse the repository at this point in the history
  • Loading branch information
warquys committed Feb 22, 2023
1 parent 9946ab4 commit 896afe8
Show file tree
Hide file tree
Showing 8 changed files with 233 additions and 131 deletions.
43 changes: 29 additions & 14 deletions RpName/EventsHandler.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,43 @@
using Synapse.Api.Events.SynapseEventArguments;
using MEC;
using Neuron.Core.Events;
using Neuron.Core.Meta;
using Synapse3.SynapseModule;
using Synapse3.SynapseModule.Events;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml.Linq;

namespace RpName
{
public class EventsHandler
[Automatic]
public class EventsHandler : Listener
{
public EventsHandler()
private readonly RpNamePlugin _plugin;

public EventsHandler(RpNamePlugin plugin, PlayerEvents playerEvents)
{
Synapse.Api.Events.EventHandler.Get.Player.PlayerSetClassEvent += OnSetClass;
SynapseLogger<EventsHandler>.Info("EventsHandler");
_plugin = plugin;
playerEvents.SetClass.Subscribe(OnSetClass);
}

private void OnSetClass(PlayerSetClassEventArgs ev)
private void OnSetClass(SetClassEvent ev)
{
if (PluginClass.Config.RoleName != null && PluginClass.Config.RoleName.Any())
Timing.CallDelayed(0.1f, () =>
{
var id = ev.Player.RoleID;
if (_plugin.Config.RoleName != null && _plugin.Config.RoleName.Any())
{
var id = ev.Player.RoleID;

var name = PluginClass.GetName(id, ev.Player.NickName);
if (string.IsNullOrEmpty(name))
ev.Player.name = ev.Player.NickName;
else
ev.Player.name = name;
}
if (id == 56)
id = (uint)ev.Player.RoleType;
var name = _plugin.GetName(id, ev.Player.NickName);
if (string.IsNullOrEmpty(name))
ev.Player.DisplayName = ev.Player.NickName;
else
ev.Player.DisplayName = name;
}
});

}
}
}
114 changes: 98 additions & 16 deletions RpName/RpName.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RpName</RootNamespace>
<AssemblyName>RpName</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -31,55 +34,134 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony, Version=2.2.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Lib.Harmony.2.2.1\lib\net472\0Harmony.dll</HintPath>
<Reference Include="0Harmony, Version=2.10.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\HarmonyX.2.10.0\lib\net45\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SynapseSL.2.9.0\lib\net472\Assembly-CSharp.dll</HintPath>
<HintPath>..\packages\SynapseSL.3.0.0-pre1.0\lib\net48\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SynapseSL.2.9.0\lib\net472\Assembly-CSharp-firstpass.dll</HintPath>
<HintPath>..\packages\SynapseSL.3.0.0-pre1.0\lib\net48\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="LiteDB, Version=5.0.11.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
<HintPath>..\packages\LiteDB.5.0.11\lib\net45\LiteDB.dll</HintPath>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.6.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Caching.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Caching.Abstractions.6.0.0\lib\net461\Microsoft.Extensions.Caching.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Caching.Memory, Version=6.0.0.1, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Caching.Memory.6.0.1\lib\net461\Microsoft.Extensions.Caching.Memory.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.6.0.0\lib\net461\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\lib\net461\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Options, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Options.6.0.0\lib\net461\Microsoft.Extensions.Options.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Primitives, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Primitives.6.0.0\lib\net461\Microsoft.Extensions.Primitives.dll</HintPath>
</Reference>
<Reference Include="Mirror, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SynapseSL.2.9.0\lib\net472\Mirror.dll</HintPath>
<HintPath>..\packages\SynapseSL.3.0.0-pre1.0\lib\net48\Mirror.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil, Version=0.11.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.11.4\lib\net40\Mono.Cecil.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Mdb, Version=0.11.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.11.4\lib\net40\Mono.Cecil.Mdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Pdb, Version=0.11.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.11.4\lib\net40\Mono.Cecil.Pdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Rocks, Version=0.11.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.11.4\lib\net40\Mono.Cecil.Rocks.dll</HintPath>
</Reference>
<Reference Include="MonoMod.RuntimeDetour, Version=22.3.23.4, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MonoMod.RuntimeDetour.22.3.23.4\lib\net452\MonoMod.RuntimeDetour.dll</HintPath>
</Reference>
<Reference Include="MonoMod.Utils, Version=22.3.23.4, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MonoMod.Utils.22.3.23.4\lib\net452\MonoMod.Utils.dll</HintPath>
</Reference>
<Reference Include="Synapse, Version=2.9.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SynapseSL.2.9.0\lib\net472\Synapse.dll</HintPath>
<Reference Include="Neuron.Core, Version=1.0.0.5, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\NeuronModding.Core.1.0.0.5\lib\netstandard2.0\Neuron.Core.dll</HintPath>
</Reference>
<Reference Include="Neuron.Modules.Commands, Version=1.0.0.5, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\NeuronModding.Modules.Commands.1.0.0.5\lib\netstandard2.0\Neuron.Modules.Commands.dll</HintPath>
</Reference>
<Reference Include="Neuron.Modules.Configs, Version=1.0.0.5, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\NeuronModding.Modules.Configs.1.0.0.5\lib\netstandard2.0\Neuron.Modules.Configs.dll</HintPath>
</Reference>
<Reference Include="Neuron.Modules.Patcher, Version=1.0.0.5, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\NeuronModding.Modules.Patcher.1.0.0.5\lib\netstandard2.0\Neuron.Modules.Patcher.dll</HintPath>
</Reference>
<Reference Include="Ninject, Version=3.3.6.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
<HintPath>..\packages\Ninject.3.3.6\lib\net45\Ninject.dll</HintPath>
</Reference>
<Reference Include="SYML, Version=1.0.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SYML.1.0.2\lib\netstandard2.0\SYML.dll</HintPath>
</Reference>
<Reference Include="Synapse3.SynapseModule, Version=3.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\SynapseSL.3.0.0-pre1.0\lib\net48\Synapse3.SynapseModule.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SynapseSL.2.9.0\lib\net472\UnityEngine.dll</HintPath>
<HintPath>..\packages\SynapseSL.3.0.0-pre1.0\lib\net48\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SynapseSL.2.9.0\lib\net472\UnityEngine.CoreModule.dll</HintPath>
<HintPath>..\packages\SynapseSL.3.0.0-pre1.0\lib\net48\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SynapseSL.2.9.0\lib\net472\UnityEngine.PhysicsModule.dll</HintPath>
<HintPath>..\packages\SynapseSL.3.0.0-pre1.0\lib\net48\UnityEngine.PhysicsModule.dll</HintPath>
</Reference>
<Reference Include="YamlDotNet, Version=11.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
<HintPath>..\packages\YamlDotNet.11.2.1\lib\net45\YamlDotNet.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="PluginConfig.cs" />
<Compile Include="RpNameConfig.cs" />
<Compile Include="EventsHandler.cs" />
<Compile Include="PluginClass.cs" />
<Compile Include="RpNamePlugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SetClassPatch.cs" />
<Compile Include="RpNameTranslations.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\build\Microsoft.Extensions.Logging.Abstractions.targets" Condition="Exists('..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\build\Microsoft.Extensions.Logging.Abstractions.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>Ce projet fait référence à des packages NuGet qui sont manquants sur cet ordinateur. Utilisez l'option de restauration des packages NuGet pour les télécharger. Pour plus d'informations, consultez http://go.microsoft.com/fwlink/?LinkID=322105. Le fichier manquant est : {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\build\Microsoft.Extensions.Logging.Abstractions.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\build\Microsoft.Extensions.Logging.Abstractions.targets'))" />
</Target>
</Project>
55 changes: 30 additions & 25 deletions RpName/PluginConfig.cs → RpName/RpNameConfig.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
using System.Collections.Generic;
using Neuron.Core.Meta;
using PlayerRoles;
using Syml;
using System.Collections.Generic;
using System.ComponentModel;

namespace RpName
{
public class PluginConfig
[Automatic]
[DocumentSection("Np Name")]
public class RpNameConfig : IDocumentSection
{
[Description("The id of the role and the new name, ref to the doc of synapse")]
public Dictionary<int, string> RoleName { get; set; } = new Dictionary<int, string>()
public Dictionary<uint, string> RoleName { get; set; } = new Dictionary<uint, string>()
{
{ (int)RoleType.ClassD, "D-%randomNum%%randomNum%%randomNum%%randomNum%-%randomChar%%randomChar% (%playerName%)" },
{ (int)RoleType.Scientist, "Dr %SecondName% %randomChar%. (%playerName%)"},
{ (int)RoleType.NtfCaptain, "Captain %firstName% %SecondName% (%playerName%)"},
{ (int)RoleType.NtfSergeant, "Sergeant %secondName% (%playerName%)" },
{ (int)RoleType.NtfSpecialist, "Specialist %SecondName% (%playerName%)" },
{ (int)RoleType.NtfPrivate, "Private %secondName% (%playerName%)" },
{ (int)RoleType.FacilityGuard, "Security Officer %secondName% (%playerName%)" },
{ (int)RoleType.Scp049, "SCP-049 (%playerName%)" },
{ (int)RoleType.Scp0492, "SCP-049-2 (%playerName%)" },
{ (int)RoleType.Scp079, "SCP-079 (%playerName%)" },
{ (int)RoleType.Scp096, "SCP-096 (%playerName%)" },
{ (int)RoleType.Scp106, "SCP-106 (%playerName%)" },
{ (int)RoleType.Scp173, "SCP-173 (%playerName%)" },
{ (int)RoleType.Scp93953, "SCP-939-53 (%playerName%)" },
{ (int)RoleType.Scp93989, "SCP-939-89 (%playerName%)" },
{ (int)RoleType.ChaosConscript, "Conscript %secondName% (%playerName%)" },
{ (int)RoleType.ChaosMarauder, "Marauder %secondName% (%playerName%)" },
{ (int)RoleType.ChaosRepressor, "Repressor %secondName% (%playerName%)" },
{ (int)RoleType.ChaosRifleman, "Rifleman %secondName% (%playerName%)" },
{ (uint)RoleTypeId.ClassD, "D-%randomNum%%randomNum%%randomNum%%randomNum%-%randomChar%%randomChar% (%playerName%)" },
{ (uint)RoleTypeId.Scientist, "Dr %SecondName% %randomChar%. (%playerName%)"},
{ (uint)RoleTypeId.NtfCaptain, "Captain %firstName% %SecondName% (%playerName%)"},
{ (uint)RoleTypeId.NtfSergeant, "Sergeant %secondName% (%playerName%)" },
{ (uint)RoleTypeId.NtfSpecialist, "Specialist %SecondName% (%playerName%)" },
{ (uint)RoleTypeId.NtfPrivate, "Private %secondName% (%playerName%)" },
{ (uint)RoleTypeId.FacilityGuard, "Security Officer %secondName% (%playerName%)" },
{ (uint)RoleTypeId.Scp049, "SCP-049 (%playerName%)" },
{ (uint)RoleTypeId.Scp0492, "SCP-049-2 (%playerName%)" },
{ (uint)RoleTypeId.Scp079, "SCP-079 (%playerName%)" },
{ (uint)RoleTypeId.Scp096, "SCP-096 (%playerName%)" },
{ (uint)RoleTypeId.Scp106, "SCP-106 (%playerName%)" },
{ (uint)RoleTypeId.Scp173, "SCP-173 (%playerName%)" },
{ (uint)RoleTypeId.Scp939, "SCP-939 (%playerName%)" },
{ (uint)RoleTypeId.ChaosConscript, "Conscript %secondName% (%playerName%)" },
{ (uint)RoleTypeId.ChaosMarauder, "Marauder %secondName% (%playerName%)" },
{ (uint)RoleTypeId.ChaosRepressor, "Repressor %secondName% (%playerName%)" },
{ (uint)RoleTypeId.ChaosRifleman, "Rifleman %secondName% (%playerName%)" },
};

public List<string> FirstName { get; set; } = new List<string>()
Expand Down Expand Up @@ -72,7 +76,7 @@ public class PluginConfig
"Justin",
"Scott",
"Brandon",
"Valentin",//Som Synapse Dev :)
"Valentin",
"Oka",
"Antonio",
"Nils",
Expand All @@ -81,8 +85,9 @@ public class PluginConfig
"Flo",
"Sönke",
"Mathe ",
"Adam", // random name lol
"Mouloud", // I dont ave the name of bonjemus :'(
"Adam",
"Mouloud",
"Cristan"
};

public List<string> SecondName { get; set; } = new List<string>()
Expand Down
Loading

0 comments on commit 896afe8

Please sign in to comment.