Skip to content

Commit

Permalink
修复支付货币可以负数
Browse files Browse the repository at this point in the history
修复支付货币可以负数
  • Loading branch information
Cybeta committed May 27, 2022
1 parent b0cf709 commit 47c6cab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
11 changes: 8 additions & 3 deletions POBC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class POBCSystem : TerrariaPlugin

public override Version Version => Assembly.GetExecutingAssembly().GetName().Version;
public string ConfigPath => Path.Combine(TShock.SavePath, "POBC.json");
public POBCConfin Config = new POBCConfin();
public POBCConfig Config = new POBCConfig();
//public string time = DateTime.Now.ToString("yyyy-MM-dd_hh-mm-ss"); yuqing : 日志整体移动到DB Sheet
#endregion

Expand Down Expand Up @@ -203,6 +203,11 @@ private void Pay(CommandArgs args)
args.Player.SendErrorMessage("未能在POBC用户数据中查找到该玩家:" + args.Parameters[0] + "! 请确认玩家名");
return;
}
if (int.Parse(args.Parameters[1]) <1)
{
args.Player.SendErrorMessage("支付的货币不能小于 1" );
return;
}
if (int.Parse(args.Parameters[1]) > Db.QueryCurrency(args.Player.Name))
{
args.Player.SendErrorMessage("您拥有的货币不够你要支付的货币数,拥有货币数:" + Db.QueryCurrency(args.Player.Name));
Expand Down Expand Up @@ -273,11 +278,11 @@ public void File()
{
try
{
Config = POBCConfin.Read(ConfigPath).Write(ConfigPath);
Config = POBCConfig.Read(ConfigPath).Write(ConfigPath);
}
catch (Exception ex)
{
Config = new POBCConfin();
Config = new POBCConfig();
TShock.Log.ConsoleError("[POBC] 读取配置文件发生错误!\n{0}".SFormat(ex.ToString()));
}
}
Expand Down
10 changes: 5 additions & 5 deletions config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace POBC2
{
public class POBCConfin
public class POBCConfig
{
public int[] IgnoreNpc = new int[0];
public int infodisplay = 1;
Expand All @@ -19,19 +19,19 @@ public bool IsIgnored(int npctype)
return IgnoreNpc.Contains(npctype);
}

public POBCConfin Write(string file)
public POBCConfig Write(string file)
{
File.WriteAllText(file, JsonConvert.SerializeObject(this, Formatting.Indented));
return this;
}

public static POBCConfin Read(string file)
public static POBCConfig Read(string file)
{
if (!File.Exists(file))
{
return new POBCConfin();
return new POBCConfig();
}
return JsonConvert.DeserializeObject<POBCConfin>(File.ReadAllText(file));
return JsonConvert.DeserializeObject<POBCConfig>(File.ReadAllText(file));
}
}
}

0 comments on commit 47c6cab

Please sign in to comment.