Improved server side inventory handling
Allowed item bans to effect armor worn, YAY FOR RP SERVERS
This commit is contained in:
parent
59e595c812
commit
021728525d
4 changed files with 56 additions and 29 deletions
|
|
@ -350,7 +350,6 @@ namespace TShockAPI
|
|||
{
|
||||
if (args.Player.Group.HasPermission(Permissions.bypassinventorychecks))
|
||||
{
|
||||
args.Player.IgnoreActionsForInventory = false;
|
||||
args.Player.IgnoreActionsForClearingTrashCan = false;
|
||||
}
|
||||
else if (!TShock.CheckInventory(args.Player))
|
||||
|
|
@ -363,12 +362,15 @@ namespace TShockAPI
|
|||
|
||||
if (args.Player.Group.HasPermission(Permissions.ignorestackhackdetection))
|
||||
args.Player.IgnoreActionsForCheating = "none";
|
||||
|
||||
if (args.Player.Group.HasPermission(Permissions.usebanneditem))
|
||||
args.Player.IgnoreActionsForDisabledArmor = "none";
|
||||
|
||||
args.Player.Group = TShock.Utils.GetGroup(user.Group);
|
||||
args.Player.UserAccountName = args.Parameters[0];
|
||||
args.Player.UserID = TShock.Users.GetUserID(args.Player.UserAccountName);
|
||||
args.Player.IsLoggedIn = true;
|
||||
args.Player.IgnoreActionsForInventory = false;
|
||||
args.Player.IgnoreActionsForInventory = "none";
|
||||
|
||||
args.Player.PlayerData.CopyInventory(args.Player);
|
||||
TShock.InventoryDB.InsertPlayerData(args.Player);
|
||||
|
|
|
|||
|
|
@ -286,7 +286,11 @@ namespace TShockAPI
|
|||
|
||||
if (TShock.Config.ServerSideInventory)
|
||||
{
|
||||
if (!TShock.CheckInventory(args.Player))
|
||||
if (args.Player.Group.HasPermission(Permissions.bypassinventorychecks))
|
||||
{
|
||||
args.Player.IgnoreActionsForClearingTrashCan = false;
|
||||
}
|
||||
else if (!TShock.CheckInventory(args.Player))
|
||||
{
|
||||
args.Player.SendMessage("Login Failed, Please fix the above errors then /login again.", Color.Cyan);
|
||||
args.Player.IgnoreActionsForClearingTrashCan = true;
|
||||
|
|
@ -294,11 +298,17 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
|
||||
if (args.Player.Group.HasPermission(Permissions.ignorestackhackdetection))
|
||||
args.Player.IgnoreActionsForCheating = "none";
|
||||
|
||||
if (args.Player.Group.HasPermission(Permissions.usebanneditem))
|
||||
args.Player.IgnoreActionsForDisabledArmor = "none";
|
||||
|
||||
args.Player.Group = TShock.Utils.GetGroup(user.Group);
|
||||
args.Player.UserAccountName = args.Player.Name;
|
||||
args.Player.UserID = TShock.Users.GetUserID(args.Player.UserAccountName);
|
||||
args.Player.IsLoggedIn = true;
|
||||
args.Player.IgnoreActionsForInventory = false;
|
||||
args.Player.IgnoreActionsForInventory = "none";
|
||||
|
||||
args.Player.PlayerData.CopyInventory(args.Player);
|
||||
TShock.InventoryDB.InsertPlayerData(args.Player);
|
||||
|
|
@ -730,21 +740,25 @@ namespace TShockAPI
|
|||
|
||||
if (!pos.Equals(args.Player.LastNetPosition))
|
||||
{
|
||||
float distance = Vector2.Distance(new Vector2((pos.X / 16f), (pos.Y / 16f)), new Vector2(Main.spawnTileX, Main.spawnTileY));
|
||||
float distance = Vector2.Distance(new Vector2(pos.X / 16f, pos.Y / 16f), new Vector2(args.Player.LastNetPosition.X / 16f, args.Player.LastNetPosition.Y / 16f));
|
||||
if (TShock.CheckIgnores(args.Player) && distance > TShock.Config.MaxRangeForDisabled)
|
||||
{
|
||||
if(args.Player.IgnoreActionsForCheating != "none")
|
||||
{
|
||||
args.Player.SendMessage("Disabled for cheating: " + args.Player.IgnoreActionsForCheating, Color.Red);
|
||||
}
|
||||
else if (args.Player.IgnoreActionsForDisabledArmor != "none")
|
||||
{
|
||||
args.Player.SendMessage("Disabled for banned armor: " + args.Player.IgnoreActionsForDisabledArmor, Color.Red);
|
||||
}
|
||||
else if (args.Player.IgnoreActionsForInventory != "none")
|
||||
{
|
||||
args.Player.SendMessage("Disabled for Server Side Inventory: " + args.Player.IgnoreActionsForInventory, Color.Red);
|
||||
}
|
||||
else if (TShock.Config.RequireLogin && !args.Player.IsLoggedIn)
|
||||
{
|
||||
args.Player.SendMessage("Please /register or /login to play!", Color.Red);
|
||||
}
|
||||
else if (args.Player.IgnoreActionsForInventory)
|
||||
{
|
||||
args.Player.SendMessage("Server Side Inventory is enabled! Please /register or /login to play!", Color.Red);
|
||||
}
|
||||
else if (args.Player.IgnoreActionsForClearingTrashCan)
|
||||
{
|
||||
args.Player.SendMessage("You need to rejoin to ensure your trash can is cleared!", Color.Red);
|
||||
|
|
@ -753,7 +767,12 @@ namespace TShockAPI
|
|||
{
|
||||
args.Player.SendMessage("PvP is forced! Enable PvP else you can't move or do anything!", Color.Red);
|
||||
}
|
||||
args.Player.Spawn();
|
||||
int lastTileX = (int)(args.Player.LastNetPosition.X / 16f);
|
||||
int lastTileY = (int)(args.Player.LastNetPosition.Y / 16f);
|
||||
if (!args.Player.Teleport(lastTileX, lastTileY + 3))
|
||||
{
|
||||
args.Player.Spawn();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,8 +70,9 @@ namespace TShockAPI
|
|||
public int Difficulty;
|
||||
private string CacheIP;
|
||||
public bool IgnoreActionsForPvP = false;
|
||||
public bool IgnoreActionsForInventory = false;
|
||||
public string IgnoreActionsForInventory = "none";
|
||||
public string IgnoreActionsForCheating = "none";
|
||||
public string IgnoreActionsForDisabledArmor = "none";
|
||||
public bool IgnoreActionsForClearingTrashCan = false;
|
||||
public PlayerData PlayerData;
|
||||
public bool RequiresPassword = false;
|
||||
|
|
@ -234,7 +235,7 @@ namespace TShockAPI
|
|||
{
|
||||
InitSpawn = false;
|
||||
|
||||
|
||||
LastNetPosition = new Vector2(tilex * 16f, tiley * 16f);
|
||||
SendWorldInfo(tilex, tiley, true);
|
||||
|
||||
//150 Should avoid all client crash errors
|
||||
|
|
@ -261,6 +262,7 @@ namespace TShockAPI
|
|||
|
||||
public void Spawn()
|
||||
{
|
||||
LastNetPosition = new Vector2(TPlayer.SpawnX*16f, TPlayer.SpawnX*16f);
|
||||
Spawn(TPlayer.SpawnX, TPlayer.SpawnY);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -532,6 +532,13 @@ namespace TShockAPI
|
|||
{
|
||||
player.Spawn();
|
||||
}
|
||||
string check = "none";
|
||||
foreach (Item item in player.TPlayer.armor)
|
||||
{
|
||||
if (!player.Group.HasPermission(Permissions.usebanneditem) && TShock.Itembans.ItemIsBanned(item.name, player))
|
||||
check = "Remove Armor/Accessory (" + item.name + ")";
|
||||
}
|
||||
player.IgnoreActionsForDisabledArmor = check;
|
||||
}
|
||||
}
|
||||
Console.Title = string.Format("TerrariaShock Version {0} ({1}) ({2}/{3})", Version, VersionCodename, count, Config.MaxSlots);
|
||||
|
|
@ -796,18 +803,13 @@ namespace TShockAPI
|
|||
|
||||
if (!player.IsLoggedIn)
|
||||
{
|
||||
if (Config.RequireLogin)
|
||||
{
|
||||
player.SendMessage("Please /register or /login to play!", Color.Red);
|
||||
}
|
||||
else if (Config.ServerSideInventory)
|
||||
{
|
||||
player.SendMessage("Server Side Inventory is enabled! Please /register or /login to play!", Color.Red);
|
||||
}
|
||||
|
||||
if (Config.ServerSideInventory)
|
||||
{
|
||||
player.IgnoreActionsForInventory = true;
|
||||
player.SendMessage(player.IgnoreActionsForInventory = "Server Side Inventory is enabled! Please /register or /login to play!", Color.Red);
|
||||
}
|
||||
else if (Config.RequireLogin)
|
||||
{
|
||||
player.SendMessage("Please /register or /login to play!", Color.Red);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1173,7 +1175,7 @@ namespace TShockAPI
|
|||
item.netDefaults(inventory[i].netID);
|
||||
item.Prefix(inventory[i].prefix);
|
||||
item.AffixName();
|
||||
player.SendMessage("Error: Your item (" + item.name + ") needs to be deleted.", Color.Cyan);
|
||||
player.SendMessage(player.IgnoreActionsForInventory = "Your item (" + item.name + ") needs to be deleted.", Color.Cyan);
|
||||
check = false;
|
||||
}
|
||||
else if (playerData.inventory[i].prefix != inventory[i].prefix)
|
||||
|
|
@ -1181,7 +1183,7 @@ namespace TShockAPI
|
|||
item.netDefaults(inventory[i].netID);
|
||||
item.Prefix(inventory[i].prefix);
|
||||
item.AffixName();
|
||||
player.SendMessage("Error: Your item (" + item.name + ") needs to be deleted.", Color.Cyan);
|
||||
player.SendMessage(player.IgnoreActionsForInventory = "Your item (" + item.name + ") needs to be deleted.", Color.Cyan);
|
||||
check = false;
|
||||
}
|
||||
else if (inventory[i].stack > playerData.inventory[i].stack)
|
||||
|
|
@ -1189,7 +1191,7 @@ namespace TShockAPI
|
|||
item.netDefaults(inventory[i].netID);
|
||||
item.Prefix(inventory[i].prefix);
|
||||
item.AffixName();
|
||||
player.SendMessage("Error: Your item (" + item.name + ") (" + inventory[i].stack + ") needs to have it's stack decreased to (" + playerData.inventory[i].stack + ").", Color.Cyan);
|
||||
player.SendMessage(player.IgnoreActionsForInventory = "Your item (" + item.name + ") (" + inventory[i].stack + ") needs to have it's stack decreased to (" + playerData.inventory[i].stack + ").", Color.Cyan);
|
||||
check = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1205,7 +1207,7 @@ namespace TShockAPI
|
|||
item.netDefaults(armor[i - 48].netID);
|
||||
item.Prefix(armor[i - 48].prefix);
|
||||
item.AffixName();
|
||||
player.SendMessage("Error: Your armor (" + item.name + ") needs to be deleted.", Color.Cyan);
|
||||
player.SendMessage(player.IgnoreActionsForInventory = "Your armor (" + item.name + ") needs to be deleted.", Color.Cyan);
|
||||
check = false;
|
||||
}
|
||||
else if (playerData.inventory[i].prefix != armor[i - 48].prefix)
|
||||
|
|
@ -1213,7 +1215,7 @@ namespace TShockAPI
|
|||
item.netDefaults(armor[i - 48].netID);
|
||||
item.Prefix(armor[i - 48].prefix);
|
||||
item.AffixName();
|
||||
player.SendMessage("Error: Your armor (" + item.name + ") needs to be deleted.", Color.Cyan);
|
||||
player.SendMessage(player.IgnoreActionsForInventory = "Your armor (" + item.name + ") needs to be deleted.", Color.Cyan);
|
||||
check = false;
|
||||
}
|
||||
else if (armor[i - 48].stack > playerData.inventory[i].stack)
|
||||
|
|
@ -1221,7 +1223,7 @@ namespace TShockAPI
|
|||
item.netDefaults(armor[i - 48].netID);
|
||||
item.Prefix(armor[i - 48].prefix);
|
||||
item.AffixName();
|
||||
player.SendMessage("Error: Your armor (" + item.name + ") (" + inventory[i].stack + ") needs to have it's stack decreased to (" + playerData.inventory[i].stack + ").", Color.Cyan);
|
||||
player.SendMessage(player.IgnoreActionsForInventory = "Your armor (" + item.name + ") (" + inventory[i].stack + ") needs to have it's stack decreased to (" + playerData.inventory[i].stack + ").", Color.Cyan);
|
||||
check = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1236,10 +1238,12 @@ namespace TShockAPI
|
|||
bool check = false;
|
||||
if (player.IgnoreActionsForPvP)
|
||||
check = true;
|
||||
if (player.IgnoreActionsForInventory)
|
||||
if (player.IgnoreActionsForInventory != "none")
|
||||
check = true;
|
||||
if (player.IgnoreActionsForCheating != "none")
|
||||
check = true;
|
||||
if (player.IgnoreActionsForDisabledArmor != "none")
|
||||
check = true;
|
||||
if (!player.IsLoggedIn && Config.RequireLogin)
|
||||
check = true;
|
||||
return check;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue