public static bool ProtectBlockPlace(VanillaSession session, WorldRegion region, PlayerBlockPlacement bp) { if (IsBlockProtected(session, region) == false) return false; if (FilterFire(session, bp)) { string i = ""; if (session.ActiveItem != null) i += "(server)" + session.ActiveItem.ItemID; if (bp.Item != null) i += "(client)" + bp.Item.ItemID; Chatting.Parser.TellAdmin(session.Player.Name + " tried to use " + i + " in " + region.Name + " at " + session.Position); //session.Player.Kick("Arson"); return true; } //If adventure protection is active, allow all actions if (session.Mode == GameMode.Adventure) //buggy but best bet so far return false; //ok, only activate levers and chests //Block all placements, non resident must be inside the region session.TellSystem(Chat.Aqua, "move inside the region before you open a door or chest"); //New method, works - no longer works /* PlayerDigging pd = new PlayerDigging(); pd.Position = bp.BlockPosition.Offset(bp.FaceDirection); pd.Face = Face.Down; pd.Status = PlayerDigging.StatusEnum.CheckBlock; session.FromClient(pd); */ //Old method - not perfect, disabling: /*BlockChange bc = new BlockChange(bp.BlockPosition.Offset(bp.FaceDirection), BlockID.Air); session.Player.SendToClient(bc);*/ return true; }
static bool CursedLand(Client player, PlayerBlockPlacement placement) { SlotItem i = player.Session.ActiveItem; if (i != null && i.ItemID == BlockID.Bucket) { var pps = new PlayerPositionLookClient(); pps.Position = placement.BlockPosition.CloneDouble(); pps.OnGround = false; pps.Position.Y += 1.1; pps.Position.X += 0.5; pps.Position.Z += 0.5; pps.Pitch = Math.PI / 2; pps.Yaw = player.Session.Yaw; player.FromClient(pps); var ppc = new PlayerPositionLookServer(pps.Position); ppc.Pitch = Math.PI / 2; ppc.Yaw = player.Session.Yaw; player.SendToClient(ppc); } BlockChange bc = new BlockChange(placement.BlockPosition.Offset(placement.FaceDirection), BlockID.Air); player.SendToClient(bc); //Block all actions return true; }
static bool FilterFire(VanillaSession session, PlayerBlockPlacement placement) { //Prevent fire, lava and TNT SlotItem i = session.ActiveItem; //A bit safer but not correctly implemented need to consider WindowClick if (i != null) { if (i.ItemID == BlockID.FlintandSteel || i.ItemID == BlockID.Fireball || i.ItemID == BlockID.Lava || i.ItemID == BlockID.TNT || i.ItemID == BlockID.Lavabucket || i.ItemID == BlockID.CartWithTNT) { return true; } } //Safer but forgable client side i = placement.Item; if (i != null) { if (i.ItemID == BlockID.FlintandSteel || i.ItemID == BlockID.Fireball || i.ItemID == BlockID.Lava || i.ItemID == BlockID.TNT || i.ItemID == BlockID.Lavabucket) { return true; } } return false; }
bool FilterLava(PlayerBlockPlacement placement) { if (Player.Admin()) return false; //Log lava SlotItem i = ActiveItem; //Prevent fire, lava and TNT if (i == null) return false; if ((i.ItemID == BlockID.Lava || i.ItemID == BlockID.Lavabucket) && CurrentRegion == null && (placement.BlockPosition.IsNull() == false) && (placement.BlockPosition.Y > 80)) { string msg = "High lava at " + placement.BlockPosition; Log.WritePlayer(this, msg); Chatting.Parser.TellAdmin(Chat.Red + Player.MinecraftUsername + " " + msg); return true; } if (i.ItemID == BlockID.FlintandSteel || i.ItemID == BlockID.Fireball || i.ItemID == BlockID.Lava || i.ItemID == BlockID.TNT || i.ItemID == BlockID.Lavabucket) { if (placement.BlockPosition.IsNull() == false) { if (Player.Uptime < TimeSpan.FromHours(48)) { //Prevent youngsters to place lava in wilderness return true; } string msg = "put " + i.ItemID + " at " + placement.BlockPosition; Log.WritePlayer(this, msg); Chatting.Parser.TellAdmin(Chat.Red + Player.MinecraftUsername + " " + msg); } } return false; }