예제 #1
0
 private void OnTileEdit( object sender, GetDataHandlers.TileEditEventArgs args )
 {
     if (players[args.Player.Index])
     {
         switch( args.Action )
         {
             case GetDataHandlers.EditAction.KillTile:
             case GetDataHandlers.EditAction.KillTileNoItem:
                 WorldGen.KillTile(args.X, args.Y);
                 TSPlayer.All.SendTileSquare(args.X, args.Y, 1);
                 break;
             case GetDataHandlers.EditAction.KillWall:
                 WorldGen.KillWall(args.X, args.Y);
                 TSPlayer.All.SendTileSquare(args.X, args.Y, 1);
                 break;
             case GetDataHandlers.EditAction.KillWire:
                 WorldGen.KillWire(args.X, args.Y);
                 TSPlayer.All.SendTileSquare(args.X, args.Y, 1);
                 break;
             case GetDataHandlers.EditAction.KillWire2:
                 WorldGen.KillWire2(args.X, args.Y);
                 TSPlayer.All.SendTileSquare(args.X, args.Y, 1);
                 break;
             case GetDataHandlers.EditAction.KillWire3:
                 WorldGen.KillWire3(args.X, args.Y);
                 TSPlayer.All.SendTileSquare(args.X, args.Y, 1);
                 break;
         }
     }
 }
예제 #2
0
        private void OnGetData(GetDataEventArgs e)
        {
            if (e.Handled)
            {
                return;
            }

            PacketTypes type = e.MsgID;

            Debug.WriteLine("Recv: {0:X}: {2} ({1:XX})", e.Msg.whoAmI, (byte)type, type);

            var player = Players[e.Msg.whoAmI];

            if (player == null)
            {
                e.Handled = true;
                return;
            }

            if (!player.ConnectionAlive)
            {
                e.Handled = true;
                return;
            }

            if (player.RequiresPassword && type != PacketTypes.PasswordSend)
            {
                e.Handled = true;
                return;
            }

            if ((player.State < 10 || player.Dead) && (int)type > 12 && (int)type != 16 && (int)type != 42 && (int)type != 50 && (int)type != 38)
            {
                e.Handled = true;
                return;
            }

            using (var data = new MemoryStream(e.Msg.readBuffer, e.Index, e.Length))
            {
                try
                {
                    if (GetDataHandlers.HandlerGetData(type, player, data))
                    {
                        e.Handled = true;
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());
                }
            }
        }
예제 #3
0
        private void OnGetData(GetDataEventArgs e)
        {
            if (e.Handled)
            {
                return;
            }

            PacketTypes type = e.MsgID;

            Debug.WriteLine("Recv: {0:X}: {2} ({1:XX})", e.Msg.whoAmI, (byte)type, type);

            var player = Players[e.Msg.whoAmI];

            if (player == null)
            {
                e.Handled = true;
                return;
            }

            if (!player.ConnectionAlive)
            {
                e.Handled = true;
                return;
            }



            // Stop accepting updates from player as this player is going to be kicked/banned during OnUpdate (different thread so can produce race conditions)
            if ((Config.BanKillTileAbusers || Config.KickKillTileAbusers) &&
                player.TileThreshold >= Config.TileThreshold && !player.Group.HasPermission(Permissions.ignoregriefdetection))
            {
                Log.Debug("Rejecting " + type + " from " + player.Name + " as this player is about to be kicked");
                e.Handled = true;
            }
            else
            {
                using (var data = new MemoryStream(e.Msg.readBuffer, e.Index, e.Length))
                {
                    try
                    {
                        if (GetDataHandlers.HandlerGetData(type, player, data))
                        {
                            e.Handled = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex.ToString());
                    }
                }
            }
        }
