diff --git a/DBEditor/CommandList.cs b/DBEditor/CommandList.cs index eb3f2af9..93ed1064 100644 --- a/DBEditor/CommandList.cs +++ b/DBEditor/CommandList.cs @@ -5,21 +5,23 @@ using System.Text; namespace TShockDBEditor { - public class Commandlist + public class TShockCommandsList { - public static List CommandList = new List(); - - public static void AddCommands() + public static void AddRemainingTShockCommands() { + List CommandList = new List(); + CommandList.Add("reservedslot"); CommandList.Add("canwater"); CommandList.Add("canlava"); + CommandList.Add("canbuild"); + CommandList.Add("adminchat"); CommandList.Add("warp"); CommandList.Add("kick"); CommandList.Add("ban"); CommandList.Add("unban"); CommandList.Add("whitelist"); - CommandList.Add("maintenace"); + CommandList.Add("maintenance"); CommandList.Add("causeevents"); CommandList.Add("spawnboss"); CommandList.Add("spawnmob"); @@ -42,6 +44,12 @@ namespace TShockDBEditor CommandList.Add("ignorecheatdetection"); CommandList.Add("ignoregriefdetection"); CommandList.Add("usebanneditem"); + + foreach (string command in CommandList) + { + if (!TShockDBEditor.CommandList.Contains(command)) + TShockDBEditor.CommandList.Add(command); + } } } } diff --git a/DBEditor/Main.cs b/DBEditor/Main.cs index 343f77ac..d5a98e2c 100644 --- a/DBEditor/Main.cs +++ b/DBEditor/Main.cs @@ -18,6 +18,7 @@ namespace TShockDBEditor { public OpenFileDialog dialog = new OpenFileDialog(); public List groups = new List(); + public static List CommandList = new List(); public IDbConnection DB; public string dbtype = ""; @@ -25,7 +26,6 @@ namespace TShockDBEditor { InitializeComponent(); Itemlist.AddItems(); - Commandlist.AddCommands(); dialog.FileOk += new CancelEventHandler(dialog_FileOk); dialog.Filter = "SQLite Database (*.sqlite)|*.sqlite"; } @@ -50,6 +50,7 @@ namespace TShockDBEditor itemListBanned.Items.Add(reader.Get("ItemName")); } } + using (var com = DB.CreateCommand()) { com.CommandText = @@ -68,6 +69,21 @@ namespace TShockDBEditor lst_newusergrplist.Items.Add(reader.Get("GroupName")); } } + + using (var reader = com.ExecuteReader()) + { + while (reader.Read()) + { + foreach (string command in reader.Get("Commands").Split(',')) + { + if (!lst_groupList.Items.Contains(command)) + if (!CommandList.Contains(command)) + CommandList.Add(command); + } + } + } + + TShockCommandsList.AddRemainingTShockCommands(); } using (var com = DB.CreateCommand()) { @@ -203,7 +219,10 @@ namespace TShockDBEditor private void lst_groupList_SelectedIndexChanged(object sender, EventArgs e) { - UpdateGroupIndex(lst_groupList.SelectedIndex); + if ((string)lst_groupList.SelectedItem != "superadmin") + UpdateGroupIndex(lst_groupList.SelectedIndex); + else + lst_groupList.SelectedIndex = -1; } private void UpdateGroupIndex(int index) @@ -238,10 +257,10 @@ namespace TShockDBEditor if (lbl_grpchild.Text == "") lbl_grpchild.Text = "none"; - for (int i = 0; i < Commandlist.CommandList.Count; i++) + for (int i = 0; i < CommandList.Count; i++) { - if (!lst_AvailableCmds.Items.Contains(Commandlist.CommandList[i])) - lst_bannedCmds.Items.Add(Commandlist.CommandList[i]); + if (!lst_AvailableCmds.Items.Contains(CommandList[i])) + lst_bannedCmds.Items.Add(CommandList[i]); } } } @@ -535,6 +554,8 @@ namespace TShockDBEditor #endregion + #region UserTab + private void lst_userlist_SelectedIndexChanged(object sender, EventArgs e) { txt_username.Text = "None Selected"; @@ -729,6 +750,8 @@ namespace TShockDBEditor } } + #endregion + private void TShockDBEditor_Load(object sender, EventArgs e) { diff --git a/DBEditor/TShockDBEditor.csproj b/DBEditor/TShockDBEditor.csproj index 7cdc2c2c..3d95e73b 100644 --- a/DBEditor/TShockDBEditor.csproj +++ b/DBEditor/TShockDBEditor.csproj @@ -74,8 +74,8 @@ - + Form diff --git a/TShockAPI/TShockAPI.csproj b/TShockAPI/TShockAPI.csproj index 3f1f90d7..946f10bf 100644 --- a/TShockAPI/TShockAPI.csproj +++ b/TShockAPI/TShockAPI.csproj @@ -171,7 +171,7 @@ - +