public async void OnLocalReporting(LocalReportingEventArgs ev)
 {
     if (Instance.Config.EventsToLog.ReportingCheater)
     {
         await Network.SendAsync(new RemoteCommand("log", "reports", string.Format(Language.CheaterReportFilled, ev.Issuer.Nickname, ev.Issuer.Id.ToString(), ev.Issuer.Role.Translate(), ev.Target.Nickname, ev.Target.Id.ToString(), ev.Target.Role.Translate(), ev.Reason))).ConfigureAwait(false);
     }
 }
Пример #2
0
        // Calling the method with bool is easier
        // It contains the code that processes the event
        private static bool InvokeLocalReport(CheaterReport reporter, GameObject reportedTo, ref string reason)
        {
            var issuer = API.Features.Player.Get(reporter.gameObject);
            var target = API.Features.Player.Get(reportedTo);

            var ev = new LocalReportingEventArgs(issuer, target, reason);

            Server.OnLocalReporting(ev);

            reason = ev.Reason;

            // If further processing isn't allowed
            // then send the success of sending the report
            // --------------------------------------------------
            // gameObjects is compared cuz there is no comparison overload for Player,
            // it can be different objects
            if (!ev.IsAllowed && reporter.gameObject != reportedTo.gameObject)
            {
                reporter.GetComponent <GameConsoleTransmission>().SendToClient(
                    reporter.connectionToClient,
                    "[Reporting] Player report successfully sent to local administrators.",
                    "green");
            }

            return(ev.IsAllowed);
        }
Пример #3
0
        /// <summary>
        /// Called when sending a complaint about a player to the local server administrators.
        /// </summary>
        /// <param name="ev">The <see cref="LocalReportingEventArgs"/> instance.</param>
        public static void OnLocalReporting(LocalReportingEventArgs ev)
        {
#if DEBUG
            void LogL(string s) =>
            Log.Debug($"{nameof(Server)}-{nameof(OnLocalReporting)}: {s}", true);

            LogL($"Original reason: {ev.Reason}");
            ev.Reason = "some random reason for debug";
            LogL($"Replaced reason: {ev.Reason}");
            LogL($"{nameof(ev.Target)} is null: {ev.Target == null}");
            LogL($"{nameof(ev.Issuer)} is null: {ev.Issuer == null}");
#endif
            LocalReporting.InvokeSafely(ev);
        }
Пример #4
0
        private void Server_LocalReporting(LocalReportingEventArgs ev)
        {
            NetDataWriter writer = new NetDataWriter();

            writer.Put(ev.Issuer.UserId);
            writer.Put(ev.Target.UserId);
            writer.Put(ev.Reason);
            NPManager.Singleton.PacketProcessor.Send <EventPacket>(
                NPManager.Singleton.NetworkListener,
                new EventPacket()
            {
                Type = (byte)EventType.PlayerLocalReport,
                Data = writer.Data
            },
                DeliveryMethod.ReliableOrdered);
        }
Пример #5
0
        internal void LocalReporting(LocalReportingEventArgs ev)
        {
            if (Plugin.Instance.Config.LocalReporting == "")
            {
                return;
            }
            string message = Plugin.Instance.Config.LocalReporting.Replace("%reason%", ev.Reason.ToString());

            message = message.Replace("%reported%", ev.Target.ToString());
            message = message.Replace("%reporter%", ev.Issuer.ToString());


            if (Plugin.Instance.Config.debug_to_console)
            {
                Log.Debug(message: "[ " + Plugin.Instance.Config.server_name + "] " + message);
            }
            Plugin.sendWebHook(Plugin.Instance.Config.server_url, message, Plugin.Instance.Config.server_name);
        }
Пример #6
0
 /// <summary>
 /// Called when sending a complaint about a player to the local server administrators.
 /// </summary>
 /// <param name="ev">The <see cref="LocalReportingEventArgs"/> instance.</param>
 public static void OnLocalReporting(LocalReportingEventArgs ev) => LocalReporting.InvokeSafely(ev);