Exemple #1
0
        public override void Initialize()
        {
            //Get TPulse instance

            tPulse = (TPulse)PlugInHandler.GetPluginByType(typeof(TPulse));

            //Commands
            //  /join : to join a channel
            //  /channel : super-command
            //      add : add channel (need group < admin)
            //      del : delete a channel (need group < admin)
            //      list : listing
            //  /cmsg : send a message in the channel
            //can be null be aware !

            tPulse.Commands.ChatCommands.Add(new Command("", JoinCommand, "join"));
            tPulse.Commands.ChatCommands.Add(new Command("", LeaveCommand, "leave"));
            tPulse.Commands.ChatCommands.Add(new Command("", ChannelCommand, "channel"));
            tPulse.Commands.ChatCommands.Add(new Command("", ChannelMessage, "cmsg"));

            DefaultChannel = Manager.DefaultChannel;

            Channels.AddRange(Manager.ChatChannels);

            //Connection hooks

            tPulse.OnPlayerJoin += new PlayerConnectionHandler(PlayerJoinServer);
            tPulse.OnPlayerLeave += new PlayerConnectionHandler(PlayerLeaveServer);

            //World Saved Hooks

            tPulse.OnWorldSaved += new WorldSavedHandler(OnWorldSaved);
        }
Exemple #2
0
        public static void SetupConfig(TPulse tPulse)
        {
            if (!Directory.Exists(TPulse.SavePath))
            {
                Directory.CreateDirectory(TPulse.SavePath);
            }

            CreateIfNot(RulesPath, "Respect the admins!\nDon't use TNT!");
            CreateIfNot(MotdPath,
                        "This server is running TPulse for Terraria.\n Type /help for a list of commands.\n%255,000,000%Current map: %map%\nCurrent players: %players%");
            CreateIfNot(WhitelistPath);
            if (File.Exists(ConfigPath))
            {
                tPulse.Config = ConfigFile.Read(ConfigPath);
                // Add all the missing config properties in the json file
            }
            tPulse.Config.Write(ConfigPath);
        }
Exemple #3
0
 public static bool OnWhitelist(string ip, TPulse tPulse)
 {
     if (!tPulse.Config.EnableWhitelist)
     {
         return true;
     }
     CreateIfNot(WhitelistPath, "127.0.0.1");
     using (var tr = new StreamReader(WhitelistPath))
     {
         string whitelist = tr.ReadToEnd();
         ip = Utils.GetRealIP(ip);
         bool contains = whitelist.Contains(ip);
         if (!contains)
         {
             foreach (var line in whitelist.Split(Environment.NewLine.ToCharArray()))
             {
                 if (string.IsNullOrWhiteSpace(line))
                     continue;
                 contains = Utils.GetIPv4Address(line).Equals(ip);
                 if (contains)
                     return true;
             }
             return false;
         }
         return true;
     }
 }
Exemple #4
0
 public RestManager(Rest rest, TPulse tPulse)
 {
     Rest = rest;
     TPulse = tPulse;
 }
Exemple #5
0
        public static void InitGetDataHandler()
        {
            tPulse = (TPulse)PlugInHandler.GetPluginByType(typeof(TPulse));

            #region Blacklists

            WhitelistBuffMaxTime = new int[Main.maxBuffs];
            WhitelistBuffMaxTime[20] = 600;
            WhitelistBuffMaxTime[0x18] = 1200;
            WhitelistBuffMaxTime[0x1f] = 120;
            WhitelistBuffMaxTime[0x27] = 420;

            #endregion Blacklists

            GetDataHandlerDelegates = new Dictionary<PacketTypes, GetDataHandlerDelegate>
                                        {
                                            {PacketTypes.PlayerInfo, HandlePlayerInfo},
                                            {PacketTypes.PlayerUpdate, HandlePlayerUpdate},
                                            {PacketTypes.Tile, HandleTile},
                                            {PacketTypes.TileSendSquare, HandleSendTileSquare},
                                            {PacketTypes.ProjectileNew, HandleProjectileNew},
                                            {PacketTypes.TogglePvp, HandleTogglePvp},
                                            {PacketTypes.PlayerTeam, HandlePlayerTeam},
                                            {PacketTypes.TileKill, HandleTileKill},
                                            {PacketTypes.PlayerKillMe, HandlePlayerKillMe},
                                            {PacketTypes.LiquidSet, HandleLiquidSet},
                                            {PacketTypes.PlayerSpawn, HandleSpawn},
                                            {PacketTypes.ChestGetContents, HandleChestOpen},
                                            {PacketTypes.ChestItem, HandleChestItem},
                                            {PacketTypes.SignNew, HandleSign},
                                            {PacketTypes.PlayerSlot, HandlePlayerSlot},
                                            {PacketTypes.TileGetSection, HandleGetSection},
                                            {PacketTypes.UpdateNPCHome, UpdateNPCHome},
                                            {PacketTypes.PlayerAddBuff, HandlePlayerBuff},
                                            {PacketTypes.ItemDrop, HandleItemDrop},
                                            {PacketTypes.PlayerHp, HandlePlayerHp},
                                            {PacketTypes.PlayerMana, HandlePlayerMana},
                                            {PacketTypes.PlayerDamage, HandlePlayerDamage},
                                            {PacketTypes.NpcStrike, HandleNpcStrike},
                                            {PacketTypes.NpcSpecial, HandleSpecial},
                                            {PacketTypes.PlayerAnimation, HandlePlayerAnimation},
                                            {PacketTypes.PlayerBuff, HandlePlayerBuffUpdate},
                                            {PacketTypes.PasswordSend, HandlePassword},
                                            {PacketTypes.ContinueConnecting2, HandleConnecting},
                                            {PacketTypes.ProjectileDestroy, HandleProjectileKill},
                                            {PacketTypes.SpawnBossorInvasion, HandleSpawnBoss}
                                        };
        }
