Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
13.8-16 Updated to Scopophobia
Browse files Browse the repository at this point in the history
  • Loading branch information
Rnen committed Jul 26, 2020
1 parent 9c9d80a commit bbe9622
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 6 deletions.
25 changes: 25 additions & 0 deletions AdminToolbox/AdminToolbox/API/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ public static class Utility
public static bool TryParseRole(int roleID, out SMRoleType role)
{
role = SMRoleType.UNASSIGNED;

try
{
role = (SMRoleType)roleID;
}
catch
{
role = SMRoleType.UNASSIGNED;
return false;
}
return true;


int[] validRoles = Enum.GetValues(typeof(RoleType)).Cast<int>().ToArray();
if (!validRoles.Contains(roleID))
return false;
Expand All @@ -35,6 +48,18 @@ public static bool TryParseRole(int roleID, out SMRoleType role)
public static bool TryParseItem(int itemID, out SMItemType itemType)
{
itemType = SMItemType.NULL;

try
{
itemType = (SMItemType)itemID;
}
catch
{
itemType = SMItemType.NULL;
return false;
}
return true;

int[] validItems = Enum.GetValues(typeof(SMItemType)).Cast<int>().ToArray();
if (!validItems.Contains(itemID))
return false;
Expand Down
6 changes: 3 additions & 3 deletions AdminToolbox/AdminToolbox/AdminToolbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ namespace AdminToolbox
id = "rnen.admin.toolbox",
version = AT_Version + "-" + AT_Revision,
SmodMajor = 3,
SmodMinor = 7,
SmodRevision = 0
SmodMinor = 8,
SmodRevision = 1
)]
public class AdminToolbox : Plugin
{
internal const string AT_Version = "1.3.8";
internal const string AT_Revision = "15";
internal const string AT_Revision = "16";

#region GitHub release info
private DateTime LastOnlineCheck = DateTime.Now;
Expand Down
32 changes: 31 additions & 1 deletion AdminToolbox/AdminToolbox/Commands/Server/ATCommand.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Smod2;
using Smod2.API;
using Smod2.Commands;
using SMRoleType = Smod2.API.RoleType;
using SMItemType = Smod2.API.ItemType;

namespace AdminToolbox.Command
{
Expand Down Expand Up @@ -52,7 +57,32 @@ public string[] OnCall(ICommandSender sender, string[] args)
return denied;
AdminToolbox.DebugMode = !AdminToolbox.DebugMode;
return new string[] { "AdminToolbox Debugmode: " + AdminToolbox.DebugMode };

case "ITEMS":
Dictionary<int, string> dict = new Dictionary<int, string>();
string str = "Items:";
foreach (SMItemType i in Enum.GetValues(typeof(SMItemType)))
{
if (!dict.ContainsKey((int)i))
{
dict.Add((int)i, i.ToString());
}
}
foreach(KeyValuePair<int,string> kvp in dict.OrderBy(s => s.Key))
str += "\n" + kvp.Key + " - " + kvp.Value;
return new string[] { str };
case "ROLES":
Dictionary<int, string> dict2 = new Dictionary<int, string>();
string str2 = "Items:";
foreach (SMRoleType i in Enum.GetValues(typeof(SMRoleType)))
{
if (!dict2.ContainsKey((int)i))
{
dict2.Add((int)i, i.ToString());
}
}
foreach (KeyValuePair<int, string> kvp in dict2.OrderBy(s => s.Key))
str2 += "\n" + kvp.Key + " - " + kvp.Value;
return new string[] { str2 };
default:
return new string[] { args[0] + " is not a valid arguement!", GetUsage() };
}
Expand Down
2 changes: 2 additions & 0 deletions AdminToolbox/AdminToolbox/Events/PlayerDamageEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public void OnPlayerHurt(PlayerHurtEvent ev)
ev.Damage = 0f;
else if ((attackerSetting?.isJailed ?? false) || (attackerSetting?.dmgOff ?? false))
ev.Damage = 0f;
else if (ev.DamageType == DamageType.FLYING && Config.GetBoolValue("admintoolbox_antifly_disable", false))
ev.Damage = 0f;


int[] allowedTutDmg = new int[] { -1 };
Expand Down
7 changes: 5 additions & 2 deletions AdminToolbox/AdminToolbox/Managers/ATFileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,11 @@ public static void ConvertOldFilesToNewUserID()
if (!Path.GetFileName(files[i]).Contains('@'))
{
x++;
AdminToolbox.singleton.Debug(files[i].Substring(0, files[i].Length - 4) + "@steam.txt");
File.Move(files[i], files[i].Substring(0, files[i].Length - 4) + "@steam.txt");
string _newpath = files[i].Substring(0, files[i].Length - 4) + "@steam.txt";
AdminToolbox.singleton.Debug(_newpath);
if (File.Exists(_newpath)) //At rare occations this file already exists
File.Delete(_newpath);
File.Move(files[i], _newpath);
}
}
AdminToolbox.singleton.Info($"(File Manager) - {x} files converted");
Expand Down

0 comments on commit bbe9622

Please sign in to comment.