Ejemplo n.º 1
0
        public queryQueue()
        {
            string pluginFolder = Statics.PluginPath + Path.DirectorySeparatorChar + "mysql";
            MysqlPlugin.CreateDirectory (pluginFolder);

            properties = new PropertiesFile (pluginFolder + Path.DirectorySeparatorChar + "mysql.properties");
            properties.Load ();
            var dummy2 = mysqlserver;
            var dummy3 = mysqldatabase;
            var dummy4 = mysqluser;
            var dummy5 = mysqlpassword;
            properties.Save ();
            queue = new Queue<string> (1000);
            dbcon = new MySqlConnection (connectionString);
        }
Ejemplo n.º 2
0
        protected override void Initialized(object state)
        {
            if (!Directory.Exists(RegionsFolder))
                Directory.CreateDirectory(RegionsFolder);

            rProperties = new Properties(RegionsFolder + Path.DirectorySeparatorChar + "regions.properties");
            rProperties.Load();

            rProperties.AddHeaderLine("Use 'rectify=false' to ignore world alterations from");
            rProperties.AddHeaderLine("players who are blocked; Possibly saving bandwidth.");

            rProperties.pushData();
            rProperties.Save(false);

            if (rProperties.RectifyChanges)
                WorldAlter = HookResult.RECTIFY;

            SelectorItem = rProperties.SelectionToolID;
            #region set up mysql properties

            string pluginFolder = Statics.PluginPath + Path.DirectorySeparatorChar + "mysql";
            if (!Directory.Exists(pluginFolder))
            {
                Directory.CreateDirectory(pluginFolder);
            }

            mysql = new PropertiesFile(pluginFolder + Path.DirectorySeparatorChar + "mysql.properties");
            mysql.Load();
            var dummy1 = mysqlenabled;
            var dummy2 = mysqlserver;
            var dummy3 = mysqldatabase;
            var dummy4 = mysqluser;
            var dummy5 = mysqlpassword;
            var dummy6 = imported;
            mysql.Save(false);

            #endregion

            #region check if mysql table exists
            if (mysqlenabled)
            {
                try
                {
                    checkTable(connectionString, "terraria_regions");
                }
                catch (MySqlException e)
                {
                    if (e.Number == 1042)
                    {
                        ProgramLog.Error.Log("[Regions] Could not connect to mysql server. Falling back to using regions files");
                        mysql.setValue("mysql-enabled", "False");
                        mysql.Save();
                    }
                    else
                    {
                        ProgramLog.Error.Log("[Regions] MYSQL ERROR CODE: " + e.Number);
                        ProgramLog.Error.Log(e.StackTrace);
                    }
                }
            }
            #endregion

            regionManager = new RegionManager(DataFolder);
            selection = new Selection();

            commands = new Commands();
            commands.regionManager = regionManager;
            commands.RegionsPlugin = this;
            commands.selection = selection;

            commands.Node_Create        = Node.FromPath("region.create");
            commands.Node_Here          = Node.FromPath("region.here");
            commands.Node_List          = Node.FromPath("region.list");
            commands.Node_Npcres        = Node.FromPath("region.npcres");
            commands.Node_Opres         = Node.FromPath("region.opres");
            commands.Node_Projectile    = Node.FromPath("region.projectile");
            commands.Node_ProtectAll    = Node.FromPath("region.protectall");
            commands.Node_Select        = Node.FromPath("region.select");
            commands.Node_User          = Node.FromPath("region.user");

            AddCommand("region")
                .WithAccessLevel(AccessLevel.OP)
                .WithHelpText("Usage:    region [select, create, user, list, npcres, opres]")
                .WithDescription("Region Management.")
                .WithPermissionNode("regions")
                .Calls(commands.Region);

            AddCommand("regions")
                .WithAccessLevel(AccessLevel.OP)
                .WithHelpText("Usage:    regions [select, create, user, list, npcres, opres]")
                .WithDescription("Region Management.")
                .WithPermissionNode("regions") //Need another method to split the commands up.
                .Calls(commands.Region);

            ChestBreak      = AddAndCreateNode("region.chestbreak");
            ChestOpen       = AddAndCreateNode("region.chestopen");
            DoorChange      = AddAndCreateNode("region.doorchange");
            LiquidFlow      = AddAndCreateNode("region.liquidflow");
            ProjectileUse   = AddAndCreateNode("region.projectileuse");
            SignEdit        = AddAndCreateNode("region.signedit");
            TileBreak       = AddAndCreateNode("region.tilebreak");
            TilePlace       = AddAndCreateNode("region.tileplace");
        }
        public static void Start(string dbPath)
        {
            LoginDatabase = new PropertiesFile (dbPath);
            LoginDatabase.Load ();

            if (LoginDatabase.Count == 0)
            {
                var bytes = new byte [8];
                (new Random ((int) DateTime.Now.Ticks)).NextBytes (bytes);

                string password = String.Format ("{0:x2}{1:x2}-{2:x2}{3:x2}-{4:x2}{5:x2}-{6:x2}{7:x2}",
                    bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7]);
                string login = "******";
                ProgramLog.Admin.Log ("The rcon login database was empty, a new user \"{1}\" has been created with password: {0}", password, login);

                LoginDatabase.setValue (login, Hash (login, password));
            }

            LoginDatabase.Save ();

            var bind = Program.properties.RConBindAddress;
            var split = bind.Split(':');
            IPAddress addr;
            ushort port;

            if (split.Length != 2 || !IPAddress.TryParse (split[0], out addr) || !ushort.TryParse (split[1], out port) || port < 1)
            {
                ProgramLog.Error.Log ("{0} is not a valid bind address, remote console disabled.", bind);
                return;
            }

            listener = new TcpListener (addr, port);

            try
            {
                listener.Start();
            }
            catch (Exception)
            {
                ProgramLog.Error.Log ("Failed to bind to address {0}, remote console disabled.", bind);
                //ProgramLog.Log (exception, "Failed to bind to address 127.0.0.1:" + 7776);
                return;
            }

            thread = new ProgramThread ("RCon", RConLoop);
            thread.Start ();
        }
