Skip to content

Commit 828791e

Browse files
author
尧杰 曾
committed
Update
1 parent 930f188 commit 828791e

File tree

6 files changed

+40
-308
lines changed

6 files changed

+40
-308
lines changed

CDK/CDK.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
<Reference Include="MySql.Data, Version=8.0.30.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
6060
<HintPath>..\packages\MySql.Data.8.0.30\lib\net48\MySql.Data.dll</HintPath>
6161
</Reference>
62+
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
63+
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
64+
</Reference>
6265
<Reference Include="PermissionSync, Version=1.0.1.2, Culture=neutral, processorArchitecture=MSIL">
6366
<SpecificVersion>False</SpecificVersion>
6467
<HintPath>..\..\PermissionSync\PermissionSync\bin\Release\PermissionSync.dll</HintPath>

CDK/Data/CDKData.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ namespace CDK.Data
1010
public class CDKData
1111
{
1212
public string CDK { get; internal set; }
13-
public string Items { get; internal set; }
14-
public string Amount { get; internal set; }
13+
public string[] Items { get; internal set; }
14+
//public string Items { get; internal set; }
15+
//public string Amount { get; internal set; }
16+
public string[] Amount { get; internal set; }
1517
public ushort? Vehicle { get; internal set; }
1618
public ushort? Experience { get; internal set; }
1719
public decimal? Money { get; internal set; }
@@ -27,8 +29,8 @@ public class CDKData
2729
public CDKData(string cdk,string items, string amount, ushort? vehicle, ushort? exp, decimal? money, int? reputation, string permissonGroup, int redeemedTimes, int? maxredeem, DateTime validuntill, CSteamID steamID, bool renew, bool usePermissionSync)
2830
{
2931
CDK = cdk;
30-
Items = items;
31-
Amount = amount;
32+
Items = items.Split(',');
33+
Amount = amount.Split(',');
3234
Vehicle = vehicle;
3335
Experience = exp;
3436
Money = money;

CDK/DatabaseManager.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,22 @@ internal DatabaseManager()
3131

3232
private bool KeyVailed(CDKData cdk)
3333
{
34-
if (cdk.Items != string.Empty && cdk.Amount != string.Empty)
34+
if (cdk.Items.Length != 0 && cdk.Amount.Length != 0)
3535
{
36-
if (cdk.Items.Split(',').Length != cdk.Amount.Split(',').Length)
36+
if (cdk.Items.Length != cdk.Amount.Length)
3737
{
3838
Logger.LogError(String.Format("CDK:{0} Items and Amount Column length not equal! ", cdk.CDK));
3939
return false;
4040
}
41-
for (int i = 0; i < cdk.Items.Split(',').Length; i++)
41+
for (int i = 0; i < cdk.Items.Length; i++)
4242
{
4343
if (!ushort.TryParse(cdk.Items[i].ToString(), out ushort id))
4444
{
4545
Logger.LogError(String.Format("CDK:{0} has id in Items not a ushort!", cdk.CDK));
4646
return false;
4747
}
4848
}
49-
for (int i = 0; i < cdk.Amount.Split(',').Length; i++)
49+
for (int i = 0; i < cdk.Amount.Length; i++)
5050
{
5151
if (!byte.TryParse(cdk.Amount[i].ToString(), out byte am))
5252
{
@@ -87,19 +87,19 @@ public RedeemCDKResult RedeemCDK(UnturnedPlayer player, string CDK)
8787
}
8888
else
8989
{
90-
if (cdkdata.Items != string.Empty && cdkdata.Amount == string.Empty)
90+
if (cdkdata.Items.Length != 0 && cdkdata.Amount.Length == 0)
9191
{
9292

93-
var items = cdkdata.Items.Split(',');
93+
var items = cdkdata.Items;
9494
for (int i = 0; i < items.Length; i++)
9595
{
9696
player.GiveItem(ushort.Parse(items[i]), 1);
9797
}
9898
}
99-
else if (cdkdata.Items != string.Empty && cdkdata.Amount != string.Empty)
99+
else if (cdkdata.Items.Length != 0 && cdkdata.Amount.Length != 0)
100100
{
101-
var items = cdkdata.Items.Split(',');
102-
var amount = cdkdata.Amount.Split(',');
101+
var items = cdkdata.Items;
102+
var amount = cdkdata.Amount;
103103

104104
for (int i = 0; i < amount.Length; i++)
105105
{

0 commit comments

Comments
 (0)