Иконка ресурса

FREE EncryptionFix : 1.0.0 1.0.0

Нет прав для скачивания
C#:
//Reference: 0Harmony

using System;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using HarmonyLib;
using Network;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("EncryptionFix", "Farkas", "1.0.0")]
    [Description("Decreases the encryption level for admins to 1")]
    public class EncryptionFix : RustPlugin
    {
        private Harmony _harmony;

        private void Init()
        {
            _harmony = new Harmony(Name + "Patches");
            _harmony.Patch(AccessTools.Method(typeof(ServerMgr), "JoinGame"),
                transpiler: new HarmonyMethod(typeof(ServerMgr_JoinGame), nameof(ServerMgr_JoinGame.Transpiler)));
        }

        private void Unload()
        {
            _harmony?.UnpatchAll(_harmony.Id);
        }
        
        private static class ServerMgr_JoinGame
        {
            internal static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
            {
                List<CodeInstruction> list = new List<CodeInstruction>(instructions);

                int index = list.FindIndex(x =>
                    x.opcode == OpCodes.Ldsfld && ((FieldInfo)x.operand).Name == "encryption");

                if (index == -1 || list[index + 1].opcode != OpCodes.Stloc_1)
                {
                    Debug.LogError("[EncryptionFix] Failed to patch encryption! Please update the plugin.");
                    return list;
                }

                list.InsertRange(index + 2, new List<CodeInstruction>
                {
                    new CodeInstruction(OpCodes.Ldloca_S, 1), // uint num
                    new CodeInstruction(OpCodes.Ldarg_1), // Connection connection
                    new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(ServerMgr_JoinGame), nameof(FixEncryptionLevel)))
                });

                return list;
            }

            private static void FixEncryptionLevel(ref uint encryptionLevel, Connection connection)
            {
                if (encryptionLevel > 1 && connection.authLevel > 0)
                {
                    encryptionLevel = 1;
                }
            }
        }
    }
}

Автор
15FPS
Скачиваний
0
Просмотры
1
Первый выпуск
Обновление
Оценка
0.00 звёзд 0 оценок
Сверху