예제 #4
0
 private void OnTileEdit( object sender, GetDataHandlers.TileEditEventArgs args )
 {
     if (players[args.Player.Index])
     {
         switch (args.EditType)
         {
             case 0:
             case 4:
                 {
                     Recursive re = new Recursive();
                     List<Vector2> del = re.RecursiveEdit(args.X, args.Y, args.EditType);
                     foreach (Vector2 tip in del)
                     {
                         WorldGen.KillTile(Convert.ToInt16(tip.X), Convert.ToInt16(tip.Y));
                         TSPlayer.All.SendTileSquare(Convert.ToInt16(tip.X), Convert.ToInt16(tip.Y), 1);
                     }
                     break;
                 }
             case 2:
                 {
                     Recursive re = new Recursive();
                     List<Vector2> del = re.RecursiveEdit(args.X, args.Y, args.EditType);
                     foreach (Vector2 tip in del)
                     {
                         WorldGen.KillWall(Convert.ToInt16(tip.X), Convert.ToInt16(tip.Y));
                         TSPlayer.All.SendTileSquare(Convert.ToInt16(tip.X), Convert.ToInt16(tip.Y), 1);
                     }
                     break;
                 }
             case 6:
                 {
                     Recursive re = new Recursive();
                     List<Vector2> del = re.RecursiveEdit(args.X, args.Y, args.EditType);
                     foreach (Vector2 tip in del)
                     {
                         WorldGen.KillWire(Convert.ToInt16(tip.X), Convert.ToInt16(tip.Y));
                         TSPlayer.All.SendTileSquare(Convert.ToInt16(tip.X), Convert.ToInt16(tip.Y), 1);
                     }
                     break;
                 }
         }
     }
 }
예제 #5
0
 private void ChangeTeam( object sender, GetDataHandlers.PlayerTeamEventArgs args )
 {
     TSPlayer player = TShock.Players[args.PlayerId];
     Point spawn = config.Spawns.GetSpawn(player.Group.Name, args.Team - 1);
     if( spawn.X == -1 || spawn.Y == -1 )
     {
         if (config.Spawns.forceSpawn)
         {
             player.Spawn();
         }
     }
     else
     {
         if (config.Spawns.forceSpawn)
         {
             player.Teleport(spawn.X*16, spawn.Y*16);
         }
     }
 }
예제 #6
0
        private void OnItemDrop(object sender, GetDataHandlers.ItemDropEventArgs args)
        {
            if (args.Handled)
                return;

            for (int i = 0; i < TShock.Players.Length; i++)
            {
                if (TShock.Players[i] == null)
                    continue;

                TSPlayer tsplr = TShock.Players[i];

                if (!tsplr.Group.HasPermission("geldar.admin") && !config.protectedIDs.Contains(args.ID))
                {
                    tsplr.SendErrorMessage("You are not allowed to drop items on the server!");
                    tsplr.SendErrorMessage("Rebind your drop key to avoid the destruction of more items.");
                    tsplr.SendErrorMessage("We will not refund any lost items");
                    args.Handled = true;
                }
            }
        }
예제 #7
0
 private void OnTileEdit( object sender, GetDataHandlers.TileEditEventArgs args )
 {
     if (players[args.Player.Index])
     {
         switch( args.EditType )
         {
             case 0:
             case 4:
                 WorldGen.KillTile(args.X, args.Y);
                 TSPlayer.All.SendTileSquare(args.X, args.Y, 1);
                 break;
             case 2:
                 WorldGen.KillWall(args.X, args.Y);
                 TSPlayer.All.SendTileSquare(args.X, args.Y, 1);
                 break;
             case 6:
                 WorldGen.KillWire(args.X, args.Y);
                 TSPlayer.All.SendTileSquare(args.X, args.Y, 1);
                 break;
         }
     }
 }
