Пример #1
0
        public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4)
        {
            try
            {
                ZoneCollectionSingletone coll = ZoneCollectionSingletone.GetInstance();

                Zone zone = EasyGuess.GetMatchedZone(coll, arg1);
                if (zone != null)
                {
                    if (ClientUser.LevelID > zone.LevelID || TriggerPlayer == zone.Owner)
                    {
                        String name = zone.Name;
                        coll.Items.Remove(zone);
                        coll.Save();
                        return(new CommandResult(true, String.Format("Zone {0} removed by {1}", name, TriggerPlayer)));
                    }
                    else
                    {
                        return(new CommandResult(true, String.Format("Insufficient permissions to delete a zone")));
                    }
                }
                else
                {
                    return(new CommandResult(true, String.Format("Zone not found: {0}", arg1)));
                }
            }
            catch
            {
                return(new CommandResult(true, String.Format("Zone not found: {0}", arg1)));
            }
        }
Пример #2
0
        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)
            {
                if (!String.IsNullOrEmpty(arg1))
                {
                    if (TriggerPlayer == ClientUser.Name || ClientUser.LevelID > zone.LevelID)
                    {
                        String message = RegArg.Substring(arg1.Length).Trim();
                        zone.WelcomeMessage = message;
                        coll.Save();
                        return(new CommandResult(true, String.Format("Zone-Message of zone {0} is now {1}", zone.Name, message)));
                    }
                    else
                    {
                        return(new CommandResult(true, String.Format("Insufficient permissions to set the message")));
                    }
                }
                else
                {
                    return(new CommandResult(true, String.Format("Zone-Message is empty")));
                }
            }
            else
            {
                return(new CommandResult(true, String.Format("Zone not found: {0}", arg1)));
            }
        }
Пример #3
0
        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)
            {
                String match = EasyGuess.GetMatchedString(MinecraftHandler.Player, arg2);
                if (!String.IsNullOrEmpty(match))
                {
                    if (TriggerPlayer == ClientUser.Name || ClientUser.LevelID > zone.LevelID)
                    {
                        zone.Owner = match;
                        coll.Save();
                        return(new CommandResult(true, String.Format("Zone-Owner of zone {0} is now {1}", zone.Name, match)));
                    }
                    else
                    {
                        return(new CommandResult(true, String.Format("Insufficient permissions to set the owner")));
                    }
                }
                else
                {
                    return(new CommandResult(true, String.Format("User not found {0}", match)));
                }
            }
            else
            {
                return(new CommandResult(true, String.Format("Zone not found: {0}", arg1)));
            }
        }
Пример #4
0
        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)));
            }
        }
Пример #5
0
        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)
            {
                StringBuilder builder = new StringBuilder();

                if (zone.Whitelist.Count > 0)
                {
                    builder.AppendFormat("Whitelist: ", zone.Name);
                    foreach (String player in zone.Whitelist)
                    {
                        User u = UserCollectionSingletone.GetInstance().GetUserByName(player);
                        builder.AppendFormat("§f<§{0}{1}§f> ", u.Level.GroupColor, player);
                    }

                    String result = builder.ToString();
                    if (!String.IsNullOrEmpty(result))
                    {
                        Server.SendExecuteResponse(TriggerPlayer, result);
                    }
                    coll.Save();
                }

                return(new CommandResult(true, String.Format("Zone Whitelist executed by {0}", TriggerPlayer)));
            }
            else
            {
                return(new CommandResult(true, String.Format("Zone not found: {0}", arg1)));
            }
        }
