Skip to content

Commit 6ea7c1d

Browse files
authored
version 2.0 and full rebuild
1 parent 720e564 commit 6ea7c1d

File tree

11 files changed

+572
-0
lines changed

11 files changed

+572
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
using CustomPlayerEffects;
2+
using EffectDisplay.Extensions;
3+
using Exiled.API.Enums;
4+
using Exiled.API.Extensions;
5+
using Exiled.API.Features;
6+
using MEC;
7+
using System;
8+
using System.Collections.Generic;
9+
using System.Linq;
10+
using System.Text;
11+
using System.Threading.Tasks;
12+
using UnityEngine;
13+
14+
namespace EffectDisplay.Components
15+
{
16+
public class UserEffectDisplayer: MonoBehaviour
17+
{
18+
private Player player;
19+
20+
private string Category(EffectType effectType)
21+
{
22+
if (effectType == EffectType.Scp207 | effectType == EffectType.AntiScp207)
23+
{
24+
return Plugin.Instance.Config.MixedEffect;
25+
}
26+
27+
if (effectType.IsHarmful() || effectType.IsNegative())
28+
{
29+
return Plugin.Instance.Config.BadEffect;
30+
}
31+
else
32+
{
33+
return Plugin.Instance.Config.GoodEffect;
34+
}
35+
}
36+
37+
private void Awake()
38+
{
39+
player = Player.Get(gameObject);
40+
if (!player.DataChoise())
41+
{
42+
return;
43+
}
44+
else
45+
{
46+
Timing.RunCoroutine(PlayerEffectShower(player));
47+
}
48+
}
49+
50+
private IEnumerator<float> PlayerEffectShower(Player ply)
51+
{
52+
for (; ; )
53+
{
54+
StringBuilder output = new StringBuilder();
55+
output.Append("\n\n\n\n");
56+
if (ply == null || !ply.IsConnected | !ply.DataChoise())
57+
{
58+
Destroy(this);
59+
break;
60+
}
61+
else
62+
{
63+
foreach (StatusEffectBase type in ply.ActiveEffects)
64+
{
65+
EffectType effect = type.GetEffectType();
66+
string name = "";
67+
if (Plugin.Instance.Config.EffectTranslation.ContainsKey(effect))
68+
{
69+
name = Plugin.Instance.Config.EffectTranslation[effect];
70+
}
71+
if (!Plugin.Instance.Config.EffectTranslation.ContainsKey(effect))
72+
{
73+
name = effect.ToString();
74+
}
75+
string line = $"{Plugin.Instance.Config.HintLocation}{Plugin.Instance.Config.EffectLineMessage.Replace("%effect%", name)}</align>";
76+
if (type.Duration < 0.1)
77+
{
78+
line = line.Replace("%time%", "inf");
79+
}
80+
if (type.Duration > 0.1)
81+
{
82+
line = line.Replace("%time%", ((int)type.TimeLeft).ToString());
83+
}
84+
line = line.Replace("%type%", Category(effect));
85+
output.AppendLine(line);
86+
}
87+
Log.Debug($"Try to show hint for ply {ply.Nickname}");
88+
ply.ShowHint(output.ToString(), 1);
89+
}
90+
yield return Timing.WaitForSeconds(0.9f);
91+
}
92+
}
93+
}
94+
}

