private bool TileChange(ref BinaryReader reader, int playerNumber) { if (Main.netMode == 2) { try { Player p = Main.player[playerNumber]; ServerPlayer player = p.GetServerPlayer(); int action = reader.ReadByte(); short X = reader.ReadInt16(); short Y = reader.ReadInt16(); short type = reader.ReadInt16(); int style = reader.ReadByte(); if (ServerSideCharacter.CheckSpawn(X, Y) && player.PermissionGroup.GroupName != "spadmin") { player.SendErrorInfo("Warning: Spawn is protected from change"); NetMessage.SendTileSquare(-1, X, Y, 4); return(true); } else if (ServerSideCharacter.RegionManager.CheckRegion(X, Y, player)) { player.SendErrorInfo("Warning: You don't have permission to change this tile"); NetMessage.SendTileSquare(-1, X, Y, 4); return(true); } else if (player.PermissionGroup.GroupName == "criminal") { player.SendErrorInfo("Warning: Criminals cannot change tiles"); NetMessage.SendTileSquare(-1, X, Y, 4); return(true); } } catch (Exception ex) { CommandBoardcast.ConsoleError(ex); } } return(false); }
private bool PlayerControls(ref BinaryReader reader, int playerNumber) { if (Main.netMode == 2) { byte plr = reader.ReadByte(); BitsByte control = reader.ReadByte(); BitsByte pulley = reader.ReadByte(); byte item = reader.ReadByte(); var pos = reader.ReadVector2(); Player player = Main.player[playerNumber]; ServerPlayer sPlayer = player.GetServerPlayer(); if (pulley[2]) { var vel = reader.ReadVector2(); } if (ServerSideCharacter.Config.IsItemBanned(sPlayer.PrototypePlayer.inventory[item], sPlayer)) { sPlayer.ApplyLockBuffs(); sPlayer.SendErrorInfo("You used a banned item: " + player.inventory[item].Name); } } return(false); }
private bool RequestChestOpen(ref BinaryReader reader, int playerNumber) { if (Main.netMode == 2) { int x = reader.ReadInt16(); int y = reader.ReadInt16(); int id = Chest.FindChest(x, y); Player player = Main.player[playerNumber]; ServerPlayer sPlayer = player.GetServerPlayer(); if (ServerSideCharacter.ChestManager.IsNull(id)) { ServerSideCharacter.ChestManager.SetOwner(id, playerNumber); } else if (ServerSideCharacter.ChestManager.CanOpen(id, sPlayer)) { return(false); } else { sPlayer.SendErrorInfo("You cannot open this chest"); } } return(true); }
private bool RequestChestOpen(ref BinaryReader reader, int playerNumber) { if (!ServerSideCharacter.Config.EnableChestProtection) { return(false); } if (Main.netMode == 2) { int x = reader.ReadInt16(); int y = reader.ReadInt16(); int id = Chest.FindChest(x, y); Player player = Main.player[playerNumber]; ServerPlayer sPlayer = player.GetServerPlayer(); ChestManager.Pending pending = ServerSideCharacter.ChestManager.GetPendings(sPlayer); switch (pending) { case ChestManager.Pending.AddFriend: if (ServerSideCharacter.ChestManager.IsOwner(id, sPlayer)) { ServerPlayer friend = ServerSideCharacter.ChestManager.GetFriendP(sPlayer); ServerSideCharacter.ChestManager.AddFriend(id, friend); sPlayer.SendSuccessInfo($"{friend.Name} can open this chest now"); } else { sPlayer.SendErrorInfo("You are not the owner of this chest"); } break; case ChestManager.Pending.RemoveFriend: if (ServerSideCharacter.ChestManager.IsOwner(id, sPlayer)) { ServerPlayer friend = ServerSideCharacter.ChestManager.GetFriendP(sPlayer); ServerSideCharacter.ChestManager.RemoveFriend(id, friend); sPlayer.SendSuccessInfo($"{friend.Name} can't open this chest now"); } else { sPlayer.SendErrorInfo("You are not the owner of this chest"); } break; case ChestManager.Pending.Public: if (ServerSideCharacter.ChestManager.IsOwner(id, sPlayer)) { if (!ServerSideCharacter.ChestManager.IsPublic(id)) { ServerSideCharacter.ChestManager.SetOwner(id, sPlayer.UUID, true); sPlayer.SendSuccessInfo("This chest is now Public"); } else { sPlayer.SendErrorInfo("This chest is already public"); } } else { sPlayer.SendErrorInfo("You are not the owner of this chest"); } break; case ChestManager.Pending.UnPublic: if (ServerSideCharacter.ChestManager.IsOwner(id, sPlayer)) { if (ServerSideCharacter.ChestManager.IsPublic(id)) { ServerSideCharacter.ChestManager.SetOwner(id, sPlayer.UUID, false); sPlayer.SendSuccessInfo("This chest is not Public anymore"); } else { sPlayer.SendErrorInfo("This chest is not public"); } } else { sPlayer.SendErrorInfo("You are not the owner of this chest"); } break; case ChestManager.Pending.Protect: if (ServerSideCharacter.ChestManager.IsNull(id)) { ServerSideCharacter.ChestManager.SetOwner(id, sPlayer.UUID, false); sPlayer.SendSuccessInfo("You now own this chest"); } else if (ServerSideCharacter.ChestManager.IsOwner(id, sPlayer)) { sPlayer.SendErrorInfo("You already protected this chest"); } else { sPlayer.SendErrorInfo("This chest as already been protected by other player"); } break; case ChestManager.Pending.DeProtect: if (ServerSideCharacter.ChestManager.IsOwner(id, sPlayer)) { ServerSideCharacter.ChestManager.SetOwner(id, -1, false); sPlayer.SendSuccessInfo("This chest is no longer yours"); } else if (ServerSideCharacter.ChestManager.IsNull(id)) { sPlayer.SendErrorInfo("This chest don't have a owner"); } else { sPlayer.SendErrorInfo("You are not the owner of this chest"); } break; case ChestManager.Pending.Info: if (ServerSideCharacter.ChestManager.IsOwner(id, sPlayer)) { ChestInfo chest = ServerSideCharacter.ChestManager.ChestInfo[id]; StringBuilder info = new StringBuilder(); if (sPlayer.PermissionGroup.HasPermission("chest")) { info.AppendLine($"Owner: {ServerPlayer.FindPlayer(chest.OwnerID).Name}"); //For Admins } info.AppendLine($"Public Chest: {chest.IsPublic.ToString().ToUpper()}"); info.AppendLine($"Friends ({chest.Friends.Count.ToString()}): {string.Join(", ", chest.Friends.ToArray().Take(10).Select(uuid => ServerPlayer.FindPlayer(uuid).Name))}"); sPlayer.SendInfo(info.ToString()); } else if (ServerSideCharacter.ChestManager.IsNull(id)) { sPlayer.SendErrorInfo("This chest don't have a owner"); } else { sPlayer.SendErrorInfo("You are not the owner of this chest"); } break; default: if (ServerSideCharacter.ChestManager.IsNull(id)) { if (ServerSideCharacter.Config.AutoProtectChests) { ServerSideCharacter.ChestManager.SetOwner(id, sPlayer.UUID, false); sPlayer.SendSuccessInfo("You now own this chest"); } else { sPlayer.SendErrorInfo("Use '/chest protect' to become the owner of this chest"); } return(false); } else if (ServerSideCharacter.ChestManager.CanOpen(id, sPlayer)) { return(false); } else { sPlayer.SendErrorInfo("You cannot open this chest"); } break; } ServerSideCharacter.ChestManager.RemovePending(sPlayer, pending); } return(true); }