Exemple #6
0
        public override void Initialize()
        {
            tPulse = (TPulse)PlugInHandler.GetPluginByType(typeof(TPulse));
            Setting = ArenaSetting.Load(ArenaSettingFile);
            //todo

            //commands
            tPulse.Commands.ChatCommands.Add(new Command("", SetPrepare, "asetprepare"));
            tPulse.Commands.ChatCommands.Add(new Command("", SetTeamStart, "asetstart"));
            tPulse.Commands.ChatCommands.Add(new Command("", PreparePlayers, "aprepare"));
            tPulse.Commands.ChatCommands.Add(new Command("", AssignPlayerTeam, "aassign"));
            tPulse.Commands.ChatCommands.Add(new Command("", ResetTeams, "areset"));
            tPulse.Commands.ChatCommands.Add(new Command("", SetArenaHall, "asethall"));
            tPulse.Commands.ChatCommands.Add(new Command("", SetAterMatch, "asetroom"));

            Hooks.GameHooks.Update += new Action(GameHooks_Update);

            //Team Color
            //Console.WriteLine(Main.teamColor.Length);
            Main.teamColor[1] = Color.Blue;
            Main.teamColor[2] = Color.Pink;
        }
Exemple #7
0
 //put this into a logtools maybe ?
 public void SendLogs(string log, Color color, TPulse tPulse)
 {
     Log.Info(log);
     TPPlayer.Server.SendMessage(log, color);
     foreach (TPPlayer player in Players)
     {
         if (player != null && player.Active && player.Group.HasPermission(Permissions.logs) && player.DisplayLogs &&
             tPulse.Config.DisableSpewLogs == false)
             player.SendMessage(log, color);
     }
 }
Exemple #8
0
        static Permissions()
        {
            //getting the instance of TPulse

            tPulse = (TPulse)PlugInHandler.GetPluginByType(typeof(TPulse));

            foreach (var field in typeof (Permissions).GetFields())
            {
                field.SetValue(null, field.Name);
            }

            //Backwards compatability.
            restapi = "api";
        }
Exemple #9
0
 public Commands(TPulse tPulse)
 {
     this.tPulse = tPulse;
     ChatCommands = new List<Command>();
 }
Exemple #10
0
        public override void Initialize()
        {
            tPulse = (TPulse)PlugInHandler.GetPluginByType(typeof(TPulse));

            //Loading Friends DB
            if (File.Exists(FriendsDB.DefaultFile))
            {
                FriendsList = FriendsDB.Load(FriendsDB.DefaultFile);
            }
            else
            {
                FriendsList.Save(FriendsDB.DefaultFile);
            }

               //Adding commands

            tPulse.Commands.ChatCommands.Add(new Command("", FriendCommand, "friend"));
            tPulse.Commands.ChatCommands.Add(new Command("", MessageCommand, "fmsg"));
            tPulse.Commands.ChatCommands.Add(new Command("", MessageAllCommand, "fall"));
            //Commands.ChatCommands.Add(new Command("", MessageCommand, "sendcoord"));
            tPulse.Commands.OnPlayerLogin += new PlayerLoginHandler(PlayerLogin);
            //Hooks.WorldHooks.SaveWorld += new Hooks.WorldHooks.SaveWorldD(WorldHooks_SaveWorld);
            tPulse.OnWorldSaved += new WorldSavedHandler(OnWorldSaved);
        }