Example #1
0
        public bool AskSaveChanges()
        {
            if (_watches.Changes)
            {
                GlobalWin.Sound.StopSound();
                var result = MessageBox.Show("Save Changes?", "RAM Watch", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3);
                GlobalWin.Sound.StartSound();
                if (result == DialogResult.Yes)
                {
                    if (string.IsNullOrWhiteSpace(_watches.CurrentFileName))
                    {
                        SaveAs();
                    }
                    else
                    {
                        _watches.Save();
                        Global.Config.RecentWatches.Add(_watches.CurrentFileName);
                    }
                }
                else if (result == DialogResult.No)
                {
                    _watches.Changes = false;
                    return(true);
                }
                else if (result == DialogResult.Cancel)
                {
                    return(false);
                }
            }

            return(true);
        }
        public override bool AskSaveChanges()
        {
            if (_watches.Changes)
            {
                var result = MainForm.DoWithTempMute(() => MessageBox.Show("Save Changes?", "RAM Watch", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3));
                if (result == DialogResult.Yes)
                {
                    if (string.IsNullOrWhiteSpace(_watches.CurrentFileName))
                    {
                        SaveAs();
                    }
                    else
                    {
                        _watches.Save();
                        Config.RecentWatches.Add(_watches.CurrentFileName);
                    }
                }
                else if (result == DialogResult.No)
                {
                    _watches.Changes = false;
                    return(true);
                }
                else if (result == DialogResult.Cancel)
                {
                    return(false);
                }
            }

            return(true);
        }
Example #3
0
		private void SaveMenuItem_Click(object sender, EventArgs e)
		{
			if (!string.IsNullOrWhiteSpace(_currentFileName))
			{
				var watches = new WatchList(MemoryDomains, Emu.SystemId) { CurrentFileName = _currentFileName };
				for (var i = 0; i < _searches.Count; i++)
				{
					watches.Add(_searches[i]);
				}

				if (!string.IsNullOrWhiteSpace(watches.CurrentFileName))
				{
					if (watches.Save())
					{
						_currentFileName = watches.CurrentFileName;
						MessageLabel.Text = $"{Path.GetFileName(_currentFileName)} saved";
						Settings.RecentSearches.Add(watches.CurrentFileName);
					}
				}
				else
				{
					var result = watches.SaveAs(GetWatchSaveFileFromUser(CurrentFileName()));
					if (result)
					{
						MessageLabel.Text = $"{Path.GetFileName(_currentFileName)} saved";
						Settings.RecentSearches.Add(watches.CurrentFileName);
					}
				}
			}
		}
