Skip to content
This repository has been archived by the owner on Mar 6, 2022. It is now read-only.

Commit

Permalink
fixes linux moment
Browse files Browse the repository at this point in the history
  • Loading branch information
BruteForceMaestro committed Jan 18, 2022
1 parent 1a8a0cd commit a3aaefe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static public void AddXP(Player player, int xp)
{
player.ShowHint($"+ <color=green>{xp}</color> XP");
}
Binary.WriteToBinaryFile(Main.path, Main.players);
Binary.WriteToBinaryFile(Main.Instance.Config.SavePath, Main.players);
}
static public IEnumerator<float> EvaluateRank(Player player)
{
Expand All @@ -50,7 +50,7 @@ static public IEnumerator<float> EvaluateRank(Player player)
Main.players.Add(new PlayerLog(player.UserId, 0, 0, player.Group.BadgeText));
}
}
Binary.WriteToBinaryFile(Main.path, Main.players);
Binary.WriteToBinaryFile(Main.Instance.Config.SavePath, Main.players);
PlayerLog log = Main.players.Find(x => x.UserId == player.UserId);
string badge = GetLVLBadge(player);
string color = Regex.Match(badge, @"(?<=%).*(?=%)").Value;
Expand Down
4 changes: 4 additions & 0 deletions Config.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Exiled.API.Interfaces;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;

namespace XPSystem
{
Expand Down Expand Up @@ -80,5 +82,7 @@ public class Config : IConfig

[Description("The structure of the badge displayed in-game. Variables: %lvl% - the level. %badge% earned badge in specified in LevelsBadge. %oldbadge% - base-game badge, like ones specified in config-remoteadmin, or a global badge. can be null.")]
public string BadgeStructure { get; set; } = "(LVL %lvl% | %badge%) %oldbadge%";
[Description("Path files get saved to. Requires change on linux.")]
public string SavePath { get; set; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"EXILED\Configs\Players.bin");
}
}
7 changes: 3 additions & 4 deletions Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ public class Main : Plugin<Config>
{
public static Main Instance { get; set; }
private EventHandlers handlers = new();
public static readonly string path = Environment.ExpandEnvironmentVariables(@"%AppData%\EXILED\Players.bin");
public static List<PlayerLog> players = new List<PlayerLog>();

private void GetOrCreateJson()
{
if (!File.Exists(path))
if (!File.Exists(Main.Instance.Config.SavePath))
{
Binary.WriteToBinaryFile(path, players);
Binary.WriteToBinaryFile(Main.Instance.Config.SavePath, players);
};
players = Binary.ReadFromBinaryFile<List<PlayerLog>>(path);
players = Binary.ReadFromBinaryFile<List<PlayerLog>>(Main.Instance.Config.SavePath);
if (players == null) { players = new List<PlayerLog>(); }
}
public override void OnEnabled()
Expand Down

0 comments on commit a3aaefe

Please sign in to comment.