Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to 1.22 #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 45 additions & 45 deletions InfiniteChests/InfiniteChests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace InfiniteChests
{
[ApiVersion(1, 17)]
[ApiVersion(1, 22)]
public class InfiniteChests : TerrariaPlugin
{
private IDbConnection Database;
Expand Down Expand Up @@ -129,43 +129,43 @@ void OnGetData(GetDataEventArgs e)
}
break;
case PacketTypes.ChestOpen:
{
int action = reader.ReadInt16();
int x = reader.ReadInt16();
int y = reader.ReadInt16();

if (action == -1)
{
if (Infos[plr].TransactionsLeft > 0)
int action = reader.ReadInt16();
int x = reader.ReadInt16();
int y = reader.ReadInt16();

if (action == -1)
{
//user closed the chest, but still have items transferring, close when it finishes.
Infos[plr].ShouldCloseAfterTransactions = true;
if (Infos[plr].TransactionsLeft > 0)
{
//user closed the chest, but still have items transferring, close when it finishes.
Infos[plr].ShouldCloseAfterTransactions = true;
}
else
{
Infos[plr].X = -1;
Infos[plr].Y = -1;
}
}
else
else if (Infos[plr].TransactionsLeft > 0)
{
Infos[plr].X = -1;
Infos[plr].Y = -1;
//the user is still transfering items, they shouldnt be allowed to open another chest until that finishes.
return;
}
}
else if (Infos[plr].TransactionsLeft > 0)
{
//the user is still transfering items, they shouldnt be allowed to open another chest until that finishes.
return;
}
#if !MULTI_USE
if (Infos.Any(p => p.X == x && p.Y == y))
{
//chest is in use, ignore
TShock.Players[plr].SendErrorMessage("This chest is currently open by someone else.");
return;
}
if (Infos.Any(p => p.X == x && p.Y == y))
{
//chest is in use, ignore
TShock.Players[plr].SendErrorMessage("This chest is currently open by someone else.");
return;
}
#endif
int length = reader.ReadByte();
int length = reader.ReadByte();

if (length != 0 && length <= 20 && length != 255)
TShock.Players[plr].SendData(PacketTypes.ChestName, "", 0, x, y);
}
break;
if (length != 0 && length <= 20 && length != 255)
TShock.Players[plr].SendData(PacketTypes.ChestName, "", 0, x, y);
}
break;
case PacketTypes.TileKill:
{
if (Infos[plr].TransactionsLeft > 0)
Expand Down Expand Up @@ -333,7 +333,7 @@ void OnPostInitialize(EventArgs e)
if (converted > 0)
{
TSPlayer.Server.SendSuccessMessage("[InfiniteChests] Converted {0} chest{1}.", converted, converted == 1 ? "" : "s");
WorldFile.saveWorld();
TShock.Utils.SaveWorld();
}
}

