-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit fe289af
Showing
11 changed files
with
348 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.vs/ | ||
LeftHandedPlayers/bin | ||
LeftHandedPlayers/obj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.31613.86 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LeftHandedPlayers", "LeftHandedPlayers\LeftHandedPlayers.csproj", "{82EFE8FF-A413-4955-AE94-67F7B2282D0C}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{82EFE8FF-A413-4955-AE94-67F7B2282D0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{82EFE8FF-A413-4955-AE94-67F7B2282D0C}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{82EFE8FF-A413-4955-AE94-67F7B2282D0C}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{82EFE8FF-A413-4955-AE94-67F7B2282D0C}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {EAC269C0-CECF-48F9-8C9D-4FA3001117E1} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System; | ||
using CommandSystem; | ||
using Player = Exiled.API.Features.Player; | ||
using RemoteAdmin; | ||
|
||
namespace LeftHandedPlayers.Commands | ||
{ | ||
[CommandHandler(typeof(ClientCommandHandler))] | ||
public class LeftHanded : ICommand | ||
{ | ||
public string Command { get; } = "lefthanded"; | ||
|
||
public string[] Aliases { get; } = { "left", "lefthand" }; | ||
|
||
public string Description { get; } = "Makes you left handed"; | ||
|
||
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response) | ||
{ | ||
// Converts the command sender to a player object | ||
Player player = Player.Get((PlayerCommandSender)sender); | ||
|
||
// Ensures they are not left handed before applying the change | ||
if (player.Scale == new UnityEngine.Vector3(1, 1, 1)) | ||
{ | ||
// Applies the left hand change | ||
player.Scale = new UnityEngine.Vector3(-1, 1, 1); | ||
|
||
// Checks the player does not have DNT on before adding them to the saved list of left handed players | ||
if (!player.DoNotTrack) LeftHandedPlayers.Instance.LeftHandList.Add(player.UserId); | ||
|
||
// Removes them from the removal list if on it | ||
LeftHandedPlayers.Instance.ToRemoveList.Remove(player.UserId); | ||
|
||
// Informs the player that the command worked | ||
response = "You are now left handed"; | ||
return true; | ||
} | ||
else | ||
{ | ||
// Makes the player no longer appear left handed | ||
player.Scale = new UnityEngine.Vector3(1, 1, 1); | ||
|
||
// Adds them to the removal list if they don't have DNT on and removes from left handed list if on it | ||
if (!player.DoNotTrack) LeftHandedPlayers.Instance.ToRemoveList.Add(player.UserId); | ||
LeftHandedPlayers.Instance.LeftHandList.Remove(player.UserId); | ||
|
||
// Informs the player that the command worked | ||
response = "You are no longer left handed"; | ||
return true; | ||
} | ||
|
||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Exiled.API.Interfaces; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace LeftHandedPlayers | ||
{ | ||
public class Config : IConfig | ||
{ | ||
public bool IsEnabled { get; set; } = true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Exiled.Events.EventArgs; | ||
|
||
namespace LeftHandedPlayers.Handlers | ||
{ | ||
class Player | ||
{ | ||
public void OnVerified(VerifiedEventArgs ev) | ||
{ | ||
// Checks if they are on the list of left handed players | ||
if (LeftHandedPlayers.Instance.LeftHandList.Contains(ev.Player.UserId)) | ||
{ | ||
// Sets them to be left handed | ||
ev.Player.Scale = new UnityEngine.Vector3(-1, 1, 1); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Exiled.Events.EventArgs; | ||
using System.IO; | ||
|
||
namespace LeftHandedPlayers.Handlers | ||
{ | ||
class Server | ||
{ | ||
public void OnRoundEnded(RoundEndedEventArgs ev) | ||
{ | ||
// Reads saved list of left handed people in case of servers on other ports having updated the list | ||
FileStream DataFile = new FileStream(LeftHandedPlayers.DataPath, FileMode.Open); | ||
using (var reader = new StreamReader(DataFile)) | ||
{ | ||
List<string> ReadList; | ||
if (DataFile.Length == 0) ReadList = new List<string>(); | ||
else ReadList = LeftHandedPlayers.Instance.DataLoader.Deserialize<List<string>>(reader); | ||
|
||
// Combines the two lists, removing duplicates and players on the removal list | ||
LeftHandedPlayers.Instance.LeftHandList = LeftHandedPlayers.Instance.LeftHandList.Union(ReadList).Where(id => !LeftHandedPlayers.Instance.ToRemoveList.Contains(id)).ToList(); | ||
} | ||
|
||
// Serializes the data and writes it to the file | ||
using (var writer = new StreamWriter(LeftHandedPlayers.DataPath)) | ||
{ | ||
LeftHandedPlayers.Instance.DataSaver.Serialize(writer, LeftHandedPlayers.Instance.LeftHandList); | ||
} | ||
} | ||
public void OnWaitingForPlayers() | ||
{ | ||
// Loads the list of left-handed players | ||
FileStream DataFile = new FileStream(LeftHandedPlayers.DataPath, FileMode.OpenOrCreate); | ||
using (var reader = new StreamReader(DataFile)) | ||
{ | ||
// Checks if file is empty to ensure data is not deserialized incorrectly | ||
if (DataFile.Length == 0) LeftHandedPlayers.Instance.LeftHandList = new List<string>(); | ||
else LeftHandedPlayers.Instance.LeftHandList = LeftHandedPlayers.Instance.DataLoader.Deserialize<List<string>>(reader); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using Exiled.API.Features; | ||
using Server = Exiled.Events.Handlers.Server; | ||
using Player = Exiled.Events.Handlers.Player; | ||
using Exiled.Loader; | ||
using System; | ||
using YamlDotNet.Serialization; | ||
using System.IO; | ||
using System.Collections.Generic; | ||
|
||
namespace LeftHandedPlayers | ||
{ | ||
public class LeftHandedPlayers : Plugin<Config> | ||
{ | ||
private static LeftHandedPlayers Singleton; | ||
public static LeftHandedPlayers Instance => Singleton; | ||
public override string Author => "TemmieGamerGuy"; | ||
public override string Name => "LeftHandedPlayers"; | ||
public override Version Version => new Version(1, 0, 0); | ||
public override Version RequiredExiledVersion => new Version(3, 0, 0); | ||
|
||
internal static string DataPath; | ||
internal IDeserializer DataLoader; | ||
internal ISerializer DataSaver; | ||
internal List<string> LeftHandList; | ||
internal List<string> ToRemoveList; | ||
|
||
private Handlers.Server server; | ||
private Handlers.Player player; | ||
|
||
public void RegisterEvents() | ||
{ | ||
server = new Handlers.Server(); | ||
player = new Handlers.Player(); | ||
Server.RoundEnded += server.OnRoundEnded; | ||
Server.WaitingForPlayers += server.OnWaitingForPlayers; | ||
Player.Verified += player.OnVerified; | ||
} | ||
|
||
public void UnregisterEvents() | ||
{ | ||
Server.RoundEnded -= server.OnRoundEnded; | ||
Server.WaitingForPlayers -= server.OnWaitingForPlayers; | ||
Player.Verified -= player.OnVerified; | ||
server = null; | ||
player = null; | ||
} | ||
|
||
public override void OnEnabled() | ||
{ | ||
Singleton = this; | ||
DataPath = Paths.Configs + "/" + "LeftHandedData.yml"; | ||
DataLoader = Loader.Deserializer; | ||
DataSaver = Loader.Serializer; | ||
ToRemoveList = new List<string>(); | ||
RegisterEvents(); | ||
base.OnEnabled(); | ||
} | ||
|
||
public override void OnDisabled() | ||
{ | ||
UnregisterEvents(); | ||
DataPath = null; | ||
DataLoader = null; | ||
DataSaver = null; | ||
ToRemoveList = null; | ||
LeftHandList = null; | ||
Singleton = null; | ||
base.OnDisabled(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{82EFE8FF-A413-4955-AE94-67F7B2282D0C}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>LeftHandedPlayers</RootNamespace> | ||
<AssemblyName>LeftHandedPlayers</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Assembly-CSharp-firstpass"> | ||
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Assembly-CSharp-Publicized"> | ||
<HintPath>..\..\publicized\Assembly-CSharp-Publicized.dll</HintPath> | ||
</Reference> | ||
<Reference Include="CommandSystem.Core"> | ||
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\CommandSystem.Core.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Exiled.API"> | ||
<HintPath>..\..\..\..\AppData\Roaming\EXILED\Plugins\dependencies\Exiled.API.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Exiled.Events"> | ||
<HintPath>..\..\..\..\AppData\Roaming\EXILED\Plugins\Exiled.Events.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Exiled.Loader"> | ||
<HintPath>..\..\..\..\AppData\Roaming\EXILED\Exiled.Loader.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Exiled.Permissions"> | ||
<HintPath>..\..\..\..\AppData\Roaming\EXILED\Plugins\Exiled.Permissions.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<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.CoreModule"> | ||
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.CoreModule.dll</HintPath> | ||
</Reference> | ||
<Reference Include="YamlDotNet, Version=11.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\..\..\..\AppData\Roaming\EXILED\Plugins\dependencies\YamlDotNet.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Config.cs" /> | ||
<Compile Include="Commands\LeftHanded.cs" /> | ||
<Compile Include="Handlers\Player.cs" /> | ||
<Compile Include="Handlers\Server.cs" /> | ||
<Compile Include="LeftHandedPlayers.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("LeftHandedPlayers")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("LeftHandedPlayers")] | ||
[assembly: AssemblyCopyright("Copyright © 2021")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("82efe8ff-a413-4955-ae94-67f7b2282d0c")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# LeftHandedPlayers | ||
An SCP:SL EXILED plugin to allow players to be left handed through a .lefthand command |