예제 #8
0
        /// <summary>Checks whether a player's attempted tile edit is valid. A tile edit is considered invalid if it's only possible due to the presence of phantom tiles.</summary>
        /// <param name="region">The region to check.</param>
        /// <param name="x">The x coordinate of the edited tile.</param>
        /// <param name="y">The y coordinate of the edited tile.</param>
        /// <param name="editType">The type of the edit.</param>
        /// <returns>true if the edit was valid; false if it wasn't.</returns>
        public bool tileValidityCheck(Region region, int x, int y, GetDataHandlers.EditAction editType)
        {
            // Check if there's a wall or another tile next to this tile.
            if (editType == GetDataHandlers.EditAction.PlaceWall) {
                if (Main.tile[x, y] != null && Main.tile[x, y].active()) return true;
                if (Main.tile[x - 1, y] != null && ((Main.tile[x - 1, y].active() && !Main.tileNoAttach[Main.tile[x - 1, y].type]) || Main.tile[x - 1, y].wall > 0)) return true;
                if (Main.tile[x + 1, y] != null && ((Main.tile[x + 1, y].active() && !Main.tileNoAttach[Main.tile[x + 1, y].type]) || Main.tile[x + 1, y].wall > 0)) return true;
                if (Main.tile[x, y - 1] != null && ((Main.tile[x, y - 1].active() && !Main.tileNoAttach[Main.tile[x, y - 1].type]) || Main.tile[x, y - 1].wall > 0)) return true;
                if (Main.tile[x, y + 1] != null && ((Main.tile[x, y + 1].active() && !Main.tileNoAttach[Main.tile[x, y + 1].type]) || Main.tile[x, y + 1].wall > 0)) return true;
            } else {
                if (Main.tile[x, y] != null && Main.tile[x, y].wall > 0) return true;
                if (Main.tile[x - 1, y] != null && Main.tile[x - 1, y].wall > 0) return true;
                if (Main.tile[x + 1, y] != null && Main.tile[x + 1, y].wall > 0) return true;
                if (Main.tile[x, y - 1] != null && Main.tile[x, y - 1].wall > 0) return true;
                if (Main.tile[x, y + 1] != null && Main.tile[x, y + 1].wall > 0) return true;
                if (Main.tile[x - 1, y] != null && Main.tile[x - 1, y].active() && !Main.tileNoAttach[Main.tile[x - 1, y].type]) return true;
                if (Main.tile[x + 1, y] != null && Main.tile[x + 1, y].active() && !Main.tileNoAttach[Main.tile[x + 1, y].type]) return true;
                if (Main.tile[x, y - 1] != null && Main.tile[x, y - 1].active() && !Main.tileNoAttach[Main.tile[x, y - 1].type]) return true;
                if (Main.tile[x, y - 1] != null && Main.tile[x, y + 1].active() && !Main.tileNoAttach[Main.tile[x, y + 1].type]) return true;
            }

            // Check if this tile is next to a region boundary.
            if (x >= region.showArea.Left - 1 && x <= region.showArea.Right + 1 && y >= region.showArea.Top - 1 && y <= region.showArea.Bottom + 1 &&
                !(x >= region.showArea.Left + 2 && x <= region.showArea.Right - 2 && y >= region.showArea.Top + 2 && y <= region.showArea.Bottom - 2))
                    return false;
            return true;
        }
예제 #9
0
파일: BoxesPlugin.cs 프로젝트: mawize/Boxes
        private void OnTileEdit(object sender, GetDataHandlers.TileEditEventArgs args)
        {
            if (args.Player.AwaitingName)
            {
                var protectedboxes = boxman.InAreaBoxName(args.X, args.Y);
                if (protectedboxes.Count == 0)
                {
                    args.Player.SendMessage("Box is not protected", Color.Yellow);
                }
                else
                {
                    string boxlist = string.Join(",", protectedboxes.ToArray());
                    args.Player.SendMessage("Box Name(s): " + boxlist, Color.Yellow);
                }
                args.Player.SendTileSquare(args.X, args.Y);
                args.Player.AwaitingName = false;
                args.Handled = true;
            }

            if (args.Handled)
            {
                return;
            }

            if (!boxman.CanBuild(args.X, args.Y, args.Player))
            {
                if (((DateTime.Now.Ticks/TimeSpan.TicksPerMillisecond) - args.Player.RPm) > 2000)
                {
                    args.Player.SendMessage("Box protected from changes.", Color.Red);
                    args.Player.RPm = DateTime.Now.Ticks/TimeSpan.TicksPerMillisecond;
                }
                args.Player.SendTileSquare(args.X, args.Y);
                args.Handled = true;
            }
        }
