void CommandInitExtraPerms()
        {
            extraPermsList = CommandExtraPerms.FindAll(cmd.name);
            for (int i = 0; i < commandExtraBoxes.Length; i++)
            {
                commandExtraBoxes[i].Visible  = false;
                commandExtraLabels[i].Visible = false;
            }
            if (cmd.ExtraPerms == null)
            {
                extraPermsList.Clear();
            }

            int height = 12;

            for (int i = 0; i < extraPermsList.Count; i++)
            {
                CommandExtraPerms perms = LookupExtraPerms(extraPermsList[i].CmdName, extraPermsList[i].Num);
                if (perms == null)
                {
                    perms = extraPermsList[i];
                }

                GuiPerms.SetDefaultIndex(commandExtraBoxes[i], perms.MinRank);
                commandExtraBoxes[i].Visible  = true;
                commandExtraLabels[i].Text    = "+ " + perms.Desc;
                commandExtraLabels[i].Visible = true;
                height = commandExtraBoxes[i].Bottom + 12;
            }
            cmd_grpExtra.Visible = extraPermsList.Count > 0;
            cmd_grpExtra.Height  = height;
        }
        void LoadSecurityProps()
        {
            sec_cbLogNotes.Checked     = Server.Config.LogNotes;
            sec_cbVerifyAdmins.Checked = Server.Config.verifyadmins;
            sec_cbWhitelist.Checked    = Server.Config.WhitelistedOnly;
            sec_cmbVerifyRank.Items.AddRange(GuiPerms.RankNames);
            GuiPerms.SetDefaultIndex(sec_cmbVerifyRank, Server.Config.VerifyAdminsRank);
            sec_cmbVerifyRank.Enabled = Server.Config.verifyadmins;

            sec_cbChatAuto.Checked = Server.Config.ChatSpamCheck;
            sec_numChatMsgs.Value  = Server.Config.ChatSpamCount;
            sec_numChatSecs.Value  = Server.Config.ChatSpamInterval;
            sec_numChatMute.Value  = Server.Config.ChatSpamMuteTime;
            ToggleChatSpamSettings(Server.Config.ChatSpamCheck);

            sec_cbCmdAuto.Checked = Server.Config.CmdSpamCheck;
            sec_numCmdMsgs.Value  = Server.Config.CmdSpamCount;
            sec_numCmdSecs.Value  = Server.Config.CmdSpamInterval;
            sec_numCmdMute.Value  = Server.Config.CmdSpamBlockTime;
            ToggleCmdSpamSettings(Server.Config.CmdSpamCheck);

            sec_cbBlocksAuto.Checked = Server.Config.BlockSpamCheck;
            sec_numBlocksMsgs.Value  = Server.Config.BlockSpamCount;
            sec_numBlocksSecs.Value  = Server.Config.BlockSpamInterval;
            ToggleBlocksSpamSettings(Server.Config.BlockSpamCheck);

            sec_cbIPAuto.Checked = Server.Config.IPSpamCheck;
            sec_numIPMsgs.Value  = Server.Config.IPSpamCount;
            sec_numIPSecs.Value  = Server.Config.IPSpamInterval;
            sec_numIPMute.Value  = Server.Config.IPSpamBlockTime;
            ToggleIPSpamSettings(sec_cbIPAuto.Checked);
        }
