Skip to content

Commit 80d5cb5

Browse files
authored
Add files via upload
1 parent 3271e0c commit 80d5cb5

File tree

7 files changed

+61
-87
lines changed

7 files changed

+61
-87
lines changed

Components/UserEffectDisplayer.cs

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using EffectDisplay.Extensions;
2-
using EffectDisplay.Features;
32

43
using Exiled.API.Extensions;
54
using Exiled.API.Features;
@@ -17,7 +16,6 @@ namespace EffectDisplay.Components
1716
{
1817
public class UserEffectDisplayer: MonoBehaviour
1918
{
20-
private MeowHintManager meow;
2119
private Player player;
2220
/// <summary>
2321
/// Stores the current process for future stopping
@@ -64,19 +62,9 @@ private void Awake()
6462
}
6563
}
6664

67-
private void ShowMeowHint(string text)
68-
{
69-
if (meow != null)
70-
{
71-
MeowHintManager.RemoveHint(player, meow.GetHintProcessionObject());
72-
meow = null;
73-
}
74-
meow = new MeowHintManager(text, "EffectDisplay", Plugin.Instance.Config.MeowHintSettings);
75-
MeowHintManager.AddHint(player, meow.GetHintProcessionObject());
76-
}
77-
7865
private IEnumerator<float> PlayerEffectShower()
7966
{
67+
Configs cfg = Plugin.Instance.Config;
8068
for (; ; )
8169
{
8270
if (player == null)
@@ -96,10 +84,6 @@ private IEnumerator<float> PlayerEffectShower()
9684
}
9785
if (player.ActiveEffects.Where(x => !Plugin.Instance.Config.BlackList.Contains(x.GetEffectType())).Count() == 0)
9886
{
99-
if (meow != null)
100-
{
101-
meow = null;
102-
}
10387
yield return Timing.WaitForSeconds(0.1f);
10488
continue;
10589
}
@@ -111,11 +95,11 @@ private IEnumerator<float> PlayerEffectShower()
11195
if (Plugin.Instance.Config.BlackList.Contains(item.GetEffectType())) continue;
11296
try
11397
{
114-
string processingline = Plugin.Instance.Config.EffectLine[item.Classification];
115-
if (string.IsNullOrEmpty(processingline)) continue;
116-
processingline = processingline.Replace("%time%", item.Duration == 0 ? "inf" : ((int)item.TimeLeft).ToString());
117-
processingline = processingline.Replace("%duration%", item.Duration == 0 ? "inf" : item.Duration.ToString());
118-
processingline = processingline.Replace("%effect%", Plugin.Instance.Config.GetName(item.GetEffectType()));
98+
string processingline = cfg.EffectLine[item.Classification];
99+
if (string.IsNullOrWhiteSpace(processingline)) continue;
100+
processingline = processingline.Replace("%time%", (int)item.Duration == 0 ? "inf" : ((int)item.TimeLeft).ToString());
101+
processingline = processingline.Replace("%duration%", (int)item.Duration == 0 ? "inf" : item.Duration.ToString());
102+
processingline = processingline.Replace("%effect%", cfg.GetName(item.GetEffectType()));
119103
processingline = processingline.Replace("%intensity%", item.Intensity.ToString());
120104
Log.Debug($"{nameof(PlayerEffectShower)}: Line {processingline} created");
121105
InfoLine.AppendLine(processingline);
@@ -134,22 +118,15 @@ private IEnumerator<float> PlayerEffectShower()
134118
Log.Debug(data);
135119
try
136120
{
137-
if (Plugin.HintServiceMeowDetected)
138-
{
139-
ShowMeowHint(data);
140-
}
141-
else
142-
{
143-
data = $"<size={Plugin.Instance.Config.NativeHintSettings.FontSize}><align={Plugin.Instance.Config.NativeHintSettings.Aligment}>" + data + "</size></align>";
144-
player.ShowHint(data, 1f + (float)(player.Ping / 100f)); // display a message taking into account the player's ping for a smooth update
145-
}
121+
data = $"<size={cfg.NativeHintSettings.FontSize}><align={cfg.NativeHintSettings.Aligment}>" + data + "</size></align>";
122+
player.ShowHint(data, 1f + (float)(player.Ping / 100f)); // display a message taking into account the player's ping for a smooth update
146123
}
147124
catch (Exception e)
148125
{
149126
Log.Debug($"{nameof(PlayerEffectShower)}: Exception {e.Message}");
150127
}
151128
Log.Debug($"{nameof(PlayerEffectShower)}: Iteration {player.Nickname}: processed.");
152-
yield return Timing.WaitForSeconds(Plugin.Instance.Config.UpdateTime);
129+
yield return Timing.WaitForSeconds(cfg.UpdateTime);
153130
}
154131
}
155132
}

