Esempio n. 1
0
        public async Task PerformHardReloadAsync()
        {
            var shutdownPerformed = false;

            try
            {
                await m_Runtime.ShutdownAsync();

                shutdownPerformed = true;
                m_NuGetPackageManager.ClearCache();

                var bootstrapperAssembly = AppDomain.CurrentDomain.GetAssemblies()
                                           .FirstOrDefault(d => d.GetName().Name.Equals("OpenMod.Unturned.Module.Bootstrapper"));

                var bootstrapperClass = bootstrapperAssembly !.GetType("OpenMod.Unturned.Module.Bootstrapper.BootstrapperModule");
                var instanceProperty  = bootstrapperClass.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static);
                var initializeMethod  = bootstrapperClass.GetMethod("initialize", BindingFlags.Instance | BindingFlags.Public);
                var moduleInstance    = instanceProperty !.GetValue(null);

                initializeMethod !.Invoke(moduleInstance, new object[0]);
            }
            catch (Exception ex)
            {
                if (shutdownPerformed)
                {
                    // fallback to unturned log because our logger is disposed at this point
                    UnturnedLog.exception(ex, "OpenMod has crashed.");
                }

                throw;
            }
        }
Esempio n. 2
0
        public static void checkBanStatus(SteamPlayerID playerID, uint remoteIP, out bool isBanned, out string banReason, out uint banRemainingDuration)
        {
            isBanned             = false;
            banReason            = string.Empty;
            banRemainingDuration = 0U;
            if (SteamBlacklist.checkBanned(playerID.steamID, remoteIP, out SteamBlacklistID steamBlacklistID))
            {
                isBanned             = true;
                banReason            = steamBlacklistID.reason;
                banRemainingDuration = steamBlacklistID.getTime();
            }

            try
            {
                Provider.onCheckBanStatusWithHWID?.Invoke(playerID, remoteIP, ref isBanned, ref banReason, ref banRemainingDuration);

#pragma warning disable CS0612 // Type or member is obsolete
                Provider.onCheckBanStatus?.Invoke(playerID.steamID, remoteIP, ref isBanned, ref banReason, ref banRemainingDuration);
#pragma warning restore CS0612 // Type or member is obsolete
            }
            catch (Exception e)
            {
                UnturnedLog.warn("Plugin raised an exception from onCheckBanStatus:");
                UnturnedLog.exception(e);
            }
        }
Esempio n. 3
0
        private IEnumerator KickTimer(CSteamID id)
        {
            yield return(new WaitForSeconds(Config.KickDummyAfterSeconds));

            UnturnedLog.info($"Kicking a dummy {id}");
            Provider.kick(id, "");
        }
Esempio n. 4
0
 protected void OnEnable()
 {
     interactable = gameObject.GetComponentInParent <InteractableObjectBinaryState>();
     if (interactable == null)
     {
         UnturnedLog.warn("{0} unable to find interactable", name);
     }
     else
     {
         interactable.onUsedChanged += onUsedChanged;
         ++interactable.modHookCounter;
         onUsedChanged(interactable.isUsed);
     }
 }
Esempio n. 5
0
        protected void OnEnable()
        {
#if GAME
            if (System.Guid.TryParse(WeatherAssetGuid, out parsedGuid))
            {
                WeatherEventListenerManager.addListener(parsedGuid, this);
            }
            else
            {
                parsedGuid = System.Guid.Empty;
                UnturnedLog.warn("{0} unable to parse weather asset guid", transform.GetSceneHierarchyPath());
            }
#endif
        }
        protected void OnEnable()
        {
            if (Provider.isServer == false)
            {
                // Only server has full chat information.
                return;
            }

            if (string.IsNullOrWhiteSpace(Phrase))
            {
                UnturnedLog.warn("{0} phrase is empty", name);
                return;
            }

            if (isListening == false)
            {
                ChatManager.onChatted += onChatted;
                isListening            = true;
            }
        }
Esempio n. 7
0
        public async Task PerformHardReloadAsync()
        {
            var shutdownPerformed = false;

            try
            {
                await m_Runtime.ShutdownAsync();

                shutdownPerformed = true;
                m_NuGetPackageManager.ClearCache();

                BootstrapperModule.Instance !.initialize();
            }
            catch (Exception ex)
            {
                if (shutdownPerformed)
                {
                    // fallback to unturned log because our logger is disposed at this point
                    UnturnedLog.exception(ex, "OpenMod has crashed.");
                }

                throw;
            }
        }