Beispiel #3
0
        internal static void SetSpecificPerms(List <LevelPermission> perms, ComboBox[] boxes)
        {
            ComboBox box = null;

            for (int i = 0; i < boxes.Length; i++)
            {
                box = boxes[i];
                // Hide the non-visible specific permissions
                box.Text          = "";
                box.Enabled       = false;
                box.Visible       = false;
                box.SelectedIndex = -1;

                // Show the non-visible specific permissions previously set
                if (perms.Count > i)
                {
                    box.Visible = true;
                    box.Enabled = true;
                    GuiPerms.SetDefaultIndex(box, perms[i]);
                }
            }

            // Show (add rank) for the last item
            if (perms.Count >= boxes.Length)
            {
                return;
            }
            SetAddRank(boxes[perms.Count]);
        }
        void blk_list_SelectedIndexChanged(object sender, EventArgs e)
        {
            blockID        = Block.Byte(blk_list.SelectedItem.ToString());
            blockPermsOrig = BlockPerms.List[blockID];
            blockPerms     = blockPermsChanged.Find(p => p.BlockID == blockID);
            BlockInitSpecificArrays();
            blockSupressEvents = true;

            BlockProps props = blockPropsChanged[blockID];

            blk_cbMsgBlock.Checked = props.IsMessageBlock;
            blk_cbPortal.Checked   = props.IsPortal;
            blk_cbDeath.Checked    = props.KillerBlock;
            blk_txtDeath.Text      = props.DeathMessage;
            blk_txtDeath.Enabled   = blk_cbDeath.Checked;

            blk_cbDoor.Checked  = props.IsDoor;
            blk_cbTdoor.Checked = props.IsTDoor;
            blk_cbRails.Checked = props.IsRails;
            blk_cbLava.Checked  = props.LavaKills;
            blk_cbWater.Checked = props.WaterKills;

            BlockPerms perms = blockPerms != null ? blockPerms : blockPermsOrig;

            GuiPerms.SetDefaultIndex(blk_cmbMin, perms.MinRank);
            GuiPerms.SetSpecificPerms(perms.Allowed, blockAllowBoxes);
            GuiPerms.SetSpecificPerms(perms.Disallowed, blockDisallowBoxes);
            blockSupressEvents = false;
        }
Beispiel #5
0
        void LoadIrcSqlProps()
        {
            irc_chkEnabled.Checked = Server.Config.UseIRC;
            irc_txtServer.Text     = Server.Config.IRCServer;
            irc_txtPort.Text       = Server.Config.IRCPort.ToString();
            irc_txtNick.Text       = Server.Config.IRCNick;
            irc_txtChannel.Text    = Server.Config.IRCChannels;
            irc_txtOpChannel.Text  = Server.Config.IRCOpChannels;
            irc_chkPass.Checked    = Server.Config.IRCIdentify;
            irc_txtPass.Text       = Server.Config.IRCPassword;

            irc_cbTitles.Checked       = Server.Config.IRCShowPlayerTitles;
            irc_cbWorldChanges.Checked = Server.Config.IRCShowWorldChanges;
            irc_cbAFK.Checked          = Server.Config.IRCShowAFK;
            ToggleIrcSettings(Server.Config.UseIRC);

            irc_cbRank.Items.AddRange(GuiPerms.RankNames);
            GuiPerms.SetDefaultIndex(irc_cbRank, Server.Config.IRCControllerRank);
            irc_cbVerify.Items.AddRange(Enum.GetNames(typeof(IRCControllerVerify)));
            irc_cbVerify.SelectedIndex = (int)Server.Config.IRCVerify;
            irc_txtPrefix.Text         = Server.Config.IRCCommandPrefix;

            sql_chkUseSQL.Checked = Server.Config.UseMySQL;
            sql_txtUser.Text      = Server.Config.MySQLUsername;
            sql_txtPass.Text      = Server.Config.MySQLPassword;
            sql_txtDBName.Text    = Server.Config.MySQLDatabaseName;
            sql_txtHost.Text      = Server.Config.MySQLHost;
            sql_txtPort.Text      = Server.Config.MySQLPort;
            ToggleMySQLSettings(Server.Config.UseMySQL);
        }
        void ApplySecurityProps()
        {
            Server.Config.LogNotes         = sec_cbLogNotes.Checked;
            Server.Config.verifyadmins     = sec_cbVerifyAdmins.Checked;
            Server.Config.VerifyAdminsRank = GuiPerms.GetPermission(sec_cmbVerifyRank, LevelPermission.Operator);
            Server.Config.WhitelistedOnly  = sec_cbWhitelist.Checked;

            Server.Config.ChatSpamCheck    = sec_cbChatAuto.Checked;
            Server.Config.ChatSpamCount    = (int)sec_numChatMsgs.Value;
            Server.Config.ChatSpamInterval = sec_numChatSecs.Value;
            Server.Config.ChatSpamMuteTime = sec_numChatMute.Value;

            Server.Config.CmdSpamCheck     = sec_cbCmdAuto.Checked;
            Server.Config.CmdSpamCount     = (int)sec_numCmdMsgs.Value;
            Server.Config.CmdSpamInterval  = sec_numCmdSecs.Value;
            Server.Config.CmdSpamBlockTime = sec_numCmdMute.Value;

            Server.Config.BlockSpamCheck    = sec_cbBlocksAuto.Checked;
            Server.Config.BlockSpamCount    = (int)sec_numBlocksMsgs.Value;
            Server.Config.BlockSpamInterval = sec_numBlocksSecs.Value;

            Server.Config.IPSpamCheck     = sec_cbIPAuto.Checked;
            Server.Config.IPSpamCount     = (int)sec_numIPMsgs.Value;
            Server.Config.IPSpamInterval  = sec_numIPSecs.Value;
            Server.Config.IPSpamBlockTime = sec_numIPMute.Value;
        }