Example #4
0
		private void SaveMenuItem_Click(object sender, EventArgs e)
		{
			if (!string.IsNullOrWhiteSpace(_currentFileName))
			{
				var watches = new WatchList(_settings.Domain) { CurrentFileName = _currentFileName };
				for (var i = 0; i < _searches.Count; i++)
				{
					watches.Add(_searches[i]);
				}

				if (!string.IsNullOrWhiteSpace(watches.CurrentFileName))
				{
					if (watches.Save())
					{
						_currentFileName = watches.CurrentFileName;
						MessageLabel.Text = Path.GetFileName(_currentFileName) + " saved";
					}
				}
				else
				{
					var result = watches.SaveAs(ToolHelpers.GetWatchSaveFileFromUser(watches.CurrentFileName));
					if (result)
					{
						MessageLabel.Text = Path.GetFileName(_currentFileName) + " saved";
						Global.Config.RecentWatches.Add(watches.CurrentFileName);
					}
				}
			}
		}
        /// <summary>
        /// Apply a punish to the specified <see cref="Player"/>.
        /// </summary>
        /// <param name="target">The <see cref="Exiled.API.Features.Player"/> player.</param>
        /// <param name="issuer">The <see cref="Collections.Player"/> staffer.</param>
        /// <param name="dPlayer">The <see cref="Collections.Player"/> player.</param>
        /// <param name="punishType">The <see cref="Enums.PunishType"/> punish.</param>
        /// <param name="reason">The reason of the punish.</param>
        /// <param name="duration">The <see cref="DateTime"/> duration.</param>
        public static void ApplyPunish(Player target, Collections.Player issuer, Collections.Player dPlayer, PunishType punishType, string reason, string duration)
        {
            switch (punishType)
            {
            case PunishType.Warn:
                Warn warn = new Warn(dPlayer, issuer, reason, DateTime.Now, WarnCollection.Find(w => w.Target.Id == dPlayer.Id).Count(), Server.Port, false);
                warn.Save();

                target?.Broadcast(Plugin.Singleton.Config.Translation.WarnTranslation.PlayerWarnedMessage.Duration,
                                  Plugin.Singleton.Config.Translation.WarnTranslation.PlayerWarnedMessage.Content.Replace(
                                      "{reason}", reason), global::Broadcast.BroadcastFlags.Normal, true);

                JsonManager.PunishToCache(punishType, JsonConvert.SerializeObject(warn), dPlayer, ActionType.Add);
                break;

            case PunishType.Mute:
                Mute mute = new Mute(dPlayer, issuer, reason, GetDate(duration), DateTime.Now, DateTime.Now.AddSeconds(GetTotalSeconds(duration).TotalSeconds), MuteCollection.Find(m => m.Target == dPlayer).Count(), Server.Port, false);
                mute.Save();

                MuteHandler.IssuePersistentMute(dPlayer.Id + dPlayer.Authentication);
                target?.Broadcast(Plugin.Singleton.Config.Translation.MuteTranslation.PlayerMuteMessage.Duration,
                                  Plugin.Singleton.Config.Translation.WarnTranslation.PlayerWarnedMessage.Content
                                  .Replace("{duration}", GetDate(duration)).Replace("{reason}", reason));

                JsonManager.PunishToCache(punishType, JsonConvert.SerializeObject(mute), dPlayer, ActionType.Add);
                break;

            case PunishType.Kick:
                Kick kick = new Kick(dPlayer, issuer, reason, DateTime.Now, KickCollection.Find(x => x.Target.Id == dPlayer.Id).Count(), Server.Port, false);
                kick.Save();

                target?.Kick(Plugin.Singleton.Config.Translation.KickTranslation.PlayerKickedMessage.Replace("{reason}", reason));

                JsonManager.PunishToCache(punishType, JsonConvert.SerializeObject(kick), dPlayer, ActionType.Add);
                break;

            case PunishType.Ban:
                Ban ban = new Ban(dPlayer, issuer, reason, GetDate(duration, true), DateTime.Now, DateTime.Now.AddSeconds(GetTotalSeconds(duration, true).TotalSeconds), BanCollection.Find(x => x.Target.Id == dPlayer.Id).Count(), Server.Port, false);
                ban.Save();
                target?.Disconnect(Plugin.Singleton.Config.Translation.BanTranslation.PlayerBanMessage.Replace("{reason}", reason));
                JsonManager.PunishToCache(punishType, JsonConvert.SerializeObject(ban), dPlayer, ActionType.Add);
                break;

            case PunishType.SoftWarn:
                SoftWarn softWarn = new SoftWarn(dPlayer, issuer, reason, DateTime.Now, SoftWarnCollection.Find(sw => sw.Target.Id == dPlayer.Id).Count(), Server.Port, false);
                softWarn.Save();

                target?.Broadcast(
                    Plugin.Singleton.Config.Translation.SoftWarnTranslation.PlayerSoftWarnedMessage.Duration,
                    Plugin.Singleton.Config.Translation.SoftWarnTranslation.PlayerSoftWarnedMessage.Content.Replace(
                        "{reason}", reason));

                JsonManager.PunishToCache(punishType, JsonConvert.SerializeObject(softWarn), dPlayer,
                                          ActionType.Add);
                break;

            case PunishType.SoftBan:
                SoftBan softBan = new SoftBan(dPlayer, issuer, reason, GetDate(duration), DateTime.Now, DateTime.Now.AddSeconds(GetTotalSeconds(duration).TotalSeconds), SoftBanCollection.Find(sb => sb.Target.Id == dPlayer.Id).Count(), Server.Port, false);
                softBan.Save();

                target?.Broadcast(
                    Plugin.Singleton.Config.Translation.SoftBanTranslation.PlayerSoftBanMessage.Duration,
                    Plugin.Singleton.Config.Translation.StaffTranslation.StaffSoftBanMessage.Content.Replace(
                        "{duration}",
                        GetDate(duration).Replace("{reason}", reason)));

                if (target != null && target.Role != RoleType.Spectator)
                {
                    target.Role.Type = RoleType.Spectator;
                }

                JsonManager.PunishToCache(punishType, JsonConvert.SerializeObject(softBan), dPlayer, ActionType.Add);
                break;

            case PunishType.WatchList:
                WatchList watchList = new WatchList(dPlayer, issuer, reason, DateTime.Now, WatchListCollection.Find(wl => wl.Target.Id == dPlayer.Id).Count(), Server.Port, false);
                watchList.Save();

                JsonManager.PunishToCache(punishType, JsonConvert.SerializeObject(watchList), dPlayer, ActionType.Add);
                break;
            }

            if (punishType is PunishType.WatchList)
            {
                Timing.RunCoroutine(DiscordHandler.SendMessage(Plugin.Singleton.Config.Translation.DiscordTranslation.MessageContentWatchlist.Replace("{target}", $"{dPlayer.Name} ({dPlayer.Id}@{dPlayer.Authentication})").Replace("{reason}", reason).Replace("{issuer}", $"{issuer.Name} ({issuer.Id}@{issuer.Authentication})"), Plugin.Singleton.Config.Translation.DiscordTranslation.WebhookUrlWatchlist));
            }

            Timing.RunCoroutine(DiscordHandler.SendMessage(Plugin.Singleton.Config.Translation.DiscordTranslation.MessageContent.Replace("{target}", $"{dPlayer.Name} ({dPlayer.Id}@{dPlayer.Authentication})").Replace("{reason}", reason).Replace("{action}", punishType.ToString()).Replace("{issuer}", $"{issuer.Name} ({issuer.Id}@{issuer.Authentication})").Replace("{duration}", GetDate(duration, true)), Plugin.Singleton.Config.Translation.DiscordTranslation.WebhookUrl));
        }