Skip to content

Commit af1db0e

Browse files
authored
end
1 parent ac78ca2 commit af1db0e

File tree

5 files changed

+23
-16
lines changed

5 files changed

+23
-16
lines changed

EffectDisplay/Components/UserEffectDisplayer.cs

+13-10
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,13 @@ public bool IsEnabled
4040
}
4141
}
4242

43-
private string Category(EffectType effectType)
43+
private string Category(StatusEffectBase statusEffectBase)
4444
{
45-
if (effectType == EffectType.Scp207 | effectType == EffectType.AntiScp207)
45+
if (statusEffectBase.Classification == StatusEffectBase.EffectClassification.Mixed)
4646
{
4747
return Plugin.Instance.Config.EffectLine["Mixed"];
4848
}
49-
50-
if (effectType.IsHarmful() || effectType.IsNegative())
49+
if (statusEffectBase.Classification == StatusEffectBase.EffectClassification.Negative)
5150
{
5251
return Plugin.Instance.Config.EffectLine["Negative"];
5352
}
@@ -59,15 +58,19 @@ private string Category(EffectType effectType)
5958

6059
private void Awake()
6160
{
61+
Log.Debug($"{nameof(Awake)} Initing component");
6262
player = Player.Get(gameObject);
63-
if (!player.IsAllow())
63+
Log.Debug(player);
64+
if (player.IsAllow())
6465
{
65-
this.IsEnabled = false;
66-
return;
66+
Log.Debug("Starting Corountine");
67+
Timing.RunCoroutine(PlayerEffectShower(player));
6768
}
6869
else
6970
{
70-
Timing.RunCoroutine(PlayerEffectShower(player));
71+
this.IsEnabled = false;
72+
Timing.KillCoroutines(this.Current);
73+
return;
7174
}
7275
}
7376

@@ -81,6 +84,7 @@ private IEnumerator<float> PlayerEffectShower(Player ply)
8184
// we check whether the effects display has been disabled for the user or whether the player has disconnected
8285
if (ply == null | !ply.IsConnected | !this.Enabled)
8386
{
87+
Log.Debug("Destroy components");
8488
Destroy(this);
8589
break;
8690
}
@@ -91,7 +95,7 @@ private IEnumerator<float> PlayerEffectShower(Player ply)
9195
foreach (StatusEffectBase type in ply.ActiveEffects)
9296
{
9397
string name = Plugin.Instance.Config.GetTranslation(type.GetEffectType());
94-
string line = Category(type.GetEffectType());
98+
string line = $"{Plugin.Instance.Config.HintLocation}{Category(type)}</align>";
9599
// Current end time line
96100
line = type.Duration == 0 ? line.Replace("%time%", "inf") : line.Replace("%time%", ((int)type.TimeLeft).ToString());
97101
// Effect duration total
@@ -100,7 +104,6 @@ private IEnumerator<float> PlayerEffectShower(Player ply)
100104
line = line.Replace("%effect%", name);
101105
output.AppendLine(line);
102106
}
103-
Log.Debug($"{nameof(PlayerEffectShower)} Try to show hint for ply {ply.Nickname}");
104107
ply.ShowHint(output.ToString(), 1);
105108
}
106109
}

EffectDisplay/Configs.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ public class Configs: IConfig
4040
[Description("https://discord.com/channels/656673194693885975/1172647045237067788/1172647045237067788 determines the name of the effect from the existing list to the one you specify")]
4141
public Dictionary<EffectType, string> EffectTranslation { get; set; } = new Dictionary<EffectType, string>()
4242
{
43-
{ EffectType.Blinded, "Blinded" }
43+
{ EffectType.None, "UnkownEffect" }
4444
};
4545

4646
[Description("defines the database name in the path (required at the end of .db)")]
4747
public string DatabaseName { get; set; } = "data.db";
4848

49-
[Description("locates the database")]
49+
[Description("folder location current database")]
5050
public string PathToDataBase { get; set; } = Path.Combine(Paths.Configs, "EffectDisplay");
5151
[Description("List of roles for which the effects display will not be displayed (the roles of the dead are ignored)")]
5252
public List<RoleTypeId> IgnoredRoles { get; set; } = new List<RoleTypeId>()
@@ -56,7 +56,7 @@ public class Configs: IConfig
5656
};
5757

5858
/// <summary>
59-
/// Return effect name from <see cref="EffectTranslation"/> and if not found in it return <see cref="EffectType"/> as <see cref="string"></see>
59+
/// Return effect name from <see cref="EffectTranslation"/> if not found return <see cref="EffectType"/> as <see cref="string"></see>
6060
/// </summary>
6161
public string GetTranslation(EffectType effectType)
6262
{

EffectDisplay/EventHandler/PlayerEvent.cs

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using EffectDisplay.Components;
2+
using Exiled.API.Features;
23
using Exiled.Events.EventArgs.Player;
34

45
namespace EffectDisplay.EventHandler
@@ -7,7 +8,9 @@ public class PlayerEvent
78
{
89
public void OnVerefied(VerifiedEventArgs e)
910
{
11+
Log.Debug(e.Player);
1012
e.Player?.GameObject.AddComponent<UserEffectDisplayer>();
13+
Log.Debug($"{nameof(OnVerefied)} Added {nameof(UserEffectDisplayer)} components");
1114
}
1215
}
1316
}

EffectDisplay/Features/DataBase.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using LiteDB;
22
using System;
33
using EffectDisplay.Features.Sereliazer;
4+
using Exiled.API.Features;
45

56
namespace EffectDisplay.Features
67
{
@@ -74,7 +75,8 @@ public bool IsAllow(string userid)
7475
{
7576
ILiteCollection<User> users = db.GetCollection<User>("users");
7677
User user = users.FindOne(x => x.UserId == userid);
77-
return user == null ? false : user.IsAllow;
78+
Log.Debug(user);
79+
return user is null ? true : user.IsAllow;
7880
}
7981
/// <summary>
8082
/// Clear all resources and save data base

EffectDisplay/Plugin.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class Plugin : Plugin<Configs>
1515

1616
public override Version Version { get; } = new Version(2, 0, 1);
1717

18-
public override Version RequiredExiledVersion { get; } = new Version(9, 0, 0);
18+
public override Version RequiredExiledVersion { get; } = new Version(8, 9, 0);
1919

2020
public override bool IgnoreRequiredVersionCheck { get; } = false;
2121

@@ -63,7 +63,6 @@ protected void UnsubscribeEvents()
6363
/// </summary>
6464
private void CheckDataBase()
6565
{
66-
Log.Debug($"{nameof(CheckDataBase)} Checking existing data base");
6766
if (!this.Config.IsDatabaseUse)
6867
{
6968
Log.Warn("Database usage is disabled, players will not be able to enable effects display");

0 commit comments

Comments
 (0)