Beispiel #7
0
        void ApplyIrcSqlProps()
        {
            Server.Config.UseIRC        = irc_chkEnabled.Checked;
            Server.Config.IRCServer     = irc_txtServer.Text;
            Server.Config.IRCPort       = int.Parse(irc_txtPort.Text);
            Server.Config.IRCNick       = irc_txtNick.Text;
            Server.Config.IRCChannels   = irc_txtChannel.Text;
            Server.Config.IRCOpChannels = irc_txtOpChannel.Text;
            Server.Config.IRCIdentify   = irc_chkPass.Checked;
            Server.Config.IRCPassword   = irc_txtPass.Text;

            Server.Config.IRCShowPlayerTitles = irc_cbTitles.Checked;
            Server.Config.IRCShowWorldChanges = irc_cbWorldChanges.Checked;
            Server.Config.IRCShowAFK          = irc_cbAFK.Checked;

            Server.Config.IRCControllerRank = GuiPerms.GetPermission(irc_cbRank, LevelPermission.Nobody);
            Server.Config.IRCVerify         = (IRCControllerVerify)irc_cbVerify.SelectedIndex;
            Server.Config.IRCCommandPrefix  = irc_txtPrefix.Text;

            Server.Config.UseMySQL          = sql_chkUseSQL.Checked;
            Server.Config.MySQLUsername     = sql_txtUser.Text;
            Server.Config.MySQLPassword     = sql_txtPass.Text;
            Server.Config.MySQLDatabaseName = sql_txtDBName.Text;
            Server.Config.MySQLHost         = sql_txtHost.Text;
            Server.Config.MySQLPort         = sql_txtPort.Text;

            Database.Backend = Server.Config.UseMySQL ? MySQLBackend.Instance : SQLiteBackend.Instance;
            //Server.Config.MySQLPooling = ; // No setting for this?
        }
        void LoadEcoProps()
        {
            eco_cbEnabled.Checked = Economy.Enabled;
            eco_txtCurrency.Text  = Server.Config.Currency;
            Eco_UpdateEnables();

            foreach (Item item in Economy.Items)
            {
                eco_cmbCfg.Items.Add(item.Name);
            }
            eco_cmbCfg.Items.Add("(none)");
            eco_cmbCfg.SelectedIndex = eco_cmbCfg.Items.Count - 1;

            GuiPerms.SetRanks(eco_cmbItemRank);
            eco_colRankPrice.CellTemplate = new NumericalCell();
            eco_dgvRanks.DataError       += eco_dgv_DataError;

            eco_colLvlPrice.CellTemplate = new NumericalCell();
            eco_colLvlX.CellTemplate     = new NumericalCell();
            eco_colLvlY.CellTemplate     = new NumericalCell();
            eco_colLvlZ.CellTemplate     = new NumericalCell();
            eco_colLvlTheme.CellTemplate = new ThemeCell();

            foreach (MapGen gen in MapGen.Generators)
            {
                if (gen.Type == GenType.Advanced)
                {
                    continue;
                }
                eco_colLvlTheme.Items.Add(gen.Theme);
            }
            eco_dgvMaps.DataError += eco_dgv_DataError;
        }