예제 #10
0
파일: TShock.cs 프로젝트: B-BOB/TShock
        /// <summary>CheckTilePermission - Checks to see if a player has permission to modify a tile in general.</summary>
        /// <param name="player">player - The TSPlayer object.</param>
        /// <param name="tileX">tileX - The x coordinate of the tile.</param>
        /// <param name="tileY">tileY - The y coordinate of the tile.</param>
        /// <param name="tileType">tileType - The tile type.</param>
        /// <param name="actionType">actionType - The type of edit that took place.</param>
        /// <returns>bool - True if the player should not be able to modify a tile.</returns>
        public static bool CheckTilePermission(TSPlayer player, int tileX, int tileY, short tileType, GetDataHandlers.EditAction actionType)
        {
            if (!player.Group.HasPermission(Permissions.canbuild))
            {
                if (TShock.Config.AllowIce && actionType != GetDataHandlers.EditAction.PlaceTile)
                {
                    foreach (Point p in player.IceTiles)
                    {
                        if (p.X == tileX && p.Y == tileY && (Main.tile[p.X, p.Y].type == 0 || Main.tile[p.X, p.Y].type == 127))
                        {
                            player.IceTiles.Remove(p);
                            return false;
                        }
                    }

                    if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.BPm) > 2000)
                    {
                        player.SendErrorMessage("You do not have permission to build!");
                        player.BPm = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
                    }
                    return true;
                }

                if (TShock.Config.AllowIce && actionType == GetDataHandlers.EditAction.PlaceTile && tileType == 127)
                {
                    player.IceTiles.Add(new Point(tileX, tileY));
                    return false;
                }

                if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.BPm) > 2000)
                {
                    player.SendErrorMessage("You do not have permission to build!");
                    player.BPm = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
                }
                return true;
            }

            if (!player.Group.HasPermission(Permissions.editregion) && !Regions.CanBuild(tileX, tileY, player) &&
                Regions.InArea(tileX, tileY))
            {
                if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.RPm) > 2000)
                {
                    player.SendErrorMessage("This region is protected from changes.");
                    player.RPm = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
                }
                return true;
            }

            if (Config.DisableBuild)
            {
                if (!player.Group.HasPermission(Permissions.antibuild))
                {
                    if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.WPm) > 2000)
                    {
                        player.SendErrorMessage("The world is protected from changes.");
                        player.WPm = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
                    }
                    return true;
                }
            }

            if (Config.SpawnProtection)
            {
                if (!player.Group.HasPermission(Permissions.editspawn))
                {
                    if (CheckSpawn(tileX, tileY))
                    {
                        if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.SPm) > 2000)
                        {
                            player.SendErrorMessage("Spawn is protected from changes.");
                            player.SPm = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
                        }
                        return true;
                    }
                }
            }
            return false;
        }
예제 #11
0
 void OnProjectile(Object sender, GetDataHandlers.NewProjectileEventArgs args)
 {
     if (args.Owner < 255)
     {
         var projectile = Main.projectile[args.Identity];
         if (projectile.active && projectile.type == 34 && cannonPlayers[args.Owner] && Main.player[args.Owner].channel && !projectileList.Contains(projectile))
         {
             projectileList.Add(projectile);
         }
     }
 }
예제 #12
0
 public void OnTileEdit(object sender, GetDataHandlers.TileEditEventArgs args)
 {
     FTPlayer ply = FreezeTools.GetFTPlayerByID(args.Player.Index);
     if (args.Handled)
     {
         return;
     }
     if (ply.Tagged)
     {
         args.Player.SendTileSquare(args.X, args.Y);
         args.Handled = true;
     }
     if (ply.IsIt)
     {
         if (ply.CurrentGame != null)
         {
             lock (ply.CurrentGame.Players)
             {
                 foreach (FTPlayer plyr in ply.CurrentGame.Players)
                 {
                     if (plyr.Tagged && FreezeTools.GetRectOutline(plyr.TagBox).Contains(new Point((int)args.X, (int)args.Y)))
                     {
                         args.Handled = true;
                     }
                 }
             }
         }
     }
 }
예제 #13
0
 private void TileKill(object sender, GetDataHandlers.TileEditEventArgs args)
 {
     if (args.Action == GetDataHandlers.EditAction.KillWall && blacklistedWalls.Contains(Main.tile[args.X, args.Y].wall) && !args.Player.Group.HasPermission("invincibletile.breakwall"))
     {
         args.Handled = true;
         args.Player.SendErrorMessage("You do not have permission to break protected walls.");
         TSPlayer.All.SendTileSquare(args.X, args.Y, 1);
     }
     else if ((args.Action == GetDataHandlers.EditAction.KillTile || args.Action == GetDataHandlers.EditAction.KillTileNoItem || args.Action == GetDataHandlers.EditAction.PoundTile) && blacklistedTiles.Contains(Main.tile[args.X, args.Y].type) && !args.Player.Group.HasPermission("invincibletile.breaktile"))
     {
         args.Handled = true;
         args.Player.SendErrorMessage("You do not have permission to modify protected tiles.");
         TSPlayer.All.SendTileSquare(args.X,args.Y, 1);
     }
     else if (args.Action == GetDataHandlers.EditAction.PlaceTile)
     {
         if (blacklistedWalls.Contains(Main.tile[args.X, args.Y].wall) && !args.Player.Group.HasPermission("invincibletile.placeoverprotectedwalls"))
         {
             args.Handled = true;
             args.Player.SendErrorMessage("You do not have permission to place tiles over protected walls.");
             TSPlayer.All.SendTileSquare(args.X, args.Y, 1);
         }
         else if (blacklistedTiles.Contains(Main.tile[args.X, args.Y].type) && !args.Player.Group.HasPermission("invincibletile.placetile"))
         {
             args.Handled = true;
             args.Player.SendErrorMessage("You do not have permission to place tiles that are protected.");
             TSPlayer.All.SendTileSquare(args.X, args.Y, 1);
         }
     }
     else if (args.Action == GetDataHandlers.EditAction.PlaceWall)
     {
         if (blacklistedWalls.Contains(Main.tile[args.X, args.Y].wall) && !args.Player.Group.HasPermission("invincibletile.placewall"))
         {
             args.Handled = true;
             args.Player.SendErrorMessage("You do not have permission to place walls that are protected.");
             TSPlayer.All.SendTileSquare(args.X, args.Y, 1);
         }
     }
 }