Пример #6
0
        public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4)
        {
            ZoneCollectionSingletone coll = ZoneCollectionSingletone.GetInstance();

            coll.Load();
            if (arg2.ToLower() == "p1" || arg2.ToLower() == "p2")
            {
                Zone zone = EasyGuess.GetMatchedZone(coll, arg1);
                if (zone != null)
                {
                    if (arg2 == "p1")
                    {
                        zone.Position1 = new MinecraftWrapper.Player.XPosition((int)Client.Position.X, (int)Client.Position.Y, (int)Client.Position.Z, 0, 0, 0, false);
                        coll.Save();
                        return(new CommandResult(true, string.Format("{0} set zone {1} position 1", TriggerPlayer, zone.Name)));
                    }

                    if (arg2 == "p2")
                    {
                        zone.Position2 = new MinecraftWrapper.Player.XPosition((int)Client.Position.X, (int)Client.Position.Y, (int)Client.Position.Z, 0, 0, 0, false);
                        coll.Save();
                        return(new CommandResult(true, string.Format("{0} set zone {1} position 2", TriggerPlayer, zone.Name)));
                    }
                }
                else
                {
                    return(new CommandResult(true, string.Format("{0} zone not found", arg1)));
                }
            }
            else if (!String.IsNullOrEmpty(arg1))
            {
                Zone zone = ZoneCollectionSingletone.GetInstance().GetZoneByName(arg1);
                if (zone == null)
                {
                    zone = new Zone(arg1);
                    if (!MinecraftHandler.IsStringInList(TriggerPlayer, zone.Whitelist))
                    {
                        zone.Whitelist.Add(TriggerPlayer);
                    }
                    zone.LevelID   = ClientUser.LevelID;
                    zone.Owner     = TriggerPlayer;
                    zone.Position1 = new MinecraftWrapper.Player.XPosition((int)Client.Position.X, (int)Client.Position.Y, (int)Client.Position.Z, 0, 0, 0, false);
                    zone.Position2 = new MinecraftWrapper.Player.XPosition((int)Client.Position.X, (int)Client.Position.Y, (int)Client.Position.Z, 0, 0, 0, false);
                    coll.Add(zone);
                    coll.Save();
                    return(new CommandResult(true, string.Format("{0} created zone {1}", TriggerPlayer, arg1)));
                }
                else
                {
                    return(new CommandResult(true, string.Format("Zone {0} is allready in use", zone.Name)));
                }
            }

            return(new CommandResult());
        }
Пример #7
0
        public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4)
        {
            ZoneCollectionSingletone zones = ZoneCollectionSingletone.GetInstance();
            Zone zone = zones.GetZoneByPosition(Client.Position);

            if (zone != null)
            {
                Server.SendExecuteResponse(TriggerPlayer, string.Format("<{0}> is in zone <{1}> and the owner is <{2}>", TriggerPlayer, zone.Name, zone.Owner));
                Server.SendExecuteResponse(TriggerPlayer, String.Format("{0}", zone.Description));
                return(new CommandResult(true, string.Format("{0} executed by {1}", Name, TriggerPlayer)));
            }

            return(new CommandResult(true, string.Format("Player <{0}> is not in a zone", TriggerPlayer)));
        }
Пример #8
0
        public ZoneForm(MinecraftHandler mc)
        {
            InitializeComponent();
            dgvZones.AutoGenerateColumns = false;

            this.mc = mc;

            _zoneCollection = ZoneCollectionSingletone.GetInstance();

            dgvZones.DataSource = _zoneCollection.Items;
            GenerateColumns(false);
            UpdateDataGrid(0);
            this.Dock = DockStyle.Fill;
        }