Beispiel #9
0
        void PropertyWindow_Load(object sender, EventArgs e)
        {
            // try to use same icon as main window
            // must be done in OnLoad, otherwise icon doesn't show on Mono
            GuiUtils.SetIcon(this);

            OnMapsChangedEvent.Register(HandleMapsChanged, Priority.Low);
            OnStateChangedEvent.Register(HandleStateChanged, Priority.Low);
            GuiPerms.UpdateRankNames();
            rank_cmbDefault.Items.AddRange(GuiPerms.RankNames);
            rank_cmbOsMap.Items.AddRange(GuiPerms.RankNames);
            blk_cmbMin.Items.AddRange(GuiPerms.RankNames);
            cmd_cmbMin.Items.AddRange(GuiPerms.RankNames);

            //Load server stuff
            LoadProperties();
            LoadRanks();
            try {
                LoadCommands();
                LoadBlocks();
            } catch (Exception ex) {
                Logger.LogError("Error loading commands and blocks", ex);
            }

            LoadGameProps();
        }
        void Eco_UpdateItem()
        {
            eco_gbItem.Text        = eco_curItem.Name;
            eco_numItemPrice.Value = eco_curItem.Price;
            Eco_UpdateItemEnables();

            GuiPerms.SetSelectedRank(eco_cmbItemRank, eco_curItem.PurchaseRank);
        }
Beispiel #11
0
 void LoadRankProps()
 {
     GuiPerms.SetDefaultIndex(rank_cmbDefault, Group.DefaultRank.Permission);
     GuiPerms.SetDefaultIndex(rank_cmbOsMap, Server.Config.OSPerbuildDefault);
     rank_cbTPHigher.Checked     = Server.Config.HigherRankTP;
     rank_cbSilentAdmins.Checked = Server.Config.AdminsJoinSilently;
     rank_cbEmpty.Checked        = Server.Config.ListEmptyRanks;
 }
 void ApplyRankProps()
 {
     Server.Config.DefaultRankName    = rank_cmbDefault.SelectedItem.ToString();
     Server.Config.OSPerbuildDefault  = GuiPerms.GetSelectedRank(rank_cmbOsMap, LevelPermission.Owner);
     Server.Config.HigherRankTP       = rank_cbTPHigher.Checked;
     Server.Config.AdminsJoinSilently = rank_cbSilentAdmins.Checked;
     Server.Config.ListEmptyRanks     = rank_cbEmpty.Checked;
 }
Beispiel #13
0
        void Eco_UpdateItem()
        {
            eco_gbItem.Text        = eco_curItem.Name;
            eco_numItemPrice.Value = eco_curItem.Price;
            Eco_UpdateItemEnables();

            GuiPerms.SetDefaultIndex(eco_cbItemRank, eco_curItem.PurchaseRank);
        }
Beispiel #14
0
 public void Update(ItemPerms perms)
 {
     SupressEvents = true;
     GuiPerms.SetDefaultIndex(MinBox, perms.MinRank);
     SetSpecificPerms(perms.Allowed, AllowBoxes);
     SetSpecificPerms(perms.Disallowed, DisallowBoxes);
     SupressEvents = false;
 }
        void LoadRankProps()
        {
            LoadDefaultRank();
            GuiPerms.SetRanks(rank_cmbOsMap);
            GuiPerms.SetSelectedRank(rank_cmbOsMap, Server.Config.OSPerbuildDefault);

            rank_cbTPHigher.Checked     = Server.Config.HigherRankTP;
            rank_cbSilentAdmins.Checked = Server.Config.AdminsJoinSilently;
            rank_cbEmpty.Checked        = Server.Config.ListEmptyRanks;
        }
        void eco_cmbItemRank_SelectedIndexChanged(object sender, EventArgs e)
        {
            const LevelPermission perm = LevelPermission.Guest;

            if (eco_curItem == null)
            {
                return;
            }

            eco_curItem.PurchaseRank = GuiPerms.GetSelectedRank(eco_cmbItemRank, perm);
        }
 void BlockInitSpecificArrays()
 {
     if (blockAllowBoxes != null)
     {
         return;
     }
     blockAllowBoxes    = new ComboBox[] { blk_cmbAlw1, blk_cmbAlw2, blk_cmbAlw3 };
     blockDisallowBoxes = new ComboBox[] { blk_cmbDis1, blk_cmbDis2, blk_cmbDis3 };
     GuiPerms.FillRanks(blockAllowBoxes);
     GuiPerms.FillRanks(blockDisallowBoxes);
 }
