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"); }
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; 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"); }
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(); if (rProperties.RectifyChanges) WorldAlter = HookResult.RECTIFY; SelectorItem = rProperties.SelectionToolID; regionManager = new RegionManager(DataFolder); selection = new Selection(); commands = new Commands(); commands.regionManager = regionManager; commands.RegionsPlugin = this; commands.selection = selection; 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); Hook(HookPoints.PlayerWorldAlteration, OnPlayerWorldAlteration); Hook(HookPoints.LiquidFlowReceived, OnLiquidFlowReceived); Hook(HookPoints.ProjectileReceived, OnProjectileReceived); Hook(HookPoints.PlayerEnteredGame, OnPlayerEnteredGame); Hook(HookPoints.ServerStateChange, OnServerStateChange); Hook(HookPoints.DoorStateChanged, OnDoorStateChange); Hook(HookPoints.ChestBreakReceived, OnChestBreak); Hook(HookPoints.SignTextSet, OnSignEdit); UsingPermissions = isRunningPermissions(); if (UsingPermissions) Log("Using Permissions."); else Log("No Permissions Found\nUsing Internal User System"); }