public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { ZoneCollectionSingletone coll = ZoneCollectionSingletone.GetInstance(); Zone zone = EasyGuess.GetMatchedZone(coll, arg1); if (zone != null) { GroupCollectionSingletone groups = GroupCollectionSingletone.GetInstance(); Group group = EasyGuess.GetMatchedGroup(groups, arg2); if (group != null) { if (ClientUser.LevelID >= group.Id && ClientUser.LevelID >= zone.LevelID) { zone.LevelID = group.Id; return(new CommandResult(true, String.Format("{0} has set zone's {1} group to {2}", TriggerPlayer, zone.Name, group.Name))); } else { return(new CommandResult(true, String.Format("Insufficient permissions to set the zone group"))); } } else { return(new CommandResult(true, String.Format("Group not found: {0}", arg2))); } } else { return(new CommandResult(true, String.Format("Zone not found: {0}", arg1))); } }
/// <summary> /// this is the execution method which gets executed later /// to get more arguments use the internal regArgs variable /// </summary> /// <param name="arg1">first argument after the command in the string</param> /// <param name="arg2">second argument after the command in the string</param> /// <param name="arg3">third argument after the command in the string</param> /// <param name="arg4">fourth argument after the command in the string</param> /// <returns>remember to set the command result in every return case</returns> public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { if (!String.IsNullOrEmpty(arg1)) { IMinecraftHandler mc = MinecraftHandler; String match = EasyGuess.GetMatchedString(mc.Player, arg1); if (!String.IsNullOrEmpty(match)) { UserCollectionSingletone userCollection = UserCollectionSingletone.GetInstance(); User matchedPlayer = userCollection.GetUserByName(match); if (matchedPlayer != null) { GroupCollectionSingletone groups = GroupCollectionSingletone.GetInstance(); Group group = EasyGuess.GetMatchedGroup(groups, arg2); if (group != null) { if (ClientUser.LevelID >= matchedPlayer.LevelID && ClientUser.LevelID >= group.Id) // checks if the triggered user has a higher group level { matchedPlayer.LevelID = group.Id; // sets the rank to the user :) if (matchedPlayer.Generated) { matchedPlayer.Name = match; if (!userCollection.IsInlist(match)) { userCollection.Add(matchedPlayer); userCollection.Save(); } } return(new CommandResult(true, string.Format("player {0} set to group {1}", matchedPlayer.Name, group.Name))); } else { return(new CommandResult(true, string.Format("group level is too low {0} ID:{1}", ClientUser.Level.Name, ClientUser.LevelID))); } } else { return(new CommandResult(true, string.Format("couldn't find group {0}", arg2))); // give as much informations as you can } } else { return(new CommandResult(true, string.Format("couldn't find the user {0}", match))); // give as much informations as you can } } else { return(new CommandResult(true, string.Format("couldn't find the user {0}", match))); // give as much informations as you can } } else { return(new CommandResult(true, string.Format("couldn't find player {0}", arg1))); } }
public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { GroupCollectionSingletone groups = GroupCollectionSingletone.GetInstance(); if (!String.IsNullOrEmpty(arg1)) { if (arg1[0] == '*') { if (arg1 == "*true") { foreach (Group g in groups) { if (ClientUser.Level != g) { g.AllowChat = false; } } return(new CommandResult(true, String.Format("Every group has been muted except {0}", ClientUser.Level.Name))); } if (arg1 == "*false") { foreach (Group g in groups) { if (ClientUser.Level != g) { g.AllowChat = true; } } return(new CommandResult(true, String.Format("Every group has been unmuted except {0}", ClientUser.Level.Name))); } } else { Group g = EasyGuess.GetMatchedGroup(groups, arg1); if (g != null) { g.AllowChat = !g.AllowChat; if (g.AllowChat) { groups.Save(); return(new CommandResult(true, String.Format("Group {0} has been unmuted", g.Name))); } else { groups.Save(); return(new CommandResult(true, String.Format("Group {0} has been muted", g.Name))); } } } } return(new CommandResult(true, String.Format("Group {0} not found", arg1))); }
private void GenerateColumns() { DataGridViewColumn col = new DataGridViewTextBoxColumn(); col.HeaderText = "User Name"; col.DataPropertyName = "Name"; dgvUsers.Columns.Add(col); GroupCollectionSingletone levels = GroupCollectionSingletone.GetInstance(); comboBoxLevel.DataSource = null; comboBoxLevel.DataSource = levels.Items; DataGridViewComboBoxColumn combo = new DataGridViewComboBoxColumn(); combo.HeaderText = "Group"; combo.DataPropertyName = "Level"; combo.ValueMember = "Name"; combo.DisplayMember = "Name"; combo.DataSource = levels.Items; dgvUsers.Columns.Add(combo); col = new DataGridViewTextBoxColumn(); col.HeaderText = "Balance"; col.DataPropertyName = "Balance"; dgvUsers.Columns.Add(col); col = new DataGridViewCheckBoxColumn(); col.HeaderText = "Allow Chat"; col.DataPropertyName = "AllowChat"; dgvUsers.Columns.Add(col); //col = new DataGridViewTextBoxColumn(); //col.HeaderText = "Remote Login"; //col.DataPropertyName = "Login"; //dgvUsers.Columns.Add(col); //DataGridViewTextBoxColumn passwordColumn = new DataGridViewTextBoxColumn(); //passwordColumn.HeaderText = "Remote Password"; //passwordColumn.DataPropertyName = "PasswordHash"; //dgvUsers.Columns.Add(passwordColumn); col = new DataGridViewCheckBoxColumn(); col.HeaderText = "Has Web Access"; col.DataPropertyName = "HasWebAccess"; dgvUsers.Columns.Add(col); }
/// <summary> /// this is the execution method which gets executed later /// to get more arguments use the internal regArgs variable /// </summary> /// <param name="arg1">first argument after the command in the string</param> /// <param name="arg2">second argument after the command in the string</param> /// <param name="arg3">third argument after the command in the string</param> /// <param name="arg4">fourth argument after the command in the string</param> /// <returns>remember to set the command result in every return case</returns> public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { var mc = MinecraftHandler; GroupCollectionSingletone groups = GroupCollectionSingletone.GetInstance(); StringBuilder builder = new StringBuilder(); List <String> lines = new List <string>(); builder.AppendFormat("Groups: {0} ", groups.Items.Count); if (groups.Items.Count > 0) { for (int i = 0; i < groups.Items.Count; i++) { Group g = groups.Items[i]; if (builder.Length + g.Name.Length + mc.Config.ResponsePrefix.Length < 70) { builder.AppendFormat("§f<§{0}{1}§f> ", g.GroupColor, g.Name); } else { lines.Add(builder.ToString()); builder = new StringBuilder(); i--; } } } if (builder.Length + mc.Config.ResponsePrefix.Length <= 70) { lines.Add(builder.ToString()); } //MinecraftHandler.ExecuteSay(result); foreach (String line in lines) { Server.SendExecuteResponse(TriggerPlayer, line); } return(new CommandResult(true, string.Format("{0} executed by {1}", Name, TriggerPlayer))); }
private void GenerateColumns(bool expert) { dgvZones.Columns.Clear(); DataGridViewColumn col = new DataGridViewTextBoxColumn(); col.HeaderText = "Zone Name"; col.DataPropertyName = "Name"; dgvZones.Columns.Add(col); col = new DataGridViewTextBoxColumn(); col.HeaderText = "Welcome"; col.DataPropertyName = "WelcomeMessage"; dgvZones.Columns.Add(col); col = new DataGridViewTextBoxColumn(); col.HeaderText = "Description"; col.DataPropertyName = "Description"; dgvZones.Columns.Add(col); col = new DataGridViewTextBoxColumn(); col.HeaderText = "Block Level"; col.DataPropertyName = "BlockLevel"; dgvZones.Columns.Add(col); col = new DataGridViewTextBoxColumn(); col.HeaderText = "Owner"; col.DataPropertyName = "Owner"; dgvZones.Columns.Add(col); col = new DataGridViewCheckBoxColumn(); col.HeaderText = "Fix permissions to group"; col.DataPropertyName = "FixToGroup"; dgvZones.Columns.Add(col); col = new DataGridViewCheckBoxColumn(); col.HeaderText = "Allow destroy"; col.DataPropertyName = "AllowDestroy"; dgvZones.Columns.Add(col); col = new DataGridViewCheckBoxColumn(); col.HeaderText = "Allow Build"; col.DataPropertyName = "AllowBuild"; dgvZones.Columns.Add(col); GroupCollectionSingletone levels = GroupCollectionSingletone.GetInstance(); comboBoxLevel.DataSource = null; comboBoxLevel.DataSource = levels.Items; DataGridViewComboBoxColumn combo = new DataGridViewComboBoxColumn(); combo.HeaderText = "Group"; combo.DataPropertyName = "Level"; combo.ValueMember = "Name"; combo.DisplayMember = "Name"; combo.DataSource = levels.Items; dgvZones.Columns.Add(combo); if (expert) { col = new DataGridViewTextBoxColumn(); col.HeaderText = "X1"; col.DataPropertyName = "X1"; dgvZones.Columns.Add(col); col = new DataGridViewTextBoxColumn(); col.HeaderText = "Y1"; col.DataPropertyName = "Y1"; dgvZones.Columns.Add(col); col = new DataGridViewTextBoxColumn(); col.HeaderText = "Z1"; col.DataPropertyName = "Z1"; dgvZones.Columns.Add(col); col = new DataGridViewTextBoxColumn(); col.HeaderText = "X2"; col.DataPropertyName = "X2"; dgvZones.Columns.Add(col); col = new DataGridViewTextBoxColumn(); col.HeaderText = "Y2"; col.DataPropertyName = "Y2"; dgvZones.Columns.Add(col); col = new DataGridViewTextBoxColumn(); col.HeaderText = "Z2"; col.DataPropertyName = "Z2"; dgvZones.Columns.Add(col); } }