Skip to content

Commit 0460bbc

Browse files
committed
Add a IsVip feature to the player data class.
1 parent 60ada2f commit 0460bbc

4 files changed

Lines changed: 21 additions & 4 deletions

File tree

CommandInvestigate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public void Execute(IRocketPlayer caller, string[] command)
9595
start++;
9696
if (pData.IsLocal())
9797
{
98-
UnturnedChat.Say(caller, string.Format("{0}: {1} [{2}] ({3}), IP: {4}, Local: {5}", start, caller is ConsolePlayer ? pData.CharacterName : pData.CharacterName.Truncate(12), caller is ConsolePlayer ? pData.SteamName : pData.SteamName.Truncate(12), pData.SteamID, pData.IP, pData.IsLocal()), Color.yellow);
98+
UnturnedChat.Say(caller, string.Format("{0}: {1} [{2}] ({3}), IP: {4}, Local: {5}, IsVip: {6}", start, caller is ConsolePlayer ? pData.CharacterName : pData.CharacterName.Truncate(12), caller is ConsolePlayer ? pData.SteamName : pData.SteamName.Truncate(12), pData.SteamID, pData.IP, pData.IsLocal(), pData.IsVip()), Color.yellow);
9999
UnturnedChat.Say(caller, string.Format("Seen: {0}, TT: {1}, Cleaned:{2}:{3}", pData.LastLoginLocal, pData.TotalPlayime.FormatTotalTime(), pData.CleanedBuildables, pData.CleanedPlayerData), Color.yellow);
100100
}
101101
else

PlayerData.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
using Steamworks;
1+
using Rocket.API;
2+
using Rocket.Core;
3+
using Steamworks;
24
using System;
5+
using System.Linq;
36

47
namespace PlayerInfoLibrary
58
{
@@ -25,6 +28,8 @@ public class PlayerData
2528
/// <returns>true if the data is from this server.</returns>
2629
public bool IsLocal()
2730
{
31+
if (!IsValid())
32+
return false;
2833
return ServerID == PlayerInfoLib.Database.InstanceID;
2934
}
3035

@@ -48,6 +53,17 @@ public bool IsCacheExpired()
4853
return true;
4954
}
5055

56+
/// <summary>
57+
/// Checks players groups against the config value set in the plugin config to see if they're a VIP.
58+
/// </summary>
59+
/// <returns>true if a match is found.</returns>
60+
public bool IsVip()
61+
{
62+
if (!IsValid())
63+
return false;
64+
return R.Permissions.GetGroups(new RocketPlayer(SteamID.ToString()), true).FirstOrDefault(g => g.Id == PlayerInfoLib.Instance.Configuration.Instance.VipCheckGroupName) != null;
65+
}
66+
5167
internal PlayerData()
5268
{
5369
SteamID = CSteamID.Nil;

PlayerInfoLibConfig.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class PlayerInfoLibConfig : IRocketPluginConfiguration
1414
public float CacheTime = 180;
1515
public float ExpiredCheckInterval = 30;
1616
public float ExpiresAfter = 365;
17+
public string VipCheckGroupName = "vip";
1718

1819
public void LoadDefaults() { }
1920
}

Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.3.0.2")]
36-
[assembly: AssemblyFileVersion("1.3.0.2")]
35+
[assembly: AssemblyVersion("1.3.1.0")]
36+
[assembly: AssemblyFileVersion("1.3.1.0")]

0 commit comments

Comments
 (0)