Expand Down Expand Up @@ -383,7 +383,7 @@ void GetChest(int x, int y, int plr)
player.SendErrorMessage("This chest is already protected.");
break;
}
Database.Query("UPDATE Chests SET Account = @0 WHERE ID = @1", player.UserAccountName, chest.ID);
Database.Query("UPDATE Chests SET Account = @0 WHERE ID = @1", player.User.Name, chest.ID);
player.SendSuccessMessage("This chest is now protected.");
break;
case ChestAction.TogglePublic:
Expand All @@ -392,7 +392,7 @@ void GetChest(int x, int y, int plr)
player.SendErrorMessage("This chest is not protected.");
break;
}
if (chest.Account != player.UserAccountName && !player.Group.HasPermission("infchests.admin.editall"))
if (chest.Account != player.User.Name && !player.Group.HasPermission("infchests.admin.editall"))
{
player.SendErrorMessage("This chest is not yours.");
break;
Expand All @@ -406,7 +406,7 @@ void GetChest(int x, int y, int plr)
player.SendErrorMessage("This chest is not protected.");
break;
}
if (chest.Account != player.UserAccountName && !player.Group.HasPermission("infchests.admin.editall"))
if (chest.Account != player.User.Name && !player.Group.HasPermission("infchests.admin.editall"))
{
player.SendErrorMessage("This chest is not yours.");
break;
Expand All @@ -420,7 +420,7 @@ void GetChest(int x, int y, int plr)
player.SendErrorMessage("This chest is not protected.");
break;
}
if (chest.Account != player.UserAccountName && !player.Group.HasPermission("infchests.admin.editall"))
if (chest.Account != player.User.Name && !player.Group.HasPermission("infchests.admin.editall"))
{
player.SendErrorMessage("This chest is not yours.");
break;
Expand Down Expand Up @@ -457,7 +457,7 @@ void GetChest(int x, int y, int plr)
player.SendErrorMessage("This chest is not protected.");
break;
}
if (chest.Account != player.UserAccountName && !player.Group.HasPermission("infchests.admin.editall"))
if (chest.Account != player.User.Name && !player.Group.HasPermission("infchests.admin.editall"))
{
player.SendErrorMessage("This chest is not yours.");
break;
Expand All @@ -479,7 +479,7 @@ void GetChest(int x, int y, int plr)
player.SendErrorMessage("This chest is not protected.");
break;
}
if (chest.Account != player.UserAccountName && !player.Group.HasPermission("infchests.admin.editall"))
if (chest.Account != player.User.Name && !player.Group.HasPermission("infchests.admin.editall"))
{
player.SendErrorMessage("This chest is not yours.");
break;
Expand All @@ -501,7 +501,7 @@ void GetChest(int x, int y, int plr)
player.SendErrorMessage("This chest is not protected.");
break;
}
if (chest.Account != player.UserAccountName && !player.Group.HasPermission("infchests.admin.editall"))
if (chest.Account != player.User.Name && !player.Group.HasPermission("infchests.admin.editall"))
{
player.SendErrorMessage("This chest is not yours.");
break;
Expand All @@ -519,7 +519,7 @@ void GetChest(int x, int y, int plr)
#endif

bool isFree = String.IsNullOrEmpty(chest.Account);
bool isOwner = chest.Account == player.UserAccountName || player.Group.HasPermission("infchests.admin.editall");
bool isOwner = chest.Account == player.User.Name || player.Group.HasPermission("infchests.admin.editall");
bool isRegion = chest.IsRegion && TShock.Regions.CanBuild(x, y, player);
if (!isFree && !isOwner && !chest.IsPublic && !isRegion)
{
Expand Down Expand Up @@ -606,7 +606,7 @@ void KillChest(int x, int y, int plr)
WorldGen.KillTile(x, y);
TSPlayer.All.SendData(PacketTypes.Tile, "", 0, x, y + 1);
}
else if (chest.Account != player.UserAccountName && !String.IsNullOrEmpty(chest.Account) && !player.Group.HasPermission("infchests.admin.editall"))
else if (chest.Account != player.User.Name && !String.IsNullOrEmpty(chest.Account) && !player.Group.HasPermission("infchests.admin.editall"))
{
player.SendErrorMessage("This chest is protected.");
player.SendTileSquare(x, y, 3);
Expand Down Expand Up @@ -735,7 +735,7 @@ void PlaceChest(int x, int y, int plr)
{
TSPlayer player = TShock.Players[plr];
Database.Query("INSERT INTO Chests (X, Y, Account, Flags, Items, Password, WorldID) VALUES (@0, @1, @2, 0, @3, NULL, @4)",
x, y - 1, (player.IsLoggedIn && player.Group.HasPermission("infchests.chest.protect")) ? player.UserAccountName : null,
x, y - 1, (player.IsLoggedIn && player.Group.HasPermission("infchests.chest.protect")) ? player.User.Name : null,
"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0," +
"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0", Main.worldID);
Main.chest[999] = null;
Expand Down Expand Up @@ -789,7 +789,7 @@ void Bank(CommandArgs e)
}
void ConvertChests(CommandArgs e)
{
Task.Factory.StartNew(() =>
Task.Factory.StartNew(() =>
{
int converted = 0;
var items = new StringBuilder();
Expand All @@ -810,7 +810,7 @@ void ConvertChests(CommandArgs e)

e.Player.SendSuccessMessage("Converted {0} chest{1}.", converted, converted == 1 ? "" : "s");
if (converted > 0)
WorldFile.saveWorld();
TShock.Utils.SaveWorld();
}).LogExceptions();
}
void Deselect(CommandArgs e)
Expand Down Expand Up @@ -914,7 +914,7 @@ void Prune(CommandArgs e)

e.Player.SendSuccessMessage("Pruned {0} corrupted chest{1}.", corrupted, corrupted == 1 ? "" : "s");
if (corrupted + empty > 0)
WorldFile.saveWorld();
TShock.Utils.SaveWorld();
}).LogExceptions();
}
void Refill(CommandArgs e)
Expand Down Expand Up @@ -996,7 +996,7 @@ void ReverseConvertChests(CommandArgs e)
Database.Query("DELETE FROM Chests WHERE WorldID = @0", Main.worldID);
e.Player.SendSuccessMessage("Reverse converted {0} chests.", i);
if (i > 0)
WorldFile.saveWorld();
TShock.Utils.SaveWorld();
}).LogExceptions();
}
void Unlock(CommandArgs e)
Expand Down
5 changes: 4 additions & 1 deletion InfiniteChests/InfiniteChests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>InfiniteChests</RootNamespace>
<AssemblyName>InfiniteChests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
Expand All @@ -22,6 +22,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -32,6 +33,7 @@
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>true</UseVSHostingProcess>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release Multi-Use|AnyCPU'">
<OutputPath>bin\</OutputPath>
Expand All @@ -41,6 +43,7 @@
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Data.Sqlite">
Expand Down
Binary file modified InfiniteChests/bin/InfiniteChests.dll
Binary file not shown.
Binary file modified References/MySql.Data.dll
Binary file not shown.
Binary file modified References/TShockAPI.dll
Binary file not shown.
Binary file modified References/TerrariaServer.exe
Binary file not shown.