Beispiel #18
0
        void cmd_list_SelectedIndexChanged(object sender, EventArgs e)
        {
            commandName      = cmd_list.SelectedItem.ToString();
            commandPermsOrig = CommandPerms.Find(commandName);
            commandPerms     = commandPermsChanged.Find(p => p.CmdName == commandName);
            CommandInitSpecificArrays();

            commandSupressEvents = true;
            CommandPerms perms = commandPerms != null ? commandPerms : commandPermsOrig;

            GuiPerms.SetDefaultIndex(cmd_cmbMin, perms.MinRank);
            GuiPerms.SetSpecificPerms(perms.Allowed, commandAllowBoxes);
            GuiPerms.SetSpecificPerms(perms.Disallowed, commandDisallowBoxes);
            CommandInitExtraPerms();
            commandSupressEvents = false;
        }
        void CommandInitSpecificArrays()
        {
            if (commandItems.MinBox != null)
            {
                return;
            }
            commandItems.MinBox        = cmd_cmbMin;
            commandItems.AllowBoxes    = new ComboBox[] { cmd_cmbAlw1, cmd_cmbAlw2, cmd_cmbAlw3 };
            commandItems.DisallowBoxes = new ComboBox[] { cmd_cmbDis1, cmd_cmbDis2, cmd_cmbDis3 };
            commandItems.FillInitial();

            commandExtraBoxes = new ComboBox[] { cmd_cmbExtra1, cmd_cmbExtra2, cmd_cmbExtra3,
                                                 cmd_cmbExtra4, cmd_cmbExtra5, cmd_cmbExtra6, cmd_cmbExtra7 };
            commandExtraLabels = new Label[] { cmd_lblExtra1, cmd_lblExtra2, cmd_lblExtra3,
                                               cmd_lblExtra4, cmd_lblExtra5, cmd_lblExtra6, cmd_lblExtra7 };
            GuiPerms.FillRanks(commandExtraBoxes, false);
        }
        void blk_cmbSpecific_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox box = (ComboBox)sender;

            if (blockSupressEvents)
            {
                return;
            }
            int idx = box.SelectedIndex;

            if (idx == -1)
            {
                return;
            }
            BlockGetOrAddPermsChanged();

            List <LevelPermission> perms = blockPerms.Allowed;

            ComboBox[] boxes  = blockAllowBoxes;
            int        boxIdx = Array.IndexOf <ComboBox>(boxes, box);

            if (boxIdx == -1)
            {
                perms  = blockPerms.Disallowed;
                boxes  = blockDisallowBoxes;
                boxIdx = Array.IndexOf <ComboBox>(boxes, box);
            }

            if (idx == box.Items.Count - 1)
            {
                if (boxIdx >= perms.Count)
                {
                    return;
                }
                perms.RemoveAt(boxIdx);

                blockSupressEvents = true;
                GuiPerms.SetSpecificPerms(perms, boxes);
                blockSupressEvents = false;
            }
            else
            {
                GuiPerms.SetSpecific(boxes, boxIdx, perms, idx);
            }
        }
Beispiel #21
0
        void PropertyWindow_Load(object sender, EventArgs e)
        {
            ToggleIrcSettings(ServerConfig.UseIRC);

            GuiPerms.UpdateRankNames();
            rank_cmbDefault.Items.AddRange(GuiPerms.RankNames);
            rank_cmbOsMap.Items.AddRange(GuiPerms.RankNames);
            blk_cmbMin.Items.AddRange(GuiPerms.RankNames);
            cmd_cmbMin.Items.AddRange(GuiPerms.RankNames);

            //Load server stuff
            LoadProperties();
            LoadRanks();
            try {
                LoadCommands();
                LoadBlocks();
            } catch (Exception ex) {
                Logger.LogError(ex);
                Logger.Log(LogType.Warning, "Failed to load commands and blocks!");
            }

            try {
                LoadLavaSettings();
                UpdateLavaMapList();
                UpdateLavaControls();
            } catch (Exception ex) {
                Logger.LogError(ex);
                Logger.Log(LogType.Warning, "Failed to load Lava Survival settings!");
            }

            try {
                lavaUpdateTimer = new System.Timers.Timer(10000)
                {
                    AutoReset = true
                };
                lavaUpdateTimer.Elapsed += delegate {
                    UpdateLavaControls();
                    UpdateLavaMapList(false);
                };
                lavaUpdateTimer.Start();
            } catch {
                Logger.Log(LogType.Warning, "Failed to start lava control update timer!");
            }
        }