Ejemplo n.º 4
0
        protected override void Initialized(object state)
        {
            string pluginFolder = Statics.PluginPath + Path.DirectorySeparatorChar + "mysql";
            CreateDirectory (pluginFolder);

            properties = new PropertiesFile (pluginFolder + Path.DirectorySeparatorChar + "mysql.properties");
            properties.Load ();
            var dummy1 = mysqlenabled;
            var dummy2 = mysqlserver;
            var dummy3 = mysqldatabase;
            var dummy4 = mysqluser;
            var dummy5 = mysqlpassword;
            var dummy8 = logtiles;
            var dummy9 = logplayers;
            var dummy10 = logliquid;
            var dummy11 = logplants;
            properties.Save ();
            if (mysqlenabled) {
                try
                {
                    checkTable("terraria");
                    checkTable("terraria_tiles");
                    checkTable("terraria_iplog");
                    if (!logtiles)
                    {
                        ProgramLog.Error.Log("[Mysql] logtiles is disabled. Edit mysql.properties to enable");
                    }
                }
                catch (MySqlException e)
                {
                    if (e.Number == 1042)
                    {
                        ProgramLog.Error.Log("[Mysql] Could not connect to mysql server. Setting mysql-enabled to false.");
                        properties.setValue("mysql-enabled", "False");
                        properties.Save();
                    }
                    else
                    {
                        ProgramLog.Error.Log("[Mysql] MYSQL ERROR CODE: " + e.Number);
                        ProgramLog.Error.Log(e.StackTrace);
                    }
                }
            } else {
                ProgramLog.Error.Log ("[Mysql] connection not enabled. Please edit mysql.properties");
            }

            AddCommand ("mysql")
                .WithDescription ("MySQL settings")
                .WithAccessLevel (AccessLevel.OP)
                .WithHelpText ("To reload settings from mysql.properties:")
                .WithHelpText ("mysql -L")
                .Calls (this.OptionsCommand);

            AddCommand ("blockinfo")
                .WithDescription ("retrieves block history of blocks you touch")
                .WithAccessLevel (AccessLevel.OP)
                .WithHelpText ("each time you use the command it toggles true/false")
                .Calls (this.LocationCommand);

            AddCommand ("lastseen")
                .WithDescription ("find when someone was on last")
                .WithAccessLevel (AccessLevel.PLAYER) //everyone can use this command
                .WithHelpText ("To use:")
                .WithHelpText ("lastseen \"playername\"")
                .Calls (this.LastSeenCommand);

            //TODO: fix THIS
            //AddCommand ("rollback")
            //	.WithDescription ("revert the world's changes in the specified amount of minutes")
            //   .WithAccessLevel(AccessLevel.OP)
            //	.WithHelpText (" eg. /rollback 5 ")
            //	.Calls (this.RollbackCommand);

            // these two are not released in this version

            //AddCommand ("undo")
            //	.WithDescription ("undo a players actions")
            //	.WithHelpText (" eg. /undo \"crazy griefer\" ")
            //	.Calls (this.UndoCommand);

            //AddCommand ("redo")
            //	.WithDescription ("redoes a players actions")
            //	.WithHelpText (" eg. /redo \"builders name\" ")
            //	.Calls (this.RedoCommand);
        }
