void OnChestBreak(ref HookContext ctx, ref HookArgs.ChestBreakReceived args)
        {
            var player = ctx.Player;

            if (player == null || player.Name == null)
            {
                ProgramLog.Log("<Restrict> Invalid player in OnChestBreak.");
                ctx.SetResult(HookResult.IGNORE);
                return;
            }

            if (!restrictGuests)
            {
                return;
            }

            if (player.AuthenticatedAs == null)
            {
                ctx.SetResult(HookResult.RECTIFY);
                player.sendMessage("<Restrict> You are not allowed to alter the world as a guest.");
                player.sendMessage("<Restrict> Type \"/reg password\" to request registration.");
            }
            else if (IsRestrictedForUser(ctx.Player, ChestBreak))
            {
                ctx.SetResult(HookResult.RECTIFY);
                player.sendMessage("<Restrict> You are not allowed to alter the world without permissions.");
            }
        }
Beispiel #2
0
        public override void Process(int whoAmI, byte[] readBuffer, int length, int num)
        {
            int x = BitConverter.ToInt32(readBuffer, num);

            num += 4;
            int y = BitConverter.ToInt32(readBuffer, num);

            if (Main.tile.At(x, y).Type != 21)
            {
                return;
            }

            var player = Main.players[whoAmI];

            var ctx = new HookContext
            {
                Connection = player.Connection,
                Player     = player,
                Sender     = player,
            };

            var args = new HookArgs.ChestBreakReceived
            {
                X = x, Y = y,
            };

            HookPoints.ChestBreakReceived.Invoke(ref ctx, ref args);

            if (ctx.CheckForKick())
            {
                return;
            }

            if (ctx.Result == HookResult.IGNORE)
            {
                return;
            }

            if (ctx.Result == HookResult.RECTIFY)
            {
                NetMessage.SendTileSquare(whoAmI, x, y, 3);
                return;
            }

            WorldModify.KillTile(null, null, x, y);

            if (!Main.tile.At(x, y).Active || Main.tile.At(x, y).Type != 21)
            {
                NetMessage.SendData(17, -1, -1, "", 0, (float)x, (float)y);
            }
        }
Beispiel #3
0
 void OnChestBreak(ref HookContext ctx, ref HookArgs.ChestBreakReceived args)
 {
     foreach (Region rgn in regionManager.Regions)
     {
         if (rgn.HasPoint(new Vector2(args.X, args.Y)))
         {
             if (ctx.Sender is Player)
             {
                 if (IsRestrictedForUser(ctx.Player, rgn, DoorChange))
                 {
                     ctx.SetResult(HookResult.RECTIFY);
                     ctx.Player.sendMessage("You cannot edit this area!", ChatColor.Red);
                     return;
                 }
             }
         }
     }
 }
        public override void Process(int whoAmI, byte[] readBuffer, int length, int num)
        {
            byte method = ReadByte(readBuffer);
            int  x      = (int)ReadInt16(readBuffer);
            int  y      = (int)ReadInt16(readBuffer);
            int  type   = (int)ReadInt16(readBuffer);

            var player = Main.player[whoAmI];

            var ctx = new HookContext
            {
                Connection = player.Connection,
                Player     = player,
                Sender     = player,
            };

            var args = new HookArgs.ChestBreakReceived
            {
                X = x,
                Y = y
            };

            HookPoints.ChestBreakReceived.Invoke(ref ctx, ref args);

            if (ctx.CheckForKick())
            {
                return;
            }

            if (ctx.Result == HookResult.IGNORE)
            {
                return;
            }

            if (ctx.Result == HookResult.RECTIFY)
            {
                NewNetMessage.SendTileSquare(whoAmI, x, y, 3);
                return;
            }

            {
                if (method == 0)
                {
                    int num92 = WorldGen.PlaceChest(x, y, 21, false, type);
                    if (num92 == -1)
                    {
                        NewNetMessage.SendData(34, whoAmI, -1, String.Empty, (int)method, (float)x, (float)y, (float)type, num92);
                        Item.NewItem(x * 16, y * 16, 32, 32, Chest.itemSpawn[type], 1, true, 0, false);
                        return;
                    }
                    NewNetMessage.SendData(34, -1, -1, String.Empty, (int)method, (float)x, (float)y, (float)type, num92);
                    return;
                }
                else
                {
                    Tile tile2 = Main.tile[x, y];
                    if (tile2.type != 21)
                    {
                        return;
                    }
                    if (tile2.frameX % 36 != 0)
                    {
                        x--;
                    }
                    if (tile2.frameY % 36 != 0)
                    {
                        y--;
                    }
                    int number = Chest.FindChest(x, y);
                    WorldGen.KillTile(x, y, false, false, false);
                    if (!tile2.active())
                    {
                        NewNetMessage.SendData(34, -1, -1, String.Empty, (int)method, (float)x, (float)y, 0f, number);
                        return;
                    }
                    return;
                }
            }
        }