using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.Json;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Bloodstone.API;
using Bloodstone.Hooks;
using BloodyShop.Server.Core;
using HarmonyLib;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.Network;
using Stunlock.Core;
using Unity.Collections;
using Unity.Entities;
using UnityEngine;
using VampireCommandFramework;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("WeaponForge")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Spawns weapons with max tier stats.")]
[assembly: AssemblyFileVersion("0.1.10.0")]
[assembly: AssemblyInformationalVersion("0.1.10+1.Branch.main.Sha.c33d0879382e1a0da34861ec55914ba7e637a80e")]
[assembly: AssemblyProduct("WeaponForge")]
[assembly: AssemblyTitle("WeaponForge")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.10.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace WeaponForge
{
public static class DB
{
private static readonly string FileDirectory = Path.Combine("BepInEx", "config", "WeaponForge");
private static readonly string ModifiersFileName = "WeaponModifiers.json";
private static readonly string ModifiersFilePath = Path.Combine(FileDirectory, ModifiersFileName);
public static readonly Dictionary<string, PrefabGUID> InfusionMap = new Dictionary<string, PrefabGUID>
{
{
"blood",
new PrefabGUID(-634479113)
},
{
"chaos",
new PrefabGUID(-1102157891)
},
{
"frost",
new PrefabGUID(-1538516012)
},
{
"illusion",
new PrefabGUID(-1957977808)
},
{
"storm",
new PrefabGUID(-1099263242)
},
{
"unholy",
new PrefabGUID(-766734228)
}
};
private static readonly Dictionary<WeaponType, PrefabGUID> WeaponMap = new Dictionary<WeaponType, PrefabGUID>
{
{
WeaponType.Spear,
new PrefabGUID(-1931117134)
},
{
WeaponType.Axe,
new PrefabGUID(-102830349)
},
{
WeaponType.Crossbow,
new PrefabGUID(935392085)
},
{
WeaponType.GreatSword,
new PrefabGUID(-1173681254)
},
{
WeaponType.Mace,
new PrefabGUID(1994084762)
},
{
WeaponType.Pistols,
new PrefabGUID(-944318126)
},
{
WeaponType.Reaper,
new PrefabGUID(-105026635)
},
{
WeaponType.Slashers,
new PrefabGUID(821410795)
},
{
WeaponType.Whip,
new PrefabGUID(429323760)
},
{
WeaponType.Sword,
new PrefabGUID(195858450)
},
{
WeaponType.Longbow,
new PrefabGUID(1177453385)
}
};
private static readonly Dictionary<char, (PrefabGUID Guid, float Power, string Description)> DefaultModifiers = new Dictionary<char, (PrefabGUID, float, string)>
{
{
'1',
(new PrefabGUID(-542568600), 10f, "Attack Speed")
},
{
'2',
(new PrefabGUID(303731846), 5f, "Damage Reduction")
},
{
'3',
(new PrefabGUID(1915954443), 50f, "Max Health")
},
{
'4',
(new PrefabGUID(-285192213), 5f, "Movement Speed")
},
{
'5',
(new PrefabGUID(-184681371), 15f, "Phys Crit Chance")
},
{
'6',
(new PrefabGUID(-1480767601), 20f, "Phys Crit Damage")
},
{
'7',
(new PrefabGUID(-1122907647), 10f, "Weapon Skill Cooldown Recovery Rate")
},
{
'8',
(new PrefabGUID(-1157374165), 25f, "Spell Crit Chance")
},
{
'9',
(new PrefabGUID(193642528), 30f, "Spell Crit Damage")
},
{
'A',
(new PrefabGUID(-1639076208), 10f, "Spell Skill Cooldown Recovery Rate")
},
{
'B',
(new PrefabGUID(1705753146), 25f, "Spell Power")
},
{
'C',
(new PrefabGUID(-427223401), 5f, "Spell Leech")
},
{
'D',
(new PrefabGUID(-1276596814), 20f, "Resource Yield")
}
};
public static Dictionary<char, (PrefabGUID Guid, float Power, string Description)> StatModifiers = new Dictionary<char, (PrefabGUID, float, string)>(DefaultModifiers);
public static bool EnabledCommand { get; set; } = true;
public static bool AdminOnlyCommand { get; set; } = false;
public static int RequiredItemGUID { get; set; } = -598100816;
public static string ItemName { get; set; } = "Thistle";
public static int RequiredItemAmount { get; set; } = 10;
public static PrefabGUID GetWeaponGUID(WeaponType type)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
PrefabGUID value;
return (PrefabGUID)(WeaponMap.TryGetValue(type, out value) ? value : default(PrefabGUID));
}
public static List<(PrefabGUID Guid, float Power)> ParseStatModifiers(string input)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
List<(PrefabGUID, float)> list = new List<(PrefabGUID, float)>();
foreach (char key in input)
{
if (StatModifiers.TryGetValue(key, out (PrefabGUID, float, string) value))
{
list.Add((value.Item1, value.Item2));
}
}
return list;
}
public static string GetModifiersList()
{
StringBuilder stringBuilder = new StringBuilder();
foreach (KeyValuePair<char, (PrefabGUID, float, string)> statModifier in StatModifiers)
{
StringBuilder stringBuilder2 = stringBuilder;
StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(2, 2, stringBuilder2);
handler.AppendFormatted(statModifier.Key);
handler.AppendLiteral(": ");
handler.AppendFormatted(statModifier.Value.Item3);
stringBuilder2.AppendLine(ref handler);
}
return stringBuilder.ToString();
}
public static void LoadModifiers()
{
if (!Directory.Exists(FileDirectory))
{
Directory.CreateDirectory(FileDirectory);
}
if (!File.Exists(ModifiersFilePath))
{
StatModifiers = new Dictionary<char, (PrefabGUID, float, string)>(DefaultModifiers);
SaveModifiers();
}
else
{
string json = File.ReadAllText(ModifiersFilePath);
StatModifiers = JsonSerializer.Deserialize<Dictionary<char, (PrefabGUID, float, string)>>(json);
}
}
public static void SaveModifiers()
{
string contents = JsonSerializer.Serialize(StatModifiers, new JsonSerializerOptions
{
WriteIndented = true
});
File.WriteAllText(ModifiersFilePath, contents);
}
public static void ReloadData()
{
Plugin.Logger.LogInfo((object)"[WF] Reloading configuration and modifiers...");
MainConfig.ReloadConfig();
LoadModifiers();
Plugin.Logger.LogInfo((object)"[WF] Reload complete.");
}
}
public enum WeaponType
{
Spear,
Axe,
Crossbow,
GreatSword,
Mace,
Pistols,
Reaper,
Slashers,
Whip,
Sword,
Longbow
}
public static class Helper
{
private static World? _serverWorld;
public static World Server
{
get
{
if (_serverWorld == null)
{
Enumerator<World> enumerator = World.s_AllWorlds.GetEnumerator();
while (enumerator.MoveNext())
{
World current = enumerator.Current;
if (current.Name == "Server")
{
_serverWorld = current;
break;
}
}
if (_serverWorld == null)
{
throw new Exception("[WeaponForge] Server world not found.");
}
}
return _serverWorld;
}
}
public static void CreateWeapon(User user, PrefabGUID weaponGUID, PrefabGUID infusionGUID = default(PrefabGUID), PrefabGUID statMod1Guid = default(PrefabGUID), float statMod1Power = 0f, PrefabGUID statMod2Guid = default(PrefabGUID), float statMod2Power = 0f, PrefabGUID statMod3Guid = default(PrefabGUID), float statMod3Power = 0f)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
try
{
EntityManager entityManager = Server.EntityManager;
DebugEventsSystem existingSystemManaged = Server.GetExistingSystemManaged<DebugEventsSystem>();
if (existingSystemManaged == null)
{
Debug.LogError(Object.op_Implicit("[WeaponForge] DebugEventsSystem not found."));
return;
}
Debug.Log(Object.op_Implicit("[WeaponForge] DebugEventsSystem retrieved."));
CreateLegendaryWeaponDebugEvent val = default(CreateLegendaryWeaponDebugEvent);
val.WeaponPrefabGuid = weaponGUID;
val.Tier = 1;
val.InfuseSpellMod = infusionGUID;
val.StatMod1 = statMod1Guid;
val.StatMod1Power = statMod1Power;
val.StatMod2 = statMod2Guid;
val.StatMod2Power = statMod2Power;
val.StatMod3 = statMod3Guid;
val.StatMod3Power = statMod3Power;
CreateLegendaryWeaponDebugEvent val2 = val;
existingSystemManaged.CreateLegendaryWeaponEvent(user.Index, ref val2);
Debug.Log(Object.op_Implicit($"[WeaponForge] Weapon creation event sent successfully for GUID: {weaponGUID} with modifiers."));
}
catch (Exception ex)
{
Debug.LogError(Object.op_Implicit("[WeaponForge] Failed to create weapon: " + ex.Message + "\n" + ex.StackTrace));
}
}
}
public static class MainConfig
{
private static ConfigEntry<bool> EnableCommand;
private static ConfigEntry<bool> AdminOnlyCommand;
private static ConfigEntry<int> RequiredItemGUID;
private static ConfigEntry<int> RequiredItemAmount;
private static ConfigEntry<string> ItemName;
private static ConfigFile _configFile;
public static void SettingsInit(ConfigFile config)
{
_configFile = config;
_configFile.SaveOnConfigSet = true;
EnableCommand = _configFile.Bind<bool>("WeaponForge", "EnableCommand", true, "Enable or disable the Weapon Forge command.");
AdminOnlyCommand = _configFile.Bind<bool>("WeaponForge", "AdminOnlyCommand", false, "Restrict the Weapon Forge command to admins only.");
RequiredItemGUID = _configFile.Bind<int>("WeaponForge", "RequiredItemGUID", -598100816, "The PrefabGUID of the item required to use the Weapon Forge command.");
RequiredItemAmount = _configFile.Bind<int>("WeaponForge", "RequiredItemAmount", 10, "The amount of the required item needed to forge a weapon.");
ItemName = _configFile.Bind<string>("WeaponForge", "ItemName", "Thistle", "The name of the item required to forge a weapon.");
ApplySettingsToDB();
ManualLogSource logger = Plugin.Logger;
if (logger != null)
{
logger.LogInfo((object)"[WF] Configuration initialized successfully.");
}
}
private static void ApplySettingsToDB()
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Expected O, but got Unknown
DB.EnabledCommand = EnableCommand.Value;
DB.AdminOnlyCommand = AdminOnlyCommand.Value;
DB.RequiredItemGUID = RequiredItemGUID.Value;
DB.RequiredItemAmount = RequiredItemAmount.Value;
DB.ItemName = ItemName.Value;
ManualLogSource logger = Plugin.Logger;
if (logger != null)
{
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(117, 5, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[WF] Current Settings: EnableCommand = ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(DB.EnabledCommand);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", AdminOnlyCommand = ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(DB.AdminOnlyCommand);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", RequiredItemGUID = ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(DB.RequiredItemGUID);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", RequiredItemAmount = ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(DB.RequiredItemAmount);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", ItemName = ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(DB.ItemName);
}
logger.LogInfo(val);
}
}
public static void ReloadConfig()
{
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Expected O, but got Unknown
if (_configFile == null)
{
ManualLogSource logger = Plugin.Logger;
if (logger != null)
{
logger.LogError((object)"[WF] Configuration file not found. Reload failed.");
}
return;
}
try
{
ManualLogSource logger2 = Plugin.Logger;
if (logger2 != null)
{
logger2.LogInfo((object)"[WF] Reloading configuration...");
}
_configFile.Reload();
_configFile.Save();
ApplySettingsToDB();
ManualLogSource logger3 = Plugin.Logger;
if (logger3 != null)
{
logger3.LogInfo((object)"[WF] Configuration reloaded successfully.");
}
}
catch (Exception ex)
{
ManualLogSource logger4 = Plugin.Logger;
if (logger4 != null)
{
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(37, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[WF] Failed to reload configuration: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
logger4.LogError(val);
}
}
}
public static bool IsCommandEnabled()
{
return EnableCommand.Value;
}
public static bool IsAdminOnly()
{
return AdminOnlyCommand.Value;
}
}
internal static class Markup
{
public const string HighlightColor = "#90ee90";
public const string SecondaryColor = "#87ceeb";
public static string Prefix = Format.Bold(Format.Color("[WF]", "#ff4500"));
public static string Highlight(int i)
{
return Highlight(i.ToString());
}
public static string Highlight(string s)
{
return Format.Color(Format.Bold(s), "#90ee90");
}
public static string Secondary(int i)
{
return Secondary(i.ToString());
}
public static string Secondary(string s)
{
return Format.Color(Format.Bold(s), "#87ceeb");
}
}
[BepInPlugin("weaponforge", "Weapon Forge", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
public static ManualLogSource Logger;
private Harmony _harmony;
public override void Load()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
Logger = ((BasePlugin)this).Log;
Logger.LogInfo((object)"Weapon Forge Loaded!");
_harmony = new Harmony("weaponforge");
_harmony.PatchAll();
MainConfig.SettingsInit(((BasePlugin)this).Config);
CommandRegistry.RegisterAll();
Chat.OnChatMessage += new ChatEventHandler(HandleReloadCommand);
Logger.LogInfo((object)"Commands registered successfully.");
}
public override bool Unload()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
CommandRegistry.UnregisterAssembly();
Chat.OnChatMessage -= new ChatEventHandler(HandleReloadCommand);
Logger.LogInfo((object)"Weapon Forge unloaded successfully.");
return true;
}
private void HandleReloadCommand(VChatEvent ev)
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
if (!(ev.Message == "!reload") || !ev.User.IsAdmin)
{
return;
}
Logger.LogInfo((object)"[WF] Reload command received.");
try
{
MainConfig.ReloadConfig();
VExtensions.SendSystemMessage(ev.User, "<color=#00FF00>WeaponForge configuration reloaded successfully.</color>");
Logger.LogInfo((object)"WeaponForge configuration reloaded via !reload command.");
}
catch (Exception ex)
{
VExtensions.SendSystemMessage(ev.User, "<color=#FF0000>Failed to reload configuration:</color> " + ex.Message);
ManualLogSource logger = Logger;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(31, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error reloading configuration: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
}
logger.LogError(val);
}
}
}
public struct CreateLegendaryWeaponDebugEvent : IComponentData
{
public PrefabGUID WeaponPrefabGuid;
public int Tier;
public PrefabGUID InfuseSpellMod;
public PrefabGUID StatMod1;
public float StatMod1Power;
public PrefabGUID StatMod2;
public float StatMod2Power;
public PrefabGUID StatMod3;
public float StatMod3Power;
}
public interface IComponentData
{
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "WeaponForge";
public const string PLUGIN_NAME = "WeaponForge";
public const string PLUGIN_VERSION = "0.1.10";
}
}
namespace WeaponForge.Commands
{
internal class ForgeCommands
{
[Command("weaponforge", "wf", ".wf spear blood 123", "Forge a weapon with infusion, modifiers, and a purchase system.", null, false)]
public static void WeaponForgeCommand(ChatCommandContext ctx, string weaponType = "", string infusionType = "", string modifiers = "")
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_0299: Unknown result type (might be due to invalid IL or missing references)
//IL_029b: Unknown result type (might be due to invalid IL or missing references)
//IL_029f: Unknown result type (might be due to invalid IL or missing references)
//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0308: Unknown result type (might be due to invalid IL or missing references)
//IL_0316: Unknown result type (might be due to invalid IL or missing references)
if (!MainConfig.IsCommandEnabled())
{
ctx.Reply("<color=green>[WF]</color> This command is currently disabled by the server.");
return;
}
if (MainConfig.IsAdminOnly() && !ctx.Event.User.IsAdmin)
{
ctx.Reply("<color=green>[WF]</color> This command is restricted to admins only.");
return;
}
if (weaponType == "?")
{
ShowStatModifiers(ctx);
return;
}
if (string.IsNullOrWhiteSpace(weaponType) || !Enum.TryParse<WeaponType>(weaponType, ignoreCase: true, out var result))
{
ctx.Reply("<color=green>[WF] Invalid weapon type: " + Markup.Highlight(weaponType) + ".</color>\nAvailable weapons: " + Markup.Highlight(string.Join(", ", Enum.GetNames(typeof(WeaponType)))));
return;
}
string s = CapitalizeFirstLetter(weaponType);
if (string.IsNullOrWhiteSpace(infusionType) || !DB.InfusionMap.TryGetValue(infusionType.ToLower(), out var value))
{
ctx.Reply("<color=green>[WF] Invalid infusion type: " + Markup.Highlight(infusionType) + ".</color>\nAvailable infusions: " + Markup.Highlight(string.Join(", ", DB.InfusionMap.Keys)));
return;
}
modifiers = modifiers.ToUpper();
List<(PrefabGUID, float)> list = DB.ParseStatModifiers(modifiers);
if (list.Count != 3)
{
ctx.Reply("<color=green>[WF] Invalid modifiers.</color> Provide exactly 3 valid modifiers as a string of characters (e.g., " + Markup.Highlight("123") + ").");
return;
}
if (HasDuplicateModifiers(modifiers))
{
ctx.Reply("<color=green>[WF]</color> Duplicate modifiers are not allowed. Please use unique modifiers (e.g., '123').");
return;
}
PrefabGUID val = default(PrefabGUID);
((PrefabGUID)(ref val))..ctor(DB.RequiredItemGUID);
int requiredItemAmount = DB.RequiredItemAmount;
string itemName = DB.ItemName;
User user = ctx.Event.User;
string text = ((object)(FixedString64Bytes)(ref user.CharacterName)).ToString();
if (!InventorySystem.verifyHaveSuficientPrefabsInInventory(text, val, requiredItemAmount))
{
ctx.Reply($"<color=green>[WF]</color> The forge requires {Markup.Highlight(requiredItemAmount)} {Markup.Highlight(itemName)} to create this weapon.");
return;
}
if (!InventorySystem.getPrefabFromInventory(text, val, requiredItemAmount))
{
ctx.Reply("<color=green>[WF]</color> Failed to remove the required items from your inventory.");
return;
}
ctx.Reply("<color=green>[WF]</color> Payment successful. Creating your " + Markup.Highlight(s) + "...");
try
{
PrefabGUID weaponGUID = DB.GetWeaponGUID(result);
if (weaponGUID == default(PrefabGUID))
{
ctx.Reply("<color=green>[WF]</color> Invalid weapon configuration for " + Markup.Highlight(s) + ".");
return;
}
(PrefabGUID, float) tuple = list[0];
(PrefabGUID, float) tuple2 = list[1];
(PrefabGUID, float) tuple3 = list[2];
Helper.CreateWeapon(ctx.User, weaponGUID, value, tuple.Item1, tuple.Item2, tuple2.Item1, tuple2.Item2, tuple3.Item1, tuple3.Item2);
ctx.Reply($"<color=green>[WF]</color> {Markup.Highlight(s)} successfully created with infusion: {Markup.Highlight(infusionType)} and modifiers: {Markup.Highlight(modifiers)}.");
}
catch (Exception ex)
{
ctx.Reply("<color=green>[WF]</color> An error occurred while attempting to create the weapon. Please check the server logs for details.");
Debug.LogError(Object.op_Implicit($"<color=green>[WF] Error in WeaponForgeCommand: {ex.Message}\n{ex.StackTrace}</color>"));
}
}
private static void ShowStatModifiers(ChatCommandContext ctx)
{
string modifiersList = DB.GetModifiersList();
ctx.Reply("<color=green>[WF]</color> Available Stat Modifiers:\n" + modifiersList);
}
private static bool HasDuplicateModifiers(string modifiers)
{
HashSet<char> hashSet = new HashSet<char>();
foreach (char item in modifiers)
{
if (hashSet.Contains(item))
{
return true;
}
hashSet.Add(item);
}
return false;
}
private static string CapitalizeFirstLetter(string input)
{
if (string.IsNullOrEmpty(input))
{
return input;
}
return char.ToUpper(input[0]) + input.Substring(1).ToLower();
}
}
}