DBEditor will add permissions from the Table already, plugins can insert their own Permissions now

This commit is contained in:
Twitchy 2011-07-29 22:29:17 +12:00
parent b291e25f94
commit 7dea80bb2f
4 changed files with 43 additions and 12 deletions

View file

@ -5,21 +5,23 @@ using System.Text;
namespace TShockDBEditor namespace TShockDBEditor
{ {
public class Commandlist public class TShockCommandsList
{ {
public static List<string> CommandList = new List<string>(); public static void AddRemainingTShockCommands()
public static void AddCommands()
{ {
List<string> CommandList = new List<string>();
CommandList.Add("reservedslot"); CommandList.Add("reservedslot");
CommandList.Add("canwater"); CommandList.Add("canwater");
CommandList.Add("canlava"); CommandList.Add("canlava");
CommandList.Add("canbuild");
CommandList.Add("adminchat");
CommandList.Add("warp"); CommandList.Add("warp");
CommandList.Add("kick"); CommandList.Add("kick");
CommandList.Add("ban"); CommandList.Add("ban");
CommandList.Add("unban"); CommandList.Add("unban");
CommandList.Add("whitelist"); CommandList.Add("whitelist");
CommandList.Add("maintenace"); CommandList.Add("maintenance");
CommandList.Add("causeevents"); CommandList.Add("causeevents");
CommandList.Add("spawnboss"); CommandList.Add("spawnboss");
CommandList.Add("spawnmob"); CommandList.Add("spawnmob");
@ -42,6 +44,12 @@ namespace TShockDBEditor
CommandList.Add("ignorecheatdetection"); CommandList.Add("ignorecheatdetection");
CommandList.Add("ignoregriefdetection"); CommandList.Add("ignoregriefdetection");
CommandList.Add("usebanneditem"); CommandList.Add("usebanneditem");
foreach (string command in CommandList)
{
if (!TShockDBEditor.CommandList.Contains(command))
TShockDBEditor.CommandList.Add(command);
}
} }
} }
} }

View file

@ -18,6 +18,7 @@ namespace TShockDBEditor
{ {
public OpenFileDialog dialog = new OpenFileDialog(); public OpenFileDialog dialog = new OpenFileDialog();
public List<Group> groups = new List<Group>(); public List<Group> groups = new List<Group>();
public static List<string> CommandList = new List<string>();
public IDbConnection DB; public IDbConnection DB;
public string dbtype = ""; public string dbtype = "";
@ -25,7 +26,6 @@ namespace TShockDBEditor
{ {
InitializeComponent(); InitializeComponent();
Itemlist.AddItems(); Itemlist.AddItems();
Commandlist.AddCommands();
dialog.FileOk += new CancelEventHandler(dialog_FileOk); dialog.FileOk += new CancelEventHandler(dialog_FileOk);
dialog.Filter = "SQLite Database (*.sqlite)|*.sqlite"; dialog.Filter = "SQLite Database (*.sqlite)|*.sqlite";
} }
@ -50,6 +50,7 @@ namespace TShockDBEditor
itemListBanned.Items.Add(reader.Get<string>("ItemName")); itemListBanned.Items.Add(reader.Get<string>("ItemName"));
} }
} }
using (var com = DB.CreateCommand()) using (var com = DB.CreateCommand())
{ {
com.CommandText = com.CommandText =
@ -68,6 +69,21 @@ namespace TShockDBEditor
lst_newusergrplist.Items.Add(reader.Get<string>("GroupName")); lst_newusergrplist.Items.Add(reader.Get<string>("GroupName"));
} }
} }
using (var reader = com.ExecuteReader())
{
while (reader.Read())
{
foreach (string command in reader.Get<string>("Commands").Split(','))
{
if (!lst_groupList.Items.Contains(command))
if (!CommandList.Contains(command))
CommandList.Add(command);
}
}
}
TShockCommandsList.AddRemainingTShockCommands();
} }
using (var com = DB.CreateCommand()) using (var com = DB.CreateCommand())
{ {
@ -203,7 +219,10 @@ namespace TShockDBEditor
private void lst_groupList_SelectedIndexChanged(object sender, EventArgs e) 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) private void UpdateGroupIndex(int index)
@ -238,10 +257,10 @@ namespace TShockDBEditor
if (lbl_grpchild.Text == "") if (lbl_grpchild.Text == "")
lbl_grpchild.Text = "none"; 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])) if (!lst_AvailableCmds.Items.Contains(CommandList[i]))
lst_bannedCmds.Items.Add(Commandlist.CommandList[i]); lst_bannedCmds.Items.Add(CommandList[i]);
} }
} }
} }
@ -535,6 +554,8 @@ namespace TShockDBEditor
#endregion #endregion
#region UserTab
private void lst_userlist_SelectedIndexChanged(object sender, EventArgs e) private void lst_userlist_SelectedIndexChanged(object sender, EventArgs e)
{ {
txt_username.Text = "None Selected"; txt_username.Text = "None Selected";
@ -729,6 +750,8 @@ namespace TShockDBEditor
} }
} }
#endregion
private void TShockDBEditor_Load(object sender, EventArgs e) private void TShockDBEditor_Load(object sender, EventArgs e)
{ {

View file

@ -74,8 +74,8 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Group.cs" />
<Compile Include="CommandList.cs" /> <Compile Include="CommandList.cs" />
<Compile Include="Group.cs" />
<Compile Include="DbExt.cs" /> <Compile Include="DbExt.cs" />
<Compile Include="Main.cs"> <Compile Include="Main.cs">
<SubType>Form</SubType> <SubType>Form</SubType>

View file

@ -171,7 +171,7 @@
</PropertyGroup> </PropertyGroup>
<ProjectExtensions> <ProjectExtensions>
<VisualStudio> <VisualStudio>
<UserProperties BuildVersion_IncrementBeforeBuild="False" BuildVersion_StartDate="2011/6/17" BuildVersion_BuildVersioningStyle="None.None.None.MonthAndDayStamp" BuildVersion_BuildAction="Both" BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" /> <UserProperties BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" BuildVersion_BuildAction="Both" BuildVersion_BuildVersioningStyle="None.None.None.MonthAndDayStamp" BuildVersion_StartDate="2011/6/17" BuildVersion_IncrementBeforeBuild="False" />
</VisualStudio> </VisualStudio>
</ProjectExtensions> </ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.