Configs.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class Configs: IConfig
2121
[Description("will merge with other Hint service providers (for example HintServiceMeow) - if they are installed, it will switch itself")]
2222
public bool ThirdParty { get; set; } = true;
2323
[Description("will a database be used")]
24-
public bool IsDatabaseUse { get; set; } = true;
24+
public bool DataBaseEnabled { get; set; } = true;
2525
[Description("the time period for which information is updated")]
2626
public float UpdateTime { get; set; } = 0.9f;
2727
[Description("these lines will be displayed for each effect type separately, allowing you to customize them")]
@@ -56,8 +56,6 @@ public class Configs: IConfig
5656
};
5757
[Description("Standard settings for displaying information, used in the absence of any supported Hint providers")]
5858
public NativeHintSettings NativeHintSettings { get; set; } = new NativeHintSettings();
59-
[Description("If you use MeowHintService for Exiled then these settings will be useful for customizing the display")]
60-
public MeowHintSettings MeowHintSettings { get; set; } = new MeowHintSettings();
6159
[Description("What text will the user see when hovering over a question mark in the settings?")]
6260
public string EnabledDisplayDescription { get; set; } = "Determines whether the display of enabled effects is enabled, replaces .display in the console";
6361
[Description("Will the plugin notify you of a new update")]
@@ -79,7 +77,12 @@ public class Configs: IConfig
7977
/// </summary>
8078
public string GetName(EffectType effectType)
8179
{
82-
return EffectTranslation.ContainsKey(effectType) ? EffectTranslation[effectType] : effectType.ToString();
80+
string name = string.Empty;
81+
if (EffectTranslation.TryGetValue(effectType, out name))
82+
{
83+
return name;
84+
}
85+
return effectType.ToString();
8386
}
8487
}
8588
}

EffectDisplay.csproj

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,19 @@
4141
<ErrorReport>prompt</ErrorReport>
4242
<WarningLevel>4</WarningLevel>
4343
</PropertyGroup>
44+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Meow|AnyCPU'">
45+
<DebugType>pdbonly</DebugType>
46+
<Optimize>true</Optimize>
47+
<OutputPath>bin\Debug\</OutputPath>
48+
<DefineConstants>DEBUG;TRACE;Meow</DefineConstants>
49+
<ErrorReport>prompt</ErrorReport>
50+
<WarningLevel>4</WarningLevel>
51+
<AssemblyName>EffectDisplay-Meow</AssemblyName>
52+
</PropertyGroup>
4453
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
4554
<DebugSymbols>true</DebugSymbols>
4655
<OutputPath>bin\x64\Debug\</OutputPath>
47-
<DefineConstants>TRACE</DefineConstants>
56+
<DefineConstants>TRACE;Meow</DefineConstants>
4857
<DebugType>full</DebugType>
4958
<PlatformTarget>x64</PlatformTarget>
5059
<LangVersion>7.3</LangVersion>
@@ -59,6 +68,19 @@
5968
<LangVersion>7.3</LangVersion>
6069
<ErrorReport>prompt</ErrorReport>
6170
</PropertyGroup>
71+
<PropertyGroup>
72+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
73+
</PropertyGroup>
74+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'MeowBuild|AnyCPU'">
75+
<OutputPath>bin\MeowBuild\</OutputPath>
76+
</PropertyGroup>
77+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'MeowBuild|x64'">
78+
<OutputPath>bin\x64\MeowBuild\</OutputPath>
79+
</PropertyGroup>
80+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Meow|x64'">
81+
<OutputPath>bin\Meow\</OutputPath>
82+
<DefineConstants>TRACE;DEBUG;Meow</DefineConstants>
83+
</PropertyGroup>
6284
<ItemGroup>
6385
<Reference Include="0Harmony">
6486
<HintPath>..\..\..\..\AppData\Roaming\EXILED\Plugins\dependencies\0Harmony.dll</HintPath>
@@ -143,8 +165,6 @@
143165
<Compile Include="Extensions\PlayerExtensions.cs" />
144166
<Compile Include="Features\DataBase.cs" />
145167
<Compile Include="Features\GitHubUpdater.cs" />
146-
<Compile Include="Features\MeowHintManager.cs" />
147-
<Compile Include="Features\Sereliazer\MeowHintSettings.cs" />
148168
<Compile Include="Features\Sereliazer\NativeHintSettings.cs" />
149169
<Compile Include="Features\Sereliazer\User.cs" />
150170
<Compile Include="Plugin.cs" />
@@ -154,6 +174,7 @@
154174
<None Include="app.config" />
155175
<None Include="packages.config" />
156176
</ItemGroup>
177+
<ItemGroup />
157178
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
158179
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
159180
<PropertyGroup>

