void OnLiquidFlow(ref HookContext ctx, ref HookArgs.LiquidFlowReceived args) { var player = ctx.Player; if (player == null || player.Name == null) { ProgramLog.Log("<Restrict> Invalid player in OnLiquidFlow."); 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, LiquidFlow)) { ctx.SetResult(HookResult.RECTIFY); player.sendMessage("<Restrict> You are not allowed to alter the world without permissions."); } }
void OnLiquidFlowReceived(ref HookContext ctx, ref HookArgs.LiquidFlowReceived args) { Vector2 Position = new Vector2(args.X, args.Y); foreach (Region rgn in regionManager.Regions) { if (rgn.HasPoint(Position)) { if (IsRestrictedForUser(ctx.Player, rgn, LiquidFlow)) { ctx.SetResult(HookResult.ERASE); ctx.Player.sendMessage("You cannot edit this area!", ChatColor.Red); return; } } } }
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); num += 4; byte liquid = readBuffer[num++]; byte lavaFlag = readBuffer[num]++; var player = Main.players[whoAmI]; if (NetPlay.spamCheck) // dead code... { int centerX = (int)(player.Position.X + (float)(player.Width / 2)); int centerY = (int)(player.Position.Y + (float)(player.Height / 2)); int disperseDistance = 10; int left = centerX - disperseDistance; int right = centerX + disperseDistance; int top = centerY - disperseDistance; int bottom = centerY + disperseDistance; if (centerX < left || centerX > right || centerY < top || centerY > bottom) { NetMessage.BootPlayer(whoAmI, "Cheating attempt detected: Liquid spam"); return; } } var ctx = new HookContext { Connection = player.Connection, Player = player, Sender = player, }; var args = new HookArgs.LiquidFlowReceived { X = x, Y = y, Amount = liquid, Lava = lavaFlag == 1, }; HookPoints.LiquidFlowReceived.Invoke(ref ctx, ref args); if (ctx.CheckForKick()) { return; } if (ctx.Result == HookResult.IGNORE) { return; } if (ctx.Result == HookResult.RECTIFY) { var msg = NetMessage.PrepareThreadInstance(); msg.FlowLiquid(x, y); msg.Send(whoAmI); return; } TileRef tile = Main.tile.At(x, y); { tile.SetLiquid(liquid); tile.SetLava(lavaFlag == 1); WorldModify.SquareTileFrame(null, null, x, y, true); } }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { int x = (int)ReadInt16(readBuffer); int y = (int)ReadInt16(readBuffer); byte liquid = ReadByte(readBuffer); byte liquidType = ReadByte(readBuffer); var player = Main.player[whoAmI]; if (Main.netMode == 2 && Netplay.spamCheck) { int num113 = whoAmI; int num114 = (int)(Main.player[num113].position.X + (float)(Main.player[num113].width / 2)); int num115 = (int)(Main.player[num113].position.Y + (float)(Main.player[num113].height / 2)); int num116 = 10; int num117 = num114 - num116; int num118 = num114 + num116; int num119 = num115 - num116; int num120 = num115 + num116; if (x < num117 || x > num118 || y < num119 || y > num120) { //NewNetMessage.BootPlayer(whoAmI, "Cheating attempt detected: Liquid spam"); Main.player[num113].Kick("Cheating attempt detected: Liquid spam"); return; } } var ctx = new HookContext { Connection = player.Connection, Player = player, Sender = player, }; var args = new HookArgs.LiquidFlowReceived { X = x, Y = y, Amount = liquid, Lava = liquidType == 1, }; HookPoints.LiquidFlowReceived.Invoke(ref ctx, ref args); if (ctx.CheckForKick()) { return; } if (ctx.Result == HookResult.IGNORE) { return; } if (ctx.Result == HookResult.RECTIFY) { var msg = NewNetMessage.PrepareThreadInstance(); msg.FlowLiquid(x, y); msg.Send(whoAmI); return; } if (Main.tile[x, y] == null) { Main.tile[x, y] = new Tile(); } lock (Main.tile[x, y]) { Main.tile[x, y].liquid = liquid; Main.tile[x, y].liquidType((int)liquidType); if (Main.netMode == 2) { WorldGen.SquareTileFrame(x, y, true); } return; } }