예제 #14
0
        public override void Initialize()
        {
            if (!Directory.Exists(SavePath))
            {
                Directory.CreateDirectory(SavePath);
            }

#if DEBUG
            Log.Initialize(Path.Combine(SavePath, "log.txt"), LogLevel.All, false);
#else
            Log.Initialize(Path.Combine(SavePath, "log.txt"), LogLevel.All & ~LogLevel.Debug, false);
#endif
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;


            try
            {
                if (File.Exists(Path.Combine(SavePath, "tshock.pid")))
                {
                    Log.ConsoleInfo("TShock was improperly shut down. Deleting invalid pid file...");
                    File.Delete(Path.Combine(SavePath, "tshock.pid"));
                }
                File.WriteAllText(Path.Combine(SavePath, "tshock.pid"), Process.GetCurrentProcess().Id.ToString());

                ConfigFile.ConfigRead += OnConfigRead;
                FileTools.SetupConfig();

                HandleCommandLine(Environment.GetCommandLineArgs());

                if (Config.StorageType.ToLower() == "sqlite")
                {
                    string sql = Path.Combine(SavePath, "tshock.sqlite");
                    DB = new SqliteConnection(string.Format("uri=file://{0},Version=3", sql));
                }
                else if (Config.StorageType.ToLower() == "mysql")
                {
                    try
                    {
                        var hostport = Config.MySqlHost.Split(':');
                        DB = new MySqlConnection();
                        DB.ConnectionString =
                            String.Format("Server={0}; Port={1}; Database={2}; Uid={3}; Pwd={4};",
                                          hostport[0],
                                          hostport.Length > 1 ? hostport[1] : "3306",
                                          Config.MySqlDbName,
                                          Config.MySqlUsername,
                                          Config.MySqlPassword
                                          );
                    }
                    catch (MySqlException ex)
                    {
                        Log.Error(ex.ToString());
                        throw new Exception("MySql not setup correctly");
                    }
                }
                else
                {
                    throw new Exception("Invalid storage type");
                }

                Backups          = new BackupManager(Path.Combine(SavePath, "backups"));
                Backups.KeepFor  = Config.BackupKeepFor;
                Backups.Interval = Config.BackupInterval;
                Bans             = new BanManager(DB);
                Warps            = new WarpManager(DB);
                Users            = new UserManager(DB);
                Groups           = new GroupManager(DB);
                Groups.LoadPermisions();
                Regions         = new RegionManager(DB);
                Itembans        = new ItemManager(DB);
                RememberedPos   = new RemeberedPosManager(DB);
                RestApi         = new SecureRest(Netplay.serverListenIP, 8080);
                RestApi.Verify += RestApi_Verify;
                RestApi.Port    = Config.RestApiPort;
                RestManager     = new RestManager(RestApi);
                RestManager.RegisterRestfulCommands();

                var geoippath = Path.Combine(SavePath, "GeoIP.dat");
                if (Config.EnableGeoIP && File.Exists(geoippath))
                {
                    Geo = new MaxMind.GeoIPCountry(geoippath);
                }

                Log.ConsoleInfo(string.Format("TShock Version {0} ({1}) now running.", Version, VersionCodename));

                GameHooks.PostInitialize += OnPostInit;
                GameHooks.Update         += OnUpdate;
                ServerHooks.Join         += OnJoin;
                ServerHooks.Leave        += OnLeave;
                ServerHooks.Chat         += OnChat;
                ServerHooks.Command      += ServerHooks_OnCommand;
                NetHooks.GetData         += OnGetData;
                NetHooks.SendData        += NetHooks_SendData;
                NetHooks.GreetPlayer     += OnGreetPlayer;
                NpcHooks.StrikeNpc       += NpcHooks_OnStrikeNpc;

                GetDataHandlers.InitGetDataHandler();
                Commands.InitCommands();
                //RconHandler.StartThread();

                if (Config.BufferPackets)
                {
                    PacketBuffer = new PacketBufferer();
                }

                Log.ConsoleInfo("AutoSave " + (Config.AutoSave ? "Enabled" : "Disabled"));
                Log.ConsoleInfo("Backups " + (Backups.Interval > 0 ? "Enabled" : "Disabled"));

                if (Initialized != null)
                {
                    Initialized();
                }
            }
            catch (Exception ex)
            {
                Log.Error("Fatal Startup Exception");
                Log.Error(ex.ToString());
                Environment.Exit(1);
            }
        }