EffectDisplay.sln

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio Version 17
33
VisualStudioVersion = 17.5.2.0
44
MinimumVisualStudioVersion = 10.0.40219.1
5-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EffectDisplay", "EffectDisplay.csproj", "{7B9E9E25-73F0-5B6D-EBCF-26EAA67FC230}"
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EffectDisplay", "EffectDisplay.csproj", "{859B2CE7-9C9C-4CDA-B2D1-6AFAB4724063}"
66
EndProject
77
Global
88
GlobalSection(SolutionConfigurationPlatforms) = preSolution
99
Debug|Any CPU = Debug|Any CPU
1010
Release|Any CPU = Release|Any CPU
1111
EndGlobalSection
1212
GlobalSection(ProjectConfigurationPlatforms) = postSolution
13-
{7B9E9E25-73F0-5B6D-EBCF-26EAA67FC230}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
14-
{7B9E9E25-73F0-5B6D-EBCF-26EAA67FC230}.Debug|Any CPU.Build.0 = Debug|Any CPU
15-
{7B9E9E25-73F0-5B6D-EBCF-26EAA67FC230}.Release|Any CPU.ActiveCfg = Release|Any CPU
16-
{7B9E9E25-73F0-5B6D-EBCF-26EAA67FC230}.Release|Any CPU.Build.0 = Release|Any CPU
13+
{859B2CE7-9C9C-4CDA-B2D1-6AFAB4724063}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
14+
{859B2CE7-9C9C-4CDA-B2D1-6AFAB4724063}.Debug|Any CPU.Build.0 = Debug|Any CPU
15+
{859B2CE7-9C9C-4CDA-B2D1-6AFAB4724063}.Release|Any CPU.ActiveCfg = Release|Any CPU
16+
{859B2CE7-9C9C-4CDA-B2D1-6AFAB4724063}.Release|Any CPU.Build.0 = Release|Any CPU
1717
EndGlobalSection
1818
GlobalSection(SolutionProperties) = preSolution
1919
HideSolutionNode = FALSE

Plugin.cs

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
using EffectDisplay.EventHandler;
22
using EffectDisplay.Features;
33
using Exiled.API.Features;
4-
using Exiled.API.Features.Core.UserSettings;
5-
using Exiled.Loader;
64

7-
using MEC;
85
using System;
96
using System.IO;
10-
using System.Linq;
117
using System.Threading.Tasks;
128