EffectDisplay/Configs.cs

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using Exiled.API.Enums;
2+
using Exiled.API.Features;
3+
using Exiled.API.Interfaces;
4+
using JetBrains.Annotations;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.ComponentModel;
8+
using System.IO;
9+
using System.Security.Policy;
10+
11+
namespace EffectDisplay
12+
{
13+
public class Configs: IConfig
14+
{
15+
[Description("will the plugin be active?")]
16+
public bool IsEnabled { get; set; } = true;
17+
[Description("will information be displayed for the developer, will help when errors are detected")]
18+
public bool Debug { get; set; } = false;
19+
[Description("will a database be used")]
20+
public bool IsDatabaseUse { get; set; } = true;
21+
[Description("This message will be displayed on each line")]
22+
public string EffectLineMessage { get; set; } = "<size=12>%effect% is %type% end after %time% second's</size>";
23+
[Description("effects combining harm and benefit and nothing (207 and its anti)")]
24+
public string MixedEffect { get; set; } = "<color=purple>Mixed</color>";
25+
[Description("Only good effect")]
26+
public string GoodEffect { get; set; } = "<color=green>Positive</color>";
27+
[Description("Only bad effect")]
28+
public string BadEffect { get; set; } = "<color=red>Negative</color>";
29+
[Description("decomposes the text on the screen to change only to what is processed by align")]
30+
public string HintLocation { get; set; } = "<align=left>";
31+
[Description("defines a list of effects that the player will not see (the effects of the technical process are automatically hidden)")]
32+
public List<EffectType> BlackList { get; set; } = new List<EffectType>()
33+
{
34+
EffectType.InsufficientLighting,
35+
EffectType.SoundtrackMute
36+
};
37+
[Description("https://discord.com/channels/656673194693885975/1172647045237067788/1172647045237067788 determines the name of the effect from the existing list to the one you specify")]
38+
public Dictionary<EffectType, string> EffectTranslation { get; set; } = new Dictionary<EffectType, string>()
39+
{
40+
{ EffectType.Blinded, "Blinded" }
41+
};
42+
[Description("defines the database name in the path (required at the end of .db)")]
43+
public string DatabaseName { get; set; } = "data.db";
44+
[Description("locates the database")]
45+
public string PathToDataBase { get; set; } = Path.Combine(Paths.Configs, "EffectDisplay");
46+
}
47+
}