예제 #15
0
        private void TShock_PlayerSpawn(object sender, GetDataHandlers.SpawnEventArgs e)
        {
            if (this.isDisposed || !this.hooksEnabled || e.Handled)
            return;

              TSPlayer player = TShock.Players[e.Player];
              if (player == null || !player.IsLoggedIn)
            return;

              e.Handled = this.UserInteractionHandler.HandlePlayerSpawn(player, new DPoint(e.SpawnX, e.SpawnY));
        }
예제 #16
0
        private void HandleDeath( object sender, GetDataHandlers.KillMeEventArgs args )
        {
            if (args.Handled)
                return;

            byte PlayerID = args.PlayerId;
            byte hitDirection = args.Direction;
            Int16 Damage = args.Damage;
            bool PVP = args.Pvp;

            if( !deadplayers.ContainsKey(PlayerID) )
            {
                deadplayers.Add(PlayerID, TShock.Players[PlayerID].Team);
            }
            else
            {
                deadplayers.Remove(PlayerID);
                deadplayers.Add(PlayerID, TShock.Players[PlayerID].Team);
            }
        }
예제 #17
0
 private void OnPlayerUpdate(object sender, GetDataHandlers.PlayerUpdateEventArgs args)
 {
     TSPlayer tsplayer = TShock.Players[args.PlayerId];
     if (tsplayer == null)
         return;
     ATPlayer player = ATPlayers[args.PlayerId];
     if (player == null)
         return;
     // Console.WriteLine("Flags: {0}", flags);
     if ((args.Control & 32) == 32)
     {
         try
         {
             var BT = player.GetBindTool(Main.player[args.PlayerId].inventory[args.Item]);
             if (BT != null)
             {
                 BT.DoCommand(tsplayer);
             }
         }
         catch (Exception ex)
         {
             Log.ConsoleError(ex.ToString());
         }
         //Console.WriteLine("Player {0} used item: {1}", player.TSPlayer.Name, Main.player[plyID].inventory[item].name);
     }
 }
예제 #18
0
 private void OnTileEdit(object sender, GetDataHandlers.TileEditEventArgs args)
 {
     if (args.Action == GetDataHandlers.EditAction.PlaceWire)
     {
         if (storage.ContainsKey(args.Player.Index))
         {
             WireX = args.X;
             WireY = args.Y;
             WirePlace(args.Player.Index, WireX, WireY);
             args.Handled = true;
         }
     }
 }
예제 #19
0
 public void TileEdit(Object sender, GetDataHandlers.TileEditEventArgs args)
 {
     if ((args.EditType == 0 || args.EditType == 4) && new int[] { 3, 24, 32, 51, 52, 61, 62, 69, 71, 73, 74, 80, 82, 83, 84, 110, 113, 115, 138 }.Contains(Main.tile[args.X, args.Y].type))
     {
         try
         {
             foreach (Region reg in regionList)
             {
                 if (reg != null && reg.InArea(args.X, args.Y))
                 {
                     WorldGen.KillTile(args.X, args.Y);
                     TSPlayer.All.SendTileSquare(args.X, args.Y, 3);
                     args.Handled = true;
                     break;
                 }
             }
         }
         catch (Exception ex) { Log.ConsoleError(ex.ToString()); }
     }
 }