Ejemplo n.º 5
0
        protected override void Initialized(object state)
        {
            string pluginFolder = Statics.PluginPath + Path.DirectorySeparatorChar + "android";

            if (!Directory.Exists(pluginFolder))
            {
                Directory.CreateDirectory(pluginFolder);
            }

            properties = new PropertiesFile(pluginFolder + Path.DirectorySeparatorChar + "android.properties");
            properties.Load();
            var dummy = username;
            var dummy2 = password;
            var dummy3 = port;
            properties.Save();

            instance = this;
            base.Initialized(state);
        }
Ejemplo n.º 6
0
        protected override void Initialized(object state)
        {
            string pluginFolder = Statics.PluginPath + Path.DirectorySeparatorChar + "Announce";
            if (!Directory.Exists(pluginFolder))
                Directory.CreateDirectory(pluginFolder);

            properties = new PropertiesFile(pluginFolder + Path.DirectorySeparatorChar + "announce.properties");
            properties.Load();
            properties.Save(false);

            AddCommand("aa")
                .WithDescription("Add announcement")
                .WithAccessLevel(AccessLevel.OP)
                .WithHelpText("adds announcements to the file")
                .WithHelpText("set a custom color with \"|R|G|B\" at the end (0-255)")
                .Calls(this.AnnounceCommand);
        }
Ejemplo n.º 7
0
        protected override void Initialized(object state)
        {
            string pluginFolder = Statics.PluginPath + Path.DirectorySeparatorChar + "webchat";
            CreateDirectory(pluginFolder);

            properties = new PropertiesFile (pluginFolder + Path.DirectorySeparatorChar + "mysql.properties");
            properties.Load();
            var dummy1 = mysqlenabled;
            var dummy2 = mysqlserver;
            var dummy3 = mysqldatabase;
            var dummy4 = mysqluser;
            var dummy5 = mysqlpassword;
            var dummy9 = mysqlserver2;
            var dummy10 = mysqldatabase2;
            var dummy11 = mysqluser2;
            var dummy12 = mysqlpassword2;
            var dummy6 = pcpinprefix;
            var dummy7 = web2chat;
            var dummy8 = addhours;
            properties.Save();

            if (mysqlenabled)
            {
                checkTable(mysqlserver2, mysqldatabase2, mysqluser2, mysqlpassword2, pcpinprefix+"user");
                checkTable(mysqlserver2, mysqldatabase2, mysqluser2, mysqlpassword2, "terraria_chatqueue");
            }
            else
            {
            ProgramLog.Log("[webchat] mysql connection not enabled. Please edit mysql.properties");
            }

            AddCommand ("webchat")
                .WithDescription ("WebChat Configuration")
                .WithHelpText ("To reload settings from mysql.properties:")
                .WithHelpText ("webchat -L")
                .Calls (this.OptionsCommand);
        }
Ejemplo n.º 8
0
        protected override void Initialized(object state)
        {
            string pluginFolder = Statics.PluginPath + Path.DirectorySeparatorChar + "map";
            CreateDirectory (pluginFolder);

            properties = new PropertiesFile (pluginFolder + Path.DirectorySeparatorChar + "map.properties");
            properties.Load ();
            var dummy = mapoutputpath;
            var dummy2 = colorscheme;
            var dummy3 = autosavepath;
            var dummy4 = autosaveinterval;
            var dummy5 = autosavetimestamp;
            var dummy6 = autosavehighlight;
            var dummy7 = autosavehightlightID;
            var dummy8 = autosaveenabled;
            var dummy9 = autosavename;
            properties.Save ();

            if(colorscheme=="MoreTerra" || colorscheme=="Terrafirma"){
                isEnabled = true;
            }
            else{
                ProgramLog.Error.Log ("<map> ERROR: colorscheme must be either 'MoreTerra' or 'Terrafirma'");
                ProgramLog.Error.Log ("<map> ERROR: map command will not work until you change it");
                isEnabled = false;
            }

            AddCommand ("map")
                .WithDescription ("map options")
                .WithAccessLevel(AccessLevel.OP)
                .WithHelpText ("map help")
                .WithHelpText ("map -t")
                .WithHelpText ("map -n outputname.png")
                .WithHelpText ("map -L")
                .WithHelpText ("map [-s] -p /path/to/output")
                .WithHelpText ("map [-s] -p \"C:\\path\\to\\output\"")
                .WithHelpText ("map [-s] -c MoreTerra")
                .WithHelpText ("map [-s] -c Terrafirma")
                .WithHelpText ("map -h \"name or ID of item to highlight\"")
                .Calls (this.MapCommand);
        }