EffectDisplay/EffectDisplay.csproj

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{859B2CE7-9C9C-4CDA-B2D1-6AFAB4724063}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>EffectDisplay</RootNamespace>
11+
<AssemblyName>EffectDisplay</AssemblyName>
12+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<DebugType>pdbonly</DebugType>
27+
<Optimize>true</Optimize>
28+
<OutputPath>bin\Release\</OutputPath>
29+
<DefineConstants>TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
</PropertyGroup>
33+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
34+
<DebugSymbols>true</DebugSymbols>
35+
<OutputPath>bin\x64\Debug\</OutputPath>
36+
<DefineConstants>DEBUG;TRACE</DefineConstants>
37+
<DebugType>full</DebugType>
38+
<PlatformTarget>x64</PlatformTarget>
39+
<LangVersion>7.3</LangVersion>
40+
<ErrorReport>prompt</ErrorReport>
41+
</PropertyGroup>
42+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
43+
<OutputPath>bin\x64\Release\</OutputPath>
44+
<DefineConstants>TRACE</DefineConstants>
45+
<Optimize>true</Optimize>
46+
<DebugType>pdbonly</DebugType>
47+
<PlatformTarget>x64</PlatformTarget>
48+
<LangVersion>7.3</LangVersion>
49+
<ErrorReport>prompt</ErrorReport>
50+
</PropertyGroup>
51+
<ItemGroup>
52+
<Reference Include="0Harmony">
53+
<HintPath>..\..\..\..\AppData\Roaming\EXILED\Plugins\dependencies\0Harmony.dll</HintPath>
54+
</Reference>
55+
<Reference Include="Assembly-CSharp">
56+
<HintPath>..\packages\EXILED.8.9.2\lib\net48\Assembly-CSharp-Publicized.dll</HintPath>
57+
<Private>True</Private>
58+
</Reference>
59+
<Reference Include="Assembly-CSharp-firstpass">
60+
<HintPath>D:\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
61+
</Reference>
62+
<Reference Include="CommandSystem.Core, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
63+
<HintPath>..\packages\EXILED.8.9.2\lib\net48\CommandSystem.Core.dll</HintPath>
64+
</Reference>
65+
<Reference Include="Exiled.API, Version=8.9.2.0, Culture=neutral, processorArchitecture=AMD64">
66+
<HintPath>..\packages\EXILED.8.9.2\lib\net48\Exiled.API.dll</HintPath>
67+
</Reference>
68+
<Reference Include="Exiled.CreditTags, Version=8.9.2.0, Culture=neutral, processorArchitecture=AMD64">
69+
<HintPath>..\packages\EXILED.8.9.2\lib\net48\Exiled.CreditTags.dll</HintPath>
70+
</Reference>
71+
<Reference Include="Exiled.CustomItems, Version=8.9.2.0, Culture=neutral, processorArchitecture=AMD64">
72+
<HintPath>..\packages\EXILED.8.9.2\lib\net48\Exiled.CustomItems.dll</HintPath>
73+
</Reference>
74+
<Reference Include="Exiled.CustomRoles, Version=8.9.2.0, Culture=neutral, processorArchitecture=AMD64">
75+
<HintPath>..\packages\EXILED.8.9.2\lib\net48\Exiled.CustomRoles.dll</HintPath>
76+
</Reference>
77+
<Reference Include="Exiled.Events, Version=8.9.2.0, Culture=neutral, processorArchitecture=AMD64">
78+
<HintPath>..\packages\EXILED.8.9.2\lib\net48\Exiled.Events.dll</HintPath>
79+
</Reference>
80+
<Reference Include="Exiled.Loader, Version=8.9.2.0, Culture=neutral, processorArchitecture=AMD64">
81+
<HintPath>..\packages\EXILED.8.9.2\lib\net48\Exiled.Loader.dll</HintPath>
82+
</Reference>
83+
<Reference Include="Exiled.Permissions, Version=8.9.2.0, Culture=neutral, processorArchitecture=AMD64">
84+
<HintPath>..\packages\EXILED.8.9.2\lib\net48\Exiled.Permissions.dll</HintPath>
85+
</Reference>
86+
<Reference Include="LiteDB, Version=5.0.16.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
87+
<HintPath>..\packages\LiteDB.5.0.16\lib\net45\LiteDB.dll</HintPath>
88+
</Reference>
89+
<Reference Include="Mirror">
90+
<HintPath>D:\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Mirror.dll</HintPath>
91+
</Reference>
92+
<Reference Include="NorthwoodLib, Version=1.3.0.0, Culture=neutral, processorArchitecture=MSIL">
93+
<HintPath>..\packages\EXILED.8.9.2\lib\net48\NorthwoodLib.dll</HintPath>
94+
</Reference>
95+
<Reference Include="PluginAPI, Version=13.1.2.0, Culture=neutral, processorArchitecture=AMD64">
96+
<HintPath>..\packages\EXILED.8.9.2\lib\net48\PluginAPI.dll</HintPath>
97+
</Reference>
98+
<Reference Include="System" />
99+
<Reference Include="System.Core" />
100+
<Reference Include="System.Xml.Linq" />
101+
<Reference Include="System.Data.DataSetExtensions" />
102+
<Reference Include="Microsoft.CSharp" />
103+
<Reference Include="System.Data" />
104+
<Reference Include="System.Net.Http" />
105+
<Reference Include="System.Xml" />
106+
<Reference Include="UnityEngine">
107+
<HintPath>D:\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.dll</HintPath>
108+
</Reference>
109+
<Reference Include="UnityEngine.CoreModule">
110+
<HintPath>D:\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
111+
</Reference>
112+
<Reference Include="UnityEngine.PhysicsModule">
113+
<HintPath>D:\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
114+
</Reference>
115+
<Reference Include="YamlDotNet, Version=11.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
116+
<HintPath>..\packages\EXILED.8.9.2\lib\net48\YamlDotNet.dll</HintPath>
117+
</Reference>
118+
</ItemGroup>
119+
<ItemGroup>
120+
<Compile Include="commands\display.cs" />
121+
<Compile Include="Components\UserEffectDisplayer.cs" />
122+
<Compile Include="Configs.cs" />
123+
<Compile Include="EventHandler\PlayerEvent.cs" />
124+
<Compile Include="Extensions\PlayerExtensions.cs" />
125+
<Compile Include="Features\DataBase.cs" />
126+
<Compile Include="Features\Sereliazer\User.cs" />
127+
<Compile Include="Plugin.cs" />
128+
<Compile Include="Properties\AssemblyInfo.cs" />
129+
</ItemGroup>
130+
<ItemGroup>
131+
<None Include="packages.config" />
132+
</ItemGroup>
133+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
134+
</Project>
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using EffectDisplay.Components;
2+
using Exiled.API.Features;
3+
using Exiled.Events.EventArgs.Player;
4+
using MEC;
5+
6+
namespace EffectDisplay.EventHandler
7+
{
8+
public class PlayerEvent
9+
{
10+
public void OnVerefied(VerifiedEventArgs e)
11+
{
12+
if (e.Player == null | e.Player.GameObject.GetComponent<UserEffectDisplayer>() != null)
13+
{
14+
return;
15+
}
16+
else
17+
{
18+
e.Player.GameObject.AddComponent<UserEffectDisplayer>();
19+
}
20+
}
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Exiled.API.Features;
2+
3+
namespace EffectDisplay.Extensions
4+
{
5+
public static class PlayerExtensions
6+
{
7+
/// <summary>
8+
/// determines the user's choice of displaying effect status
9+
/// </summary>
10+
/// <param name="player"></param>
11+
/// <returns>true if is allow or false</returns>
12+
public static bool DataChoise(this Player player) => Plugin.data.IsAllow(player.UserId);
13+
14+
}
15+
}

EffectDisplay/Features/DataBase.cs

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
using LiteDB;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using EffectDisplay.Features.Sereliazer;
7+
8+
namespace EffectDisplay.Features
9+
{
10+
public class DataBase: IDisposable
11+
{
12+
private string Path;
13+
14+
private LiteDatabase db;
15+
16+
public DataBase()
17+
{
18+
Path = System.IO.Path.Combine(Plugin.Instance.Config.PathToDataBase, Plugin.Instance.Config.DatabaseName);
19+
db = new LiteDatabase(Path);
20+
}
21+
22+
private void MemberCheck(string UserId)
23+
{
24+
ILiteCollection<User> users = db.GetCollection<User>("users");
25+
User user = users.FindOne(x => x.UserId == UserId);
26+
if (user == null)
27+
{
28+
user = new User();
29+
user.UserId = UserId;
30+
users.Upsert(user);
31+
}
32+
33+
db.Commit();
34+
}
35+
/// <summary>
36+
/// Set IsAllow parament"/>
37+
/// </summary>
38+
/// <param name="userid">user steam id to update</param>
39+
/// <param name="allow">our argument</param>
40+
public void SetAllowTo(string userid, bool allow)
41+
{
42+
ILiteCollection<User> users = db.GetCollection<User>("users");
43+
MemberCheck(userid);
44+
User user = users.FindOne(x => x.UserId == userid);
45+
user.IsAllow = allow;
46+
users.Update(user);
47+
db.Commit();
48+
}
49+
/// <summary>
50+
/// Get IsAllow parametr
51+
/// </summary>
52+
/// <param name="userid">user steam id</param>
53+
/// <returns></returns>
54+
public bool IsAllow(string userid)
55+
{
56+
ILiteCollection<User> users = db.GetCollection<User>("users");
57+
User user = users.FindOne(x => x.UserId == userid);
58+
if (user == null)
59+
{
60+
return true;
61+
}
62+
else
63+
{
64+
return user.IsAllow;
65+
}
66+
}
67+
68+
public void Dispose()
69+
{
70+
this.SaveData();
71+
db = null;
72+
Path = null;
73+
}
74+
75+
public void SaveData()
76+
{
77+
db.Commit();
78+
db.Dispose();
79+
}
80+
}
81+
}

0 commit comments

Comments
 (0)