internal void Initialize() { try { Settings = new XMLFileAsset <UnturnedSettings>(Environment.SettingsFile); Translation = new XMLFileAsset <TranslationList>(String.Format(Environment.TranslationFile, Core.R.Settings.Instance.LanguageCode), new Type[] { typeof(TranslationList), typeof(TranslationListEntry) }, defaultTranslations); defaultTranslations.AddUnknownEntries(Translation); Events = gameObject.TryAddComponent <UnturnedEvents>(); gameObject.TryAddComponent <UnturnedPermissions>(); gameObject.TryAddComponent <UnturnedChat>(); gameObject.TryAddComponent <UnturnedCommands>(); gameObject.TryAddComponent <AutomaticSaveWatchdog>(); bindDelegates(); RocketPlugin.OnPluginLoading += (IRocketPlugin plugin, ref bool cancelLoading) => { try { plugin.TryAddComponent <PluginUnturnedPlayerComponentManager>(); } catch (Exception ex) { Core.Logging.Logger.LogException(ex, "Failed to load plugin " + plugin.Name + "."); cancelLoading = true; } }; RocketPlugin.OnPluginUnloading += (IRocketPlugin plugin) => { plugin.TryRemoveComponent <PluginUnturnedPlayerComponentManager>(); }; R.Commands.RegisterFromAssembly(Assembly.GetExecutingAssembly()); try { R.Plugins.OnPluginsLoaded += () => { SteamGameServer.SetKeyValue("rocketplugins", String.Join(",", R.Plugins.GetPlugins().Select(p => p.Name).ToArray())); }; SteamGameServer.SetKeyValue("rocket", Assembly.GetExecutingAssembly().GetName().Version.ToString()); SteamGameServer.SetBotPlayerCount(1); } catch (Exception ex) { Core.Logging.Logger.LogError("Steam can not be initialized: " + ex.Message); } OnRocketImplementationInitialized.TryInvoke(); } catch (Exception ex) { Core.Logging.Logger.LogException(ex); } }
public static void Init() { Translations = new JsonFileAsset <Translation>(ModuleEnvironment.TranslationFile); ModuleTranslation.FillTranslation(Translations); Permissions = new JsonFileAsset <ModulePermission>(ModuleEnvironment.PermissionFile); Commands = new JsonFileAsset <ModuleCommand>(ModuleEnvironment.CommandsFile); Settings = new JsonFileAsset <ModuleSettings>(ModuleEnvironment.SettingsFile); PermissionManager.Init(Permissions); CommandManager.Init(Commands); SettingsManager.Init(Settings); UnturnedEvents.Init(); UnturnedChatManager.Init(); }
internal void Initialize() { try { Settings = new XMLFileAsset <UnturnedSettings>(Environment.SettingsFile); Translation = new XMLFileAsset <TranslationList>(String.Format(Environment.TranslationFile, Core.R.Settings.Instance.LanguageCode), new Type[] { typeof(TranslationList), typeof(TranslationListEntry) }, defaultTranslations); defaultTranslations.AddUnknownEntries(Translation); Events = gameObject.TryAddComponent <UnturnedEvents>(); gameObject.TryAddComponent <UnturnedPermissions>(); gameObject.TryAddComponent <UnturnedChat>(); gameObject.TryAddComponent <UnturnedCommands>(); gameObject.TryAddComponent <AutomaticSaveWatchdog>(); bindDelegates(); RocketPlugin.OnPluginLoading += (IRocketPlugin plugin, ref bool cancelLoading) => { try { plugin.TryAddComponent <PluginUnturnedPlayerComponentManager>(); } catch (Exception ex) { Core.Logging.Logger.LogException(ex, "Failed to load plugin " + plugin.Name + "."); cancelLoading = true; } }; RocketPlugin.OnPluginUnloading += (IRocketPlugin plugin) => { plugin.TryRemoveComponent <PluginUnturnedPlayerComponentManager>(); }; R.Commands.RegisterFromAssembly(Assembly.GetExecutingAssembly()); try { R.Plugins.OnPluginsLoaded += () => { IPluginAdvertising pluginAdvertising = PluginAdvertising.Get(); List <IRocketPlugin> rocketPlugins = R.Plugins.GetPlugins(); List <string> pluginNames = new List <string>(rocketPlugins.Count); foreach (IRocketPlugin plugin in rocketPlugins) { if (plugin != null && !string.IsNullOrEmpty(plugin.Name)) { pluginNames.Add(plugin.Name); } } pluginAdvertising.AddPlugins(pluginNames); }; SteamGameServer.SetKeyValue("unturned", Provider.APP_VERSION); SteamGameServer.SetKeyValue("rocket", Assembly.GetExecutingAssembly().GetName().Version.ToString()); } catch (Exception ex) { Core.Logging.Logger.LogError("Steam can not be initialized: " + ex.Message); } OnRocketImplementationInitialized.TryInvoke(); } catch (Exception ex) { Core.Logging.Logger.LogException(ex); } }
internal void Initialize() { try { Settings = new XMLFileAsset <UnturnedSettings>(Environment.SettingsFile); Translation = new XMLFileAsset <TranslationList>(string.Format(Environment.TranslationFile, Core.R.Settings.Instance.LanguageCode), new Type[] { typeof(TranslationList), typeof(TranslationListEntry) }, defaultTranslations); defaultTranslations.AddUnknownEntries(Translation); //Events = gameObject.TryAddComponent<UnturnedEvents>(); Events = new UnturnedEvents(); Events.Awake(); //gameObject.TryAddComponent<UnturnedPermissions>(); //gameObject.TryAddComponent<UnturnedChat>(); SDG.Unturned.ChatManager.onChatted += UnturnedChat.handleChat; //gameObject.TryAddComponent<UnturnedCommands>(); foreach (Command vanillaCommand in Commander.commands) { R.Commands.Register(new UnturnedCommands.UnturnedVanillaCommand(vanillaCommand), vanillaCommand.command.ToLower(), Core.Serialization.CommandPriority.Low); } gameObject.TryAddComponent <AutomaticSaveWatchdog>(); bindDelegates(); RocketPlugin.OnPluginLoading += (IRocketPlugin plugin, ref bool cancelLoading) => { try { plugin.TryAddComponent <PluginUnturnedPlayerComponentManager>(); } catch (Exception ex) { Core.Logging.Logger.LogException(ex, "Failed to load plugin " + plugin.Name + "."); cancelLoading = true; } }; RocketPlugin.OnPluginUnloading += (IRocketPlugin plugin) => { plugin.TryRemoveComponent <PluginUnturnedPlayerComponentManager>(); }; R.Commands.RegisterFromAssembly(Assembly.GetExecutingAssembly()); try { if (!Settings.Instance.HidePlugins) { R.Plugins.OnPluginsLoaded += () => { var plugs = R.Plugins.GetPlugins(); var names = new string[plugs.Count]; for (int i = 0; i < names.Length; i++) { names[i] = plugs[i].Name; } SteamGameServer.SetKeyValue("rocketplugins", string.Join(",", names)); }; } if (Settings.Instance.ClampMaxPlayers) { Level.onPreLevelLoaded += ClampMaxPlayers; } SteamGameServer.SetKeyValue("unturned", Provider.APP_VERSION); SteamGameServer.SetKeyValue("rocket", Assembly.GetExecutingAssembly().GetName().Version.ToString()); SteamGameServer.SetBotPlayerCount(1); } catch (Exception ex) { Core.Logging.Logger.LogError("Steam can not be initialized: " + ex.Message); } OnRocketImplementationInitialized.TryInvoke(); } catch (Exception ex) { Core.Logging.Logger.LogException(ex); } }