using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.Json;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Bloody.Core.API.v1;
using Bloody.Core.GameData.v1;
using Bloody.Core.Methods;
using Bloody.Core.Models.v1;
using Bloody.Core.Models.v1.Base;
using BloodyWallet.API;
using BloodyWallet.Command;
using BloodyWallet.DB;
using BloodyWallet.DB.Models;
using Microsoft.CodeAnalysis;
using ProjectM.Network;
using Stunlock.Core;
using Unity.Collections;
using Unity.Entities;
using VampireCommandFramework;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("trodi")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Framework for Mods")]
[assembly: AssemblyFileVersion("0.1.2.0")]
[assembly: AssemblyInformationalVersion("0.1.2+1.Branch.master.Sha.8bf1daafa2fb70bc71f7f855e7a1abd39172334c")]
[assembly: AssemblyProduct("BloodyWallet")]
[assembly: AssemblyTitle("BloodyWallet")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/oscarpedrero/BloodyWallet")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.2.0")]
[module: UnverifiableCode]
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.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace BloodyWallet
{
[BepInPlugin("trodi.Bloody.Wallet", "BloodyWallet", "0.1.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class BloodyWalletPlugin : BasePlugin
{
internal static ConfigEntry<string> nameToken;
internal static ConfigEntry<bool> enabledAdminCommand;
internal static ConfigEntry<bool> enabledUsersCommand;
internal static ConfigEntry<int> prefabGUIDExchange;
internal static ManualLogSource Logger { get; private set; }
internal static BloodyWalletPlugin Instance { get; private set; }
public BloodyWalletPlugin()
{
Logger = ((BasePlugin)this).Log;
Instance = this;
nameToken = ((BasePlugin)this).Config.Bind<string>("General", "Name", "BloodyTokens", "Name of your virtual currency");
enabledAdminCommand = ((BasePlugin)this).Config.Bind<bool>("General", "adminCommand", true, "Enable admin commands");
enabledUsersCommand = ((BasePlugin)this).Config.Bind<bool>("General", "usersCommand", true, "Enable users commands");
prefabGUIDExchange = ((BasePlugin)this).Config.Bind<int>("General", "prefabGUIDExchange", -77477508, "PrfabGUID for exchange tokens");
}
public override void Load()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
LoadDB.CreateAndLoadDBFiles();
EventsHandlerSystem.OnSaveWorld += new SaveWorldEventHandler(SaveDB.SaveDBTOJSON);
if (enabledAdminCommand.Value)
{
CommandRegistry.RegisterCommandType(typeof(WalletAdminCommand));
}
if (enabledUsersCommand.Value)
{
CommandRegistry.RegisterCommandType(typeof(WalletUserCommand));
}
ManualLogSource log = ((BasePlugin)this).Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("trodi.Bloody.Wallet");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.1.2");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
}
log.LogInfo(val);
}
public override bool Unload()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
EventsHandlerSystem.OnSaveWorld -= new SaveWorldEventHandler(SaveDB.SaveDBTOJSON);
return true;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "trodi.Bloody.Wallet";
public const string PLUGIN_NAME = "BloodyWallet";
public const string PLUGIN_VERSION = "0.1.2";
}
}
namespace BloodyWallet.Systems
{
internal class WalletSystem
{
}
}
namespace BloodyWallet.DB
{
internal static class Database
{
internal static List<TokenModel> _TokensDB = new List<TokenModel>();
internal static List<LogModel> _LogDB = new List<LogModel>();
internal static List<TokenModel> getTokensDB()
{
return _TokensDB;
}
internal static List<TokenModel> SetTokensDB(List<TokenModel>? _tokenDB)
{
if (_tokenDB != null)
{
_TokensDB = _tokenDB;
}
return _TokensDB;
}
internal static List<LogModel> GetLogDB()
{
return _LogDB;
}
internal static List<LogModel> SetLogDB(List<LogModel>? _logDB)
{
if (_logDB != null)
{
_LogDB = _logDB;
}
return _LogDB;
}
internal static List<TokenModel> AddToken(TokenModel? _tokenModel)
{
if (_tokenModel != null)
{
_TokensDB.Add(_tokenModel);
}
return _TokensDB;
}
internal static List<LogModel> addLogDB(LogModel? _logDB)
{
if (_logDB != null)
{
_LogDB.Add(_logDB);
}
return _LogDB;
}
internal static bool AddLog(string _from, string _to, string _by, string _method, string _type, int _amount)
{
LogModel item = new LogModel
{
From = _from,
To = _to,
By = _by,
Method = _method,
Type = _type,
Amount = _amount
};
_LogDB?.Add(item);
return true;
}
internal static bool AddTokenToPlayer(string _characterName, int _tokens)
{
TokenModel tokenModel = FindBySteamID(_characterName);
if (tokenModel == null)
{
tokenModel = new TokenModel
{
CharacterName = _characterName,
Tokens = _tokens
};
_TokensDB.Add(tokenModel);
return true;
}
tokenModel.Tokens += _tokens;
return true;
}
internal static bool RemoveTokenToPlayer(string _characterName, int _tokens)
{
TokenModel tokenModel = FindBySteamID(_characterName);
if (tokenModel == null)
{
tokenModel = new TokenModel
{
CharacterName = _characterName,
Tokens = 0
};
_TokensDB.Add(tokenModel);
}
else if (tokenModel.Tokens - _tokens > 0)
{
tokenModel.Tokens -= _tokens;
}
else
{
tokenModel.Tokens = 0;
}
return true;
}
internal static bool TransferTokenToPlayer(string _characterNameFrom, string _characterNameTo, int _tokens)
{
TokenModel tokenModel = FindBySteamID(_characterNameFrom);
if (tokenModel == null)
{
return false;
}
if (tokenModel.Tokens - _tokens < 0)
{
return false;
}
tokenModel.Tokens -= _tokens;
TokenModel tokenModel2 = FindBySteamID(_characterNameTo);
if (tokenModel2 == null)
{
tokenModel2 = new TokenModel
{
CharacterName = _characterNameTo,
Tokens = _tokens
};
_TokensDB.Add(tokenModel2);
return true;
}
tokenModel2.Tokens += _tokens;
return true;
}
private static TokenModel? FindBySteamID(string _characterName)
{
string _characterName2 = _characterName;
return _TokensDB.Where((TokenModel x) => x.CharacterName == _characterName2).FirstOrDefault();
}
}
internal class LoadDB
{
internal static readonly string ConfigPath = Path.Combine(Paths.ConfigPath, "BloodyWallet");
internal static string TokensDBFile = Path.Combine(ConfigPath, "tokens.json");
internal static string LogDBFile = Path.Combine(ConfigPath, "log.json");
internal static bool CreateAndLoadDBFiles()
{
CreateFilesConfig();
LoadTokenFile();
LoadLogFile();
return true;
}
internal static bool CreateFilesConfig()
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
try
{
if (!Directory.Exists(ConfigPath))
{
Directory.CreateDirectory(ConfigPath);
}
if (!File.Exists(TokensDBFile))
{
File.WriteAllText(TokensDBFile, "[]");
}
if (!File.Exists(LogDBFile))
{
File.WriteAllText(LogDBFile, "[]");
}
return true;
}
catch (Exception ex)
{
ManualLogSource logger = BloodyWalletPlugin.Logger;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(7, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
logger.LogError(val);
return false;
}
}
internal static bool LoadTokenFile()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
try
{
Database.SetTokensDB(JsonSerializer.Deserialize<List<TokenModel>>(File.ReadAllText(TokensDBFile)));
return true;
}
catch (Exception ex)
{
ManualLogSource logger = BloodyWalletPlugin.Logger;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(7, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
logger.LogError(val);
return false;
}
}
internal static bool LoadLogFile()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
try
{
Database.SetLogDB(JsonSerializer.Deserialize<List<LogModel>>(File.ReadAllText(TokensDBFile)));
return true;
}
catch (Exception ex)
{
ManualLogSource logger = BloodyWalletPlugin.Logger;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(7, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
logger.LogError(val);
return false;
}
}
}
internal class SaveDB
{
internal static void SaveDBTOJSON()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
SaveTokenList();
SaveLogs();
ManualLogSource logger = BloodyWalletPlugin.Logger;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(11, 0, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Wallet Save");
}
logger.LogInfo(val);
}
internal static bool SaveTokenList()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
try
{
string contents = JsonSerializer.Serialize(Database._TokensDB, new JsonSerializerOptions
{
WriteIndented = true
});
File.WriteAllText(LoadDB.TokensDBFile, contents);
return true;
}
catch (Exception ex)
{
ManualLogSource logger = BloodyWalletPlugin.Logger;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(7, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
logger.LogError(val);
return false;
}
}
internal static bool SaveLogs()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
try
{
string contents = JsonSerializer.Serialize(Database._LogDB, new JsonSerializerOptions
{
WriteIndented = true
});
File.WriteAllText(LoadDB.LogDBFile, contents);
return true;
}
catch (Exception ex)
{
ManualLogSource logger = BloodyWalletPlugin.Logger;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(7, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
logger.LogError(val);
return false;
}
}
}
}
namespace BloodyWallet.DB.Models
{
[Serializable]
internal class LogModel
{
public string From { get; set; } = "";
public string To { get; set; } = "";
public string Method { get; set; } = "";
public string By { get; set; } = "";
public string Type { get; set; } = "";
public int Amount { get; set; }
}
public class MethodsLog
{
public static readonly string FromCommandAdmin = "Command Admin";
public static readonly string Fromtransfer = "Transfer";
}
[Serializable]
internal class TokenModel
{
public string CharacterName { get; set; } = "";
public int Tokens { get; set; }
}
public class TypesLog
{
public static readonly string Add = "Add";
public static readonly string Remove = "Remove";
public static readonly string Transfer = "Transfer";
}
}
namespace BloodyWallet.Command
{
[CommandGroup("bwa", null)]
public class WalletAdminCommand
{
[Command("add", null, "<PlayerName> <Amount>", "Add token to a player", null, true)]
public static void AddToken(ChatCommandContext ctx, string _playerName, int _amount)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
Users users = GameData.Users;
User user = ctx.User;
UserModel userByCharacterName = users.GetUserByCharacterName(((FixedString64Bytes)(ref user.CharacterName)).Value);
UserModel userByCharacterName2 = GameData.Users.GetUserByCharacterName(_playerName);
if (WalletAPI.AddTokenToUser(_amount, MethodsLog.FromCommandAdmin, ((EntityModel)userByCharacterName2).Entity, ((EntityModel)userByCharacterName).Entity, out string message))
{
ctx.Reply(message);
return;
}
throw ctx.Error(message);
}
[Command("remove", null, "<PlayerName> <Amount>", "Remove token to a player.", null, true)]
public static void RemoveToken(ChatCommandContext ctx, string _playerName, int _amount)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
Users users = GameData.Users;
User user = ctx.User;
UserModel userByCharacterName = users.GetUserByCharacterName(((FixedString64Bytes)(ref user.CharacterName)).Value);
UserModel userByCharacterName2 = GameData.Users.GetUserByCharacterName(_playerName);
if (WalletAPI.RemoveToken(_amount, MethodsLog.FromCommandAdmin, ((EntityModel)userByCharacterName2).Entity, ((EntityModel)userByCharacterName).Entity, out string message))
{
ctx.Reply(message);
return;
}
throw ctx.Error(message);
}
[Command("list", null, "<PlayerName>", "List of players with their respective tokens. If the <PlayerName> is specified, it only returns the tokens of that player", null, true)]
public static void listToken(ChatCommandContext ctx, string _playerName = null)
{
if (_playerName == null)
{
_playerName = string.Empty;
}
if (WalletAPI.listToken(_playerName, out List<string> message))
{
foreach (string item in message)
{
ctx.Reply(item);
}
return;
}
using List<string>.Enumerator enumerator = message.GetEnumerator();
if (enumerator.MoveNext())
{
string current2 = enumerator.Current;
throw ctx.Error(current2);
}
}
}
[CommandGroup("bw", null)]
public class WalletUserCommand
{
[Command("transfer", null, "<PlayerName> <Amount>", "Transfer token from your wallet to a another player", null, false)]
public static void TransferToken(ChatCommandContext ctx, string _playerName, int _amount)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: 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)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
if (_amount <= 0)
{
throw ctx.Error("The amount to be transferred must be greater than 0");
}
Users users = GameData.Users;
User user = ctx.User;
UserModel userByCharacterName = users.GetUserByCharacterName(((FixedString64Bytes)(ref user.CharacterName)).Value);
UserModel userByCharacterName2 = GameData.Users.GetUserByCharacterName(_playerName);
if (WalletAPI.TranferTokenFromOtherUser(_amount, MethodsLog.FromCommandAdmin, ((EntityModel)userByCharacterName2).Entity, ((EntityModel)userByCharacterName).Entity, out string message))
{
ctx.Reply(message);
UserModelMethods.SendSystemMessage(userByCharacterName2, $"You just received a transfer of {_amount} tokens from player {userByCharacterName.CharacterName}");
return;
}
throw ctx.Error(message);
}
[Command("me", null, "", "Show your tokens.", null, false)]
public static void listToken(ChatCommandContext ctx)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
User user = ctx.User;
if (WalletAPI.listToken(((FixedString64Bytes)(ref user.CharacterName)).Value, out List<string> message))
{
foreach (string item in message)
{
ctx.Reply(item);
}
return;
}
using List<string>.Enumerator enumerator = message.GetEnumerator();
if (enumerator.MoveNext())
{
string current2 = enumerator.Current;
throw ctx.Error(current2);
}
}
[Command("exchange", null, "<Amount>", "Exchange yours tokens for game item.", null, false)]
public static void ExchangeToken(ChatCommandContext ctx, int amount)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
User user = ctx.User;
if (WalletAPI.GetTotalTokensForUser(((FixedString64Bytes)(ref user.CharacterName)).Value, out var tokens))
{
Users users = GameData.Users;
user = ctx.User;
UserModel userByCharacterName = users.GetUserByCharacterName(((FixedString64Bytes)(ref user.CharacterName)).Value);
if (tokens < amount)
{
throw ctx.Error($"You don't have enough token to exchange [Tokens: {tokens}] ");
}
if (WalletAPI.RemoveToken(amount, "exchanmge", ((EntityModel)userByCharacterName).Entity, ((EntityModel)userByCharacterName).Entity, out string _))
{
UserSystem.TryAddInventoryItemOrDrop(((EntityModel)userByCharacterName).Entity, new PrefabGUID(BloodyWalletPlugin.prefabGUIDExchange.Value), amount);
ctx.Reply("Change made correctly");
return;
}
throw ctx.Error($"You don't have enough token to exchange [Tokens: {tokens}] ");
}
throw ctx.Error($"You don't have enough token to exchange [Tokens: {tokens}] ");
}
}
}
namespace BloodyWallet.API
{
public static class WalletAPI
{
public static bool AddTokenToUser(int _amount, string _method, Entity playerReciviedTokens, Entity userEntityExecuteFunction, out string message)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
try
{
UserModel val = GameData.Users.FromEntity(userEntityExecuteFunction);
UserModel val2 = GameData.Users.FromEntity(playerReciviedTokens);
string characterName = val2.CharacterName;
if (Database.AddTokenToPlayer(characterName, _amount))
{
message = $"Added {_amount} {BloodyWalletPlugin.nameToken.Value} to user {val2.CharacterName}";
Database.AddLog("", characterName, val.CharacterName, _method, TypesLog.Add, _amount);
SaveDB.SaveDBTOJSON();
return true;
}
message = $"There was an error trying to add {_amount} {BloodyWalletPlugin.nameToken} to user {val.CharacterName}";
return false;
}
catch (Exception ex)
{
message = "Error " + ex.Message;
return false;
}
}
public static bool RemoveToken(int _amount, string _method, Entity playerReciviedTokens, Entity userEntityExecuteFunction, out string message)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
try
{
UserModel val = GameData.Users.FromEntity(userEntityExecuteFunction);
string characterName = GameData.Users.FromEntity(playerReciviedTokens).CharacterName;
if (Database.RemoveTokenToPlayer(characterName, _amount))
{
message = $"Remove {_amount} {BloodyWalletPlugin.nameToken.Value} to user {characterName}";
Database.AddLog("", characterName, val.CharacterName, _method, TypesLog.Remove, _amount);
SaveDB.SaveDBTOJSON();
return true;
}
message = $"There was an error trying to remove {_amount} {BloodyWalletPlugin.nameToken} to user {characterName}";
return false;
}
catch (Exception ex)
{
message = "Error " + ex.Message;
return false;
}
}
public static bool listToken(string _playerName, out List<string> message)
{
message = new List<string>();
try
{
if (_playerName == string.Empty)
{
foreach (TokenModel item in Database._TokensDB)
{
message.Add($"------- {item.CharacterName}: {item.Tokens} {BloodyWalletPlugin.nameToken.Value} -------");
}
return true;
}
UserModel user = GameData.Users.GetUserByCharacterName(_playerName);
TokenModel tokenModel = Database._TokensDB.Where((TokenModel x) => x.CharacterName == user.CharacterName).FirstOrDefault();
if (tokenModel == null)
{
message.Add($"------- {user.CharacterName}: 0 {BloodyWalletPlugin.nameToken.Value} -------");
}
else
{
message.Add($"------- {user.CharacterName}: {tokenModel.Tokens} {BloodyWalletPlugin.nameToken.Value} -------");
}
return true;
}
catch (Exception ex)
{
message.Add("Error " + ex.Message);
return false;
}
}
public static bool GetTotalTokensForUser(string _playerName, out int tokens)
{
try
{
UserModel user = GameData.Users.GetUserByCharacterName(_playerName);
TokenModel tokenModel = Database._TokensDB.Where((TokenModel x) => x.CharacterName == user.CharacterName).FirstOrDefault();
if (tokenModel == null)
{
tokens = 0;
return true;
}
tokens = tokenModel.Tokens;
return true;
}
catch (Exception)
{
tokens = 0;
return false;
}
}
public static bool TranferTokenFromOtherUser(int _amount, string _method, Entity playerReciviedTokens, Entity fromUserSendToken, out string message)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
try
{
UserModel val = GameData.Users.FromEntity(fromUserSendToken);
UserModel val2 = GameData.Users.FromEntity(playerReciviedTokens);
string characterName = val2.CharacterName;
string characterName2 = val.CharacterName;
if (Database.TransferTokenToPlayer(characterName2, characterName, _amount))
{
message = $"Added {_amount} {BloodyWalletPlugin.nameToken.Value} to user {val2.CharacterName}";
Database.AddLog(characterName2, characterName, string.Empty, _method, TypesLog.Transfer, _amount);
SaveDB.SaveDBTOJSON();
return true;
}
message = $"There was an error trying to transfer {_amount} {BloodyWalletPlugin.nameToken.Value} from user {val.CharacterName} to user {val2.CharacterName}";
return false;
}
catch (Exception ex)
{
message = "Error " + ex.Message;
return false;
}
}
public static int GetPrefabGUID()
{
return BloodyWalletPlugin.prefabGUIDExchange.Value;
}
}
}