Beispiel #22
0
        void ApplyIRCProps()
        {
            Server.Config.UseIRC        = irc_chkEnabled.Checked;
            Server.Config.IRCServer     = irc_txtServer.Text;
            Server.Config.IRCPort       = (int)irc_numPort.Value;
            Server.Config.IRCNick       = irc_txtNick.Text;
            Server.Config.IRCChannels   = irc_txtChannel.Text;
            Server.Config.IRCOpChannels = irc_txtOpChannel.Text;
            Server.Config.IRCIdentify   = irc_chkPass.Checked;
            Server.Config.IRCPassword   = irc_txtPass.Text;

            Server.Config.IRCShowPlayerTitles = irc_cbTitles.Checked;
            Server.Config.IRCShowWorldChanges = irc_cbWorldChanges.Checked;
            Server.Config.IRCShowAFK          = irc_cbAFK.Checked;

            Server.Config.IRCControllerRank = GuiPerms.GetPermission(irc_cmbRank, LevelPermission.Admin);
            Server.Config.IRCVerify         = (IRCControllerVerify)irc_cmbVerify.SelectedIndex;
            Server.Config.IRCCommandPrefix  = irc_txtPrefix.Text;
        }
Beispiel #23
0
        void LoadIRCProps()
        {
            irc_chkEnabled.Checked = Server.Config.UseIRC;
            irc_txtServer.Text     = Server.Config.IRCServer;
            irc_numPort.Value      = Server.Config.IRCPort;
            irc_txtNick.Text       = Server.Config.IRCNick;
            irc_txtChannel.Text    = Server.Config.IRCChannels;
            irc_txtOpChannel.Text  = Server.Config.IRCOpChannels;
            irc_chkPass.Checked    = Server.Config.IRCIdentify;
            irc_txtPass.Text       = Server.Config.IRCPassword;

            irc_cbTitles.Checked       = Server.Config.IRCShowPlayerTitles;
            irc_cbWorldChanges.Checked = Server.Config.IRCShowWorldChanges;
            irc_cbAFK.Checked          = Server.Config.IRCShowAFK;
            ToggleIrcSettings(Server.Config.UseIRC);

            irc_cmbRank.Items.AddRange(GuiPerms.RankNames);
            GuiPerms.SetDefaultIndex(irc_cmbRank, Server.Config.IRCControllerRank);
            irc_cmbVerify.Items.AddRange(Enum.GetNames(typeof(IRCControllerVerify)));
            irc_cmbVerify.SelectedIndex = (int)Server.Config.IRCVerify;
            irc_txtPrefix.Text          = Server.Config.IRCCommandPrefix;
        }
Beispiel #24
0
        void PropertyWindow_Load(object sender, EventArgs e)
        {
            OnMapsChangedEvent.Register(HandleMapsChanged, Priority.Low);
            OnStateChangedEvent.Register(HandleStateChanged, Priority.Low);
            GuiPerms.UpdateRankNames();
            rank_cmbDefault.Items.AddRange(GuiPerms.RankNames);
            rank_cmbOsMap.Items.AddRange(GuiPerms.RankNames);
            blk_cmbMin.Items.AddRange(GuiPerms.RankNames);
            cmd_cmbMin.Items.AddRange(GuiPerms.RankNames);

            //Load server stuff
            LoadProperties();
            LoadRanks();
            try {
                LoadCommands();
                LoadBlocks();
            } catch (Exception ex) {
                Logger.LogError("Error loading commands and blocks", ex);
            }

            LoadGameProps();
        }
Beispiel #25
0
 public void FillInitial()
 {
     GuiPerms.SetRanks(AllowBoxes, true);
     GuiPerms.SetRanks(DisallowBoxes, true);
 }
Beispiel #26
0
 public void FillInitial()
 {
     GuiPerms.FillRanks(AllowBoxes);
     GuiPerms.FillRanks(DisallowBoxes);
 }
Beispiel #27
0
        void eco_cbItemRank_SelectedIndexChanged(object sender, EventArgs e)
        {
            const LevelPermission perm = LevelPermission.Guest;

            eco_curItem.PurchaseRank = GuiPerms.GetPermission(eco_cbItemRank, perm);
        }