Пример #9
0
        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)
            {
                String match = EasyGuess.GetMatchedString(MinecraftHandler.Player, arg2);
                User   user  = UserCollectionSingletone.GetInstance().GetUserByName(match);
                if (!user.Generated)
                {
                    if (ClientUser.LevelID >= zone.LevelID)
                    {
                        if (TriggerPlayer == zone.Owner || ClientUser.LevelID > zone.LevelID)
                        {
                            if (MinecraftHandler.IsStringInList(user.Name, zone.Whitelist))
                            {
                                zone.Whitelist.Remove(user.Name);
                                return(new CommandResult(true, String.Format("{0} removed user {1} removed from zone {2}", TriggerPlayer, user.Name, zone.Name)));
                            }
                            else
                            {
                                return(new CommandResult(true, String.Format("User {0} is not in zone {1} whitelist", user.Name, zone.Name)));
                            }
                        }
                        else
                        {
                            return(new CommandResult(true, String.Format("You cannot whitelist, you need to be the owner or have an higher id")));
                        }
                    }
                    else
                    {
                        return(new CommandResult(true, String.Format("Insufficient permissions to set remove a player from whitelist")));
                    }
                }
                else
                {
                    return(new CommandResult(true, String.Format("User not found: {0}", arg1)));
                }
            }
            else
            {
                return(new CommandResult(true, String.Format("Zone not found: {0}", arg1)));
            }
        }
Пример #10
0
        public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4)
        {
            var mc = MinecraftHandler;
            ZoneCollectionSingletone coll = ZoneCollectionSingletone.GetInstance();

            StringBuilder builder = new StringBuilder();
            List <String> lines   = new List <string>();

            if (coll.Items.Count > 0)
            {
                builder.AppendFormat("Zones: ");
                for (int i = 0; i < coll.Items.Count; i++)
                {
                    Zone   zone = coll.Items[i];
                    String name = zone.Name.Trim();

                    if (!String.IsNullOrEmpty(name))
                    {
                        if (builder.Length + name.Length + mc.Config.ResponsePrefix.Length <= 70)
                        {
                            builder.AppendFormat("§f<§{0}{1}§f> ", zone.Level.GroupColor, 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("Zones executed by {0}", TriggerPlayer)));
        }
Пример #11
0
        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)
            {
                int level = 0;
                if (int.TryParse(arg2, out level))
                {
                    if (TriggerPlayer == ClientUser.Name || ClientUser.LevelID > zone.LevelID)
                    {
                        int setLevel = 0;
                        if (ClientUser.Level.BlockLevel < level || level < 0)
                        {
                            setLevel = ClientUser.Level.BlockLevel;
                        }
                        else
                        {
                            setLevel = level;
                        }
                        coll.Save();
                        return(new CommandResult(true, String.Format("Zone-Level of zone {0} is now {1}", zone.Name, setLevel)));
                    }
                    else
                    {
                        return(new CommandResult(true, String.Format("Insufficient permissions to set the blocklevel")));
                    }
                }
                else
                {
                    return(new CommandResult(true, String.Format("Invalid blocklevel {0}", arg2)));
                }
            }
            else
            {
                return(new CommandResult(true, String.Format("Zone not found: {0}", arg1)));
            }
        }
Пример #12
0
        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)
            {
                String match = EasyGuess.GetMatchedString(MinecraftHandler.Player, arg2);
                User   user  = UserCollectionSingletone.GetInstance().GetUserByName(match);
                if (user.Generated)
                {
                    user         = new User(TriggerPlayer, false);
                    user.LevelID = 0;
                    UserCollectionSingletone.GetInstance().Add(user);
                    UserCollectionSingletone.GetInstance().Save();
                }
                if (TriggerPlayer == zone.Owner || ClientUser.LevelID > zone.LevelID)
                {
                    if (!MinecraftHandler.IsStringInList(user.Name, zone.Whitelist))
                    {
                        zone.Whitelist.Add(user.Name);
                        return(new CommandResult(true, String.Format("{0} has added user {1} to Zone {2}", TriggerPlayer, user.Name, zone.Name)));
                    }
                    else
                    {
                        return(new CommandResult(true, String.Format("User {0} is allready in Zone {1}", user.Name, zone.Name)));
                    }
                }
                else
                {
                    return(new CommandResult(true, String.Format("You cannot whitelist, you need to be the owner or have an higher id")));
                }
            }
            else
            {
                return(new CommandResult(true, String.Format("Zone not found: {0}", arg1)));
            }
        }