Skip to content
This repository was archived by the owner on Nov 7, 2023. It is now read-only.

Commit 905525e

Browse files
committed
feat (dependencies): compatibility to recent TShock & OTAPI builds
1 parent 0454bb8 commit 905525e

File tree

7 files changed

+36
-36
lines changed

7 files changed

+36
-36
lines changed

Implementation/ChestManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public bool SetUpRefillChest(
117117
if (refillTime != null)
118118
actualRefillTime = refillTime.Value;
119119

120-
refillChestData = new RefillChestMetadata(player.User.ID);
120+
refillChestData = new RefillChestMetadata(player.Account.ID);
121121
refillChestData.RefillTimer = new Timer(actualRefillTime, refillChestData, this.RefillTimerCallbackHandler);
122122
if (oneLootPerPlayer != null)
123123
refillChestData.OneLootPerPlayer = oneLootPerPlayer.Value;
@@ -200,7 +200,7 @@ public void SetUpBankChest(TSPlayer player, DPoint tileLocation, int bankChestIn
200200
if (protection.BankChestKey != BankChestDataKey.Invalid)
201201
throw new ChestTypeAlreadyDefinedException();
202202

203-
BankChestDataKey bankChestKey = new BankChestDataKey(player.User.ID, bankChestIndex);
203+
BankChestDataKey bankChestKey = new BankChestDataKey(player.Account.ID, bankChestIndex);
204204
lock (this.WorldMetadata.Protections) {
205205
if (this.WorldMetadata.Protections.Values.Any(p => p.BankChestKey == bankChestKey))
206206
throw new BankChestAlreadyInstancedException();
@@ -480,7 +480,7 @@ public bool EnsureBankChest(ProtectionEntry protection, bool resetContent) {
480480
return false;
481481
}
482482

483-
User owner = TShock.Users.GetUserByID(protection.Owner);
483+
UserAccount owner = TShock.UserAccounts.GetUserAccountByID(protection.Owner);
484484
if (owner == null) {
485485
this.DestroyChest(chest);
486486

Implementation/PluginCooperationHandler.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ public void InfiniteChests_ChestDataImport(
104104
// TSPlayer.All = chest will not be protected
105105
TSPlayer owner = TSPlayer.All;
106106
if (!string.IsNullOrEmpty(rawAccount)) {
107-
User tUser = TShock.Users.GetUserByName(rawAccount);
107+
UserAccount tUser = TShock.UserAccounts.GetUserAccountByName(rawAccount);
108108
if (tUser != null) {
109109
owner = new TSPlayer(0);
110-
owner.User.ID = tUser.ID;
111-
owner.User.Name = tUser.Name;
110+
owner.Account.ID = tUser.ID;
111+
owner.Account.Name = tUser.Name;
112112
owner.Group = TShock.Groups.GetGroupByName(tUser.Group);
113113
} else {
114114
// The original owner of the chest does not exist anymore, so we just protect it for the server player.
@@ -209,11 +209,11 @@ public void InfiniteSigns_SignDataImport(
209209
// TSPlayer.All means that the sign must not be protected at all.
210210
TSPlayer owner = TSPlayer.All;
211211
if (!string.IsNullOrEmpty(rawAccount)) {
212-
User tUser = TShock.Users.GetUserByName(rawAccount);
212+
UserAccount tUser = TShock.UserAccounts.GetUserAccountByName(rawAccount);
213213
if (tUser != null) {
214214
owner = new TSPlayer(0);
215-
owner.User.ID = tUser.ID;
216-
owner.User.Name = tUser.Name;
215+
owner.Account.ID = tUser.ID;
216+
owner.Account.Name = tUser.Name;
217217
owner.Group = TShock.Groups.GetGroupByName(tUser.Group);
218218
} else {
219219
// The original owner of the sign does not exist anymore, so we just protect it for the server player.

Implementation/ProtectionManager.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ private IEnumerable<ProtectionEntry> EnumProtectionEntriesOnTopOfObject(ObjectMe
211211
}
212212

213213
public bool CheckProtectionAccess(ProtectionEntry protection, TSPlayer player, bool fullAccessRequired = false) {
214-
bool hasAccess = (player.IsLoggedIn && protection.Owner == player.User.ID);
214+
bool hasAccess = (player.IsLoggedIn && protection.Owner == player.Account.ID);
215215
if (!hasAccess && !fullAccessRequired) {
216216
hasAccess = player.Group.HasPermission(ProtectorPlugin.UseEverything_Permission);
217217
if (!hasAccess)
@@ -265,7 +265,7 @@ public ProtectionEntry CreateProtection(
265265
if (
266266
checkLimits &&
267267
!player.Group.HasPermission(ProtectorPlugin.NoProtectionLimits_Permission) &&
268-
this.WorldMetadata.CountUserProtections(player.User.ID) >= this.Config.MaxProtectionsPerPlayerPerWorld
268+
this.WorldMetadata.CountUserProtections(player.Account.ID) >= this.Config.MaxProtectionsPerPlayerPerWorld
269269
) {
270270
throw new LimitEnforcementException();
271271
}
@@ -274,13 +274,13 @@ public ProtectionEntry CreateProtection(
274274
ProtectionEntry protection;
275275

276276
if (this.WorldMetadata.Protections.TryGetValue(tileLocation, out protection)) {
277-
if (protection.Owner == player.User.ID)
277+
if (protection.Owner == player.Account.ID)
278278
throw new AlreadyProtectedException();
279279

280280
throw new TileProtectedException(tileLocation);
281281
}
282282

283-
protection = new ProtectionEntry(player.User.ID, tileLocation, tile.type);
283+
protection = new ProtectionEntry(player.Account.ID, tileLocation, tile.type);
284284
this.WorldMetadata.Protections.Add(tileLocation, protection);
285285

286286
return protection;
@@ -306,7 +306,7 @@ public void RemoveProtection(TSPlayer player, DPoint tileLocation, bool checkIfB
306306
if (!this.WorldMetadata.Protections.TryGetValue(tileLocation, out protection))
307307
throw new NoProtectionException(tileLocation);
308308

309-
if (!canDeprotectEverything && protection.Owner != player.User.ID)
309+
if (!canDeprotectEverything && protection.Owner != player.Account.ID)
310310
throw new TileProtectedException(tileLocation);
311311

312312
if (protection.BankChestKey != BankChestDataKey.Invalid) {
@@ -358,7 +358,7 @@ public void ProtectionShareUser(
358358
throw ex;
359359
}
360360

361-
User user = TShock.Users.GetUserByID(targetUserId);
361+
UserAccount user = TShock.UserAccounts.GetUserAccountByID(targetUserId);
362362
if (user == null)
363363
throw new ArgumentException(null, "targetUserId");
364364

@@ -468,7 +468,7 @@ private void ProtectionSharePreValidation(
468468
}
469469
}
470470

471-
if (protection.Owner != player.User.ID && !player.Group.HasPermission(ProtectorPlugin.ProtectionMaster_Permission)) {
471+
if (protection.Owner != player.Account.ID && !player.Group.HasPermission(ProtectorPlugin.ProtectionMaster_Permission)) {
472472
if (!protection.IsSharedWithPlayer(player))
473473
throw new TileProtectedException(tileLocation);
474474

@@ -500,7 +500,7 @@ public void EnsureProtectionData(
500500
continue;
501501
}
502502

503-
User owner = TShock.Users.GetUserByID(protection.Owner);
503+
UserAccount owner = TShock.UserAccounts.GetUserAccountByID(protection.Owner);
504504
if (owner == null) {
505505
invalidProtectionLocations.Add(location);
506506
continue;

Implementation/UserInteractionHandler.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ private void RootCommand_Exec(CommandArgs args) {
187187
int playerProtectionCount = 0;
188188
lock (this.WorldMetadata.Protections) {
189189
foreach (KeyValuePair<DPoint,ProtectionEntry> protection in this.WorldMetadata.Protections) {
190-
if (protection.Value.Owner == args.Player.User.ID)
190+
if (protection.Value.Owner == args.Player.Account.ID)
191191
playerProtectionCount++;
192192
}
193193
}
@@ -306,7 +306,7 @@ private bool TryExecuteSubCommand(string commandNameLC, CommandArgs args) {
306306
DPoint location = protectionPair.Key;
307307
ProtectionEntry protection = protectionPair.Value;
308308

309-
TShockAPI.DB.User tsUser = TShock.Users.GetUserByID(protection.Owner);
309+
TShockAPI.DB.UserAccount tsUser = TShock.UserAccounts.GetUserAccountByID(protection.Owner);
310310
if (tsUser == null)
311311
protectionsToRemove.Add(location);
312312
}
@@ -974,7 +974,7 @@ private void ShareCommand_Exec(CommandArgs args) {
974974
playerName = args.ParamsToSingleString();
975975
}
976976

977-
TShockAPI.DB.User tsUser;
977+
TShockAPI.DB.UserAccount tsUser;
978978
if (!TShockEx.MatchUserByPlayerName(playerName, out tsUser, args.Player))
979979
return;
980980

@@ -1029,7 +1029,7 @@ private void UnshareCommand_Exec(CommandArgs args) {
10291029
playerName = args.ParamsToSingleString();
10301030
}
10311031

1032-
TShockAPI.DB.User tsUser;
1032+
TShockAPI.DB.UserAccount tsUser;
10331033
if (!TShockEx.MatchUserByPlayerName(playerName, out tsUser, args.Player))
10341034
return;
10351035

@@ -2161,7 +2161,7 @@ where itemsToLookup.Any(li => li.netID == item.Type)
21612161
string chestOwner = "{not protected}";
21622162
ProtectionEntry protection = this.ProtectionManager.GetProtectionAt(chestLocation);
21632163
if (protection != null) {
2164-
User tsUser = TShock.Users.GetUserByID(protection.Owner);
2164+
UserAccount tsUser = TShock.UserAccounts.GetUserAccountByID(protection.Owner);
21652165
chestOwner = tsUser?.Name ?? $"{{user id: {protection.Owner}}}";
21662166
}
21672167

@@ -2294,7 +2294,7 @@ public bool HandleTileEdit(TSPlayer player, TileEditType editType, int blockType
22942294
}
22952295

22962296
if (
2297-
protection.Owner == player.User.ID || (
2297+
protection.Owner == player.Account.ID || (
22982298
this.Config.AutoDeprotectEverythingOnDestruction &&
22992299
player.Group.HasPermission(ProtectorPlugin.ProtectionMaster_Permission)
23002300
)
@@ -2816,7 +2816,7 @@ private void PerformTrade(TSPlayer player, ProtectionEntry protection, Inventory
28162816
}
28172817

28182818
try {
2819-
protection.TradeChestData.AddOrUpdateLooter(player.User.ID);
2819+
protection.TradeChestData.AddOrUpdateLooter(player.Account.ID);
28202820
} catch (InvalidOperationException) {
28212821
player.SendErrorMessage($"The vendor doesn't allow more than {protection.TradeChestData.LootLimitPerPlayer} trades per player.");
28222822
return;
@@ -2858,7 +2858,7 @@ public virtual bool HandleChestModifySlot(TSPlayer player, int chestIndex, int s
28582858
// The player who set up the refill chest or masters shall modify its contents.
28592859
if (
28602860
this.Config.AllowRefillChestContentChanges &&
2861-
(refillChest.Owner == player.User.ID || player.Group.HasPermission(ProtectorPlugin.ProtectionMaster_Permission))
2861+
(refillChest.Owner == player.Account.ID || player.Group.HasPermission(ProtectorPlugin.ProtectionMaster_Permission))
28622862
) {
28632863
refillChest.RefillItems[slotIndex] = newItem;
28642864

@@ -2880,8 +2880,8 @@ public virtual bool HandleChestModifySlot(TSPlayer player, int chestIndex, int s
28802880

28812881
if (refillChest.OneLootPerPlayer || refillChest.RemainingLoots > 0) {
28822882
Contract.Assert(refillChest.Looters != null);
2883-
if (!refillChest.Looters.Contains(player.User.ID)) {
2884-
refillChest.Looters.Add(player.User.ID);
2883+
if (!refillChest.Looters.Contains(player.Account.ID)) {
2884+
refillChest.Looters.Add(player.Account.ID);
28852885

28862886
if (refillChest.RemainingLoots > 0)
28872887
refillChest.RemainingLoots--;
@@ -3366,7 +3366,7 @@ private bool TryGetProtectionInfo(TSPlayer player, DPoint tileLocation, bool sen
33663366

33673367
bool canViewExtendedInfo = (
33683368
player.Group.HasPermission(ProtectorPlugin.ViewAllProtections_Permission) ||
3369-
protection.Owner == player.User.ID ||
3369+
protection.Owner == player.Account.ID ||
33703370
protection.IsSharedWithPlayer(player)
33713371
);
33723372

@@ -3461,7 +3461,7 @@ private bool TryGetProtectionInfo(TSPlayer player, DPoint tileLocation, bool sen
34613461
if (i > 0)
34623462
sharedListBuilder.Append(", ");
34633463

3464-
TShockAPI.DB.User tsUser = TShock.Users.GetUserByID(protection.SharedUsers[i]);
3464+
TShockAPI.DB.UserAccount tsUser = TShock.UserAccounts.GetUserAccountByID(protection.SharedUsers[i]);
34653465
if (tsUser != null)
34663466
sharedListBuilder.Append(tsUser.Name);
34673467
}
@@ -3498,7 +3498,7 @@ private bool TryGetProtectionInfo(TSPlayer player, DPoint tileLocation, bool sen
34983498
}
34993499

35003500
private static string GetUserName(int userId) {
3501-
TShockAPI.DB.User tsUser = TShock.Users.GetUserByID(userId);
3501+
TShockAPI.DB.UserAccount tsUser = TShock.UserAccounts.GetUserAccountByID(userId);
35023502
if (tsUser != null)
35033503
return tsUser.Name;
35043504
else
@@ -3942,7 +3942,7 @@ public bool CheckRefillChestLootability(RefillChestMetadata refillChest, TSPlaye
39423942

39433943
if (
39443944
!this.Config.AllowRefillChestContentChanges ||
3945-
(player.User.ID != refillChest.Owner && !player.Group.HasPermission(ProtectorPlugin.ProtectionMaster_Permission))
3945+
(player.Account.ID != refillChest.Owner && !player.Group.HasPermission(ProtectorPlugin.ProtectionMaster_Permission))
39463946
) {
39473947
if (refillChest.RemainingLoots == 0) {
39483948
if (sendReasonMessages)
@@ -3956,7 +3956,7 @@ public bool CheckRefillChestLootability(RefillChestMetadata refillChest, TSPlaye
39563956
if (refillChest.Looters == null)
39573957
refillChest.Looters = new Collection<int>();
39583958

3959-
if (refillChest.Looters.Contains(player.User.ID)) {
3959+
if (refillChest.Looters.Contains(player.Account.ID)) {
39603960
if (sendReasonMessages)
39613961
player.SendErrorMessage("This chest can be looted only once per player.");
39623962

Implementation/_Data/World/ProtectionEntry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public bool IsSharedWithPlayer(TSPlayer player) {
6363
return (
6464
player.IsLoggedIn && (
6565
this.IsSharedWithEveryone ||
66-
(this.SharedUsers != null && this.SharedUsers.Contains(player.User.ID)) ||
66+
(this.SharedUsers != null && this.SharedUsers.Contains(player.Account.ID)) ||
6767
(this.SharedGroups != null && this.SharedGroups.Contains(player.Group.Name))
6868
)
6969
);

Protector.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@
138138
<Reference Include="MySql.Data, Version=6.9.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
139139
<HintPath>..\packages\MySql.Data.6.9.8\lib\net45\MySql.Data.dll</HintPath>
140140
</Reference>
141-
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
142-
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
141+
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
142+
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
143143
</Reference>
144144
<Reference Include="OTAPI">
145145
<HintPath>..\TShock\TerrariaServerAPI\TerrariaServerAPI\bin\Debug\OTAPI.dll</HintPath>

packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="MySql.Data" version="6.9.8" targetFramework="net451" />
4-
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net451" />
4+
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net451" />
55
<package id="SlowCheetah" version="2.5.10.7" targetFramework="net451" />
66
</packages>

0 commit comments

Comments
 (0)