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)));
            }
        }
Exemple #2
0
 /// <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)));
        }