13-
using UnityEngine;
14-
159
namespace EffectDisplay
1610
{
1711
public class Plugin : Plugin<Configs>
@@ -20,7 +14,7 @@ public class Plugin : Plugin<Configs>
2014

2115
public override string Name { get; } = "EffectDisplay";
2216

23-
public override Version Version { get; } = new Version(2, 6, 0);
17+
public override Version Version { get; } = new Version(2, 8, 0);
2418

2519
public override Version RequiredExiledVersion { get; } = new Version(9, 0, 0);
2620

@@ -41,23 +35,20 @@ public override void OnEnabled()
4135
DBCondition();
4236
Instance = this;
4337
iUpdater = new GithubUpdater("NOTIF-API", "EffectDisplay");
44-
// if not delayed exception called
45-
Timing.CallDelayed(0.5f, () => {
46-
data = new DataBase();
47-
});
38+
data = new DataBase();
4839
Event = new PlayerEvent();
4940
SubscribeEvents();
5041
base.OnEnabled();
51-
// for no stack when enabling
42+
// Background update task.
5243
Task.Run(() =>
5344
{
5445
Version latest = iUpdater.Version;
5546
if (latest == null || latest == new Version(0, 0, 0)) return;
47+
Log.Debug($"Current version: [{this.Version.ToString()}] latest version detected is {latest.ToString()}");
5648
if (Version >= latest) return;
5749
Log.Warn("New version of EffectDisplay plugin found");
5850
});
5951
}
60-
6152
public override void OnDisabled()
6253
{
6354
iUpdater = null;
@@ -74,39 +65,21 @@ protected void SubscribeEvents()
7465
{
7566
Log.Debug($"{nameof(SubscribeEvents)}: Subscribe to the event.");
7667
Exiled.Events.Handlers.Player.Verified += Event.OnVerefied;
77-
Exiled.Events.Handlers.Server.WaitingForPlayers += OnWaitingForPlayers;
78-
}
79-
/// <summary>
80-
/// needed to check the presence of third-party plugins after they are fully loaded.
81-
/// Also to notify about new updates.
82-
/// </summary>
83-
private void OnWaitingForPlayers()
84-
{
85-
if (Config.ThirdParty)
86-
{
87-
if (Loader.Plugins.Where(x => x.Name == "HintServiceMeow").FirstOrDefault() != null)
88-
{
89-
HintServiceMeowDetected = true;
90-
Log.Info($"{nameof(OnWaitingForPlayers)}: A third-party provider has been detected. The Hint plugin will be adjusted to work with it automatically.");
91-
Log.Info($"{nameof(OnWaitingForPlayers)}: When testing finded bug with broken chars displaying.");
92-
}
93-
}
9468
}
9569

9670
protected void UnsubscribeEvents()
9771
{
9872
Log.Debug($"{nameof(UnsubscribeEvents)}: Unsubscribe from events.");
9973
Exiled.Events.Handlers.Player.Verified -= Event.OnVerefied;
100-
Exiled.Events.Handlers.Server.WaitingForPlayers -= OnWaitingForPlayers;
10174
}
10275
/// <summary>
10376
/// Checks whether the conditions for working with the database are satisfied and restores missing files if necessary
10477
/// </summary>
10578
private void DBCondition()
10679
{
107-
if (!this.Config.IsDatabaseUse)
80+
if (!this.Config.DataBaseEnabled)
10881
{
109-
Log.Warn($"{nameof(DBCondition)}: DB usage is disabled by configuration.");
82+
Log.Warn($"{nameof(DBCondition)}: Database usage has been disabled in the plugin configuration!");
11083
return;
11184
}
11285
else
@@ -115,15 +88,15 @@ private void DBCondition()
11588
// if folder do not detected creating it with file
11689
if (!Directory.Exists(this.Config.PathToDataBase))
11790
{
91+
Log.Warn($"{nameof(DBCondition)}: The directory with the database from EffectDisplay was not found, we are creating a directory and a file.");
11892
Directory.CreateDirectory(this.Config.PathToDataBase);
119-
File.Create(file_path);
120-
Log.Warn($"{nameof(DBCondition)}: The directory with the database file is missing.");
93+
File.Create(file_path).Close();
12194
return;
12295
}
12396
if (!File.Exists(file_path))
12497
{
125-
Log.Warn($"{nameof(DBCondition)}: DB file is missing.");
126-
File.Create(file_path);
98+
Log.Warn($"{nameof(DBCondition)}: The database file was not found.");
99+
File.Create(file_path).Close();
127100
}
128101
}
129102
}

Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// Можно задать все значения или принять номера сборки и редакции по умолчанию
3333
// используя "*", как показано ниже:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.5.0.0")]
36-
[assembly: AssemblyFileVersion("2.6.0.0")]
35+
[assembly: AssemblyVersion("2.7.0.0")]
36+
[assembly: AssemblyFileVersion("2.7.0.0")]

commands/display.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ public class display : ICommand
1919
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
2020
{
2121
Player ply = Player.Get(sender);
22-
if ( !Plugin.Instance.Config.IsDatabaseUse )
23-
{
24-
response = "The specified server does not have this function.";
25-
return false;
22+
if ( !Plugin.Instance.Config.DataBaseEnabled )
23+
{
24+
response = "The specified server does not have this function.";
25+
return false;
2626
}
2727
bool flag = !Plugin.data.IsAllow(ply.UserId);
2828
Plugin.data.IsAllow(ply.UserId, flag);

0 commit comments

Comments
 (0)