<commit_before>﻿using System;
using System.Reflection;

using Oxide.Core.Libraries;
using System.Collections.Generic;

namespace Oxide.RustLegacy.Libraries
{
    /// <summary>
    /// A library containing utility shortcut functions for Rust
    /// </summary>
    public class RustLegacy : Library
    {
        /// <summary>
        /// Returns if this library should be loaded into the global namespace
        /// </summary>
        public override bool IsGlobal { get { return false; } }

        /// <summary>
        /// Returns the UserID for the specified player as a string
        /// </summary>
        /// <param name="netuser"></param>
        /// <returns></returns>
        [LibraryFunction("UserIDFromPlayer")]
        public string UserIDFromPlayer(NetUser netuser)
        {
            return netuser.userID.ToString();
        }

        /// <summary>
        /// Print a message to every players chat log
        /// </summary>
        /// <param name="name"></param>
        /// <param name="format"></param>
        /// <param name="args"></param>
        [LibraryFunction("BroadcastChat")]
        public void BroadcastChat(string name, string message = null)
        {
            if (message == null)
            {
                message = name;
                name = "Server";
            }
            ConsoleNetworker.Broadcast($"chat.add {name} {QuoteSafe(message)}");
        }

        /// <summary>
        /// Sends a chat message to the user
        /// </summary>
        /// <param name="netUser"></param>
        /// <param name="name"></param>
        /// <param name="format"></param>
        /// <param name="args"></param>
        [LibraryFunction("SendChatMessage")]
        public void SendChatMessage(NetUser netUser, string name, string message = null)
        {
            if (message == null)
            {
                message = name;
                name = "Server";
            }
            ConsoleNetworker.SendClientCommand(netUser.networkPlayer, $"chat.add {name} {QuoteSafe(message)}");
        }

        /// <summary>
        /// Print a message to a players console log
        /// </summary>
        /// <param name="netUser"></param>
        /// <param name="format"></param>
        /// <param name="args"></param>
        [LibraryFunction("SendConsoleMessage")]
        public void SendConsoleMessage(NetUser netUser, string format, params object[] args)
        {
            ConsoleNetworker.SendClientCommand(netUser.networkPlayer, $"echo {QuoteSafe(string.Format(format, args))}");
        }

        /// <summary>
        /// Print a message to every players console log<commit_msg>[Rust Legacy] Fixed a bug with chatnames<commit_after>﻿using System;
using System.Reflection;

using Oxide.Core.Libraries;
using System.Collections.Generic;

namespace Oxide.RustLegacy.Libraries
{
    /// <summary>
    /// A library containing utility shortcut functions for Rust
    /// </summary>
    public class RustLegacy : Library
    {
        /// <summary>
        /// Returns if this library should be loaded into the global namespace
        /// </summary>
        public override bool IsGlobal { get { return false; } }

        /// <summary>
        /// Returns the UserID for the specified player as a string
        /// </summary>
        /// <param name="netuser"></param>
        /// <returns></returns>
        [LibraryFunction("UserIDFromPlayer")]
        public string UserIDFromPlayer(NetUser netuser)
        {
            return netuser.userID.ToString();
        }

        /// <summary>
        /// Print a message to every players chat log
        /// </summary>
        /// <param name="name"></param>
        /// <param name="format"></param>
        /// <param name="args"></param>
        [LibraryFunction("BroadcastChat")]
        public void BroadcastChat(string name, string message = null)
        {
            if (message == null)
            {
                message = name;
                name = "Server";
            }
            ConsoleNetworker.Broadcast($"chat.add {QuoteSafe(name)} {QuoteSafe(message)}");
        }

        /// <summary>
        /// Sends a chat message to the user
        /// </summary>
        /// <param name="netUser"></param>
        /// <param name="name"></param>
        /// <param name="format"></param>
        /// <param name="args"></param>
        [LibraryFunction("SendChatMessage")]
        public void SendChatMessage(NetUser netUser, string name, string message = null)
        {
            if (message == null)
            {
                message = name;
                name = "Server";
            }
            ConsoleNetworker.SendClientCommand(netUser.networkPlayer, $"chat.add {QuoteSafe(name)} {QuoteSafe(message)}");
        }

        /// <summary>
        /// Print a message to a players console log
        /// </summary>
        /// <param name="netUser"></param>
        /// <param name="format"></param>
        /// <param name="args"></param>
        [LibraryFunction("SendConsoleMessage")]
        public void SendConsoleMessage(NetUser netUser, string format, params object[] args)
        {
            ConsoleNetworker.SendClientCommand(netUser.networkPlayer, $"echo {QuoteSafe(string.Format(format, args))}");
        }

        /// <summary>
        /// Print a message to every players console log
{'fraction_non_alphanumeric': 0.1387800783435926, 'fraction_numerical': 0.0, 'mean_word_length': 1.8265682656826567, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '359893', 'n_tokens_mistral': 1373, 'n_tokens_neox': 1337, 'n_words': 359}