-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPlugin.cs
More file actions
75 lines (67 loc) · 3.26 KB
/
Copy pathPlugin.cs
File metadata and controls
75 lines (67 loc) · 3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using ScarletCore.Commanding;
using ScarletCore.Data;
using ScarletCore.Localization;
using ScarletCore.Services;
namespace ScarletCore;
/// <summary>
/// Main entry point for the ScarletCore BepInEx plugin.
/// </summary>
[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
public class Plugin : BasePlugin {
static Harmony _harmony;
/// <summary>
/// Gets the Harmony instance used for patching.
/// </summary>
public static Harmony Harmony => _harmony;
/// <summary>
/// Gets the singleton instance of the plugin.
/// </summary>
public static Plugin Instance { get; private set; }
/// <summary>
/// Gets the log source for plugin logging.
/// </summary>
public static ManualLogSource LogInstance { get; private set; }
/// <summary>
/// Gets the plugin settings instance.
/// </summary>
public static Settings Settings { get; private set; }
/// <summary>
/// Gets the plugin database instance.
/// </summary>
public static Database Database { get; private set; }
/// <summary>
/// Called by BepInEx to load and initialize the plugin.
/// </summary>
public override void Load() {
Instance = this;
LogInstance = Log;
Log.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} version {MyPluginInfo.PLUGIN_VERSION} is loaded!");
_harmony = new Harmony(MyPluginInfo.PLUGIN_GUID);
_harmony.PatchAll(System.Reflection.Assembly.GetExecutingAssembly());
Settings = new Settings(MyPluginInfo.PLUGIN_NAME, Instance);
Database = new Database(MyPluginInfo.PLUGIN_NAME);
Settings.Section("Roles")
.Add("Owners", "", "Comma-separated list of Steam64 IDs for server owners with all permissions.");
Settings.Section("Language")
.Add("PrefabLocalizationLanguage", Language.English, $"Language code for localization. Available languages: {string.Join(", ", Localizer.AvailableServerLanguages)}")
.Add("DefaultPlayerLanguage", Language.English, $"Default language code for new players. Available languages: {string.Join(", ", Localizer.AvailableServerLanguages)}")
.Add("DisableLanguageSelectionPrompt", false, "If true, players will not be prompted to select a language on first join.")
.Add("WelcomeMessage", "~Welcome to {ServerName}!~\n\nThis server uses ~ScarletMods~ to enhance your experience.\n\nTo get started, please set ~your preferred language~:\n\n{AvailableLanguages}\nUse: ~.language <language>~", "Welcome message shown to players who haven't set their language. Placeholders: {ServerName}, {AvailableLanguages}, {PlayerName}")
.Add("LanguageReminderMessage", "~Hey {PlayerName}!~ You haven't set your language yet.\n\nAvailable languages: {AvailableLanguages}\nUse: ~.language <language>~", "Reminder message sent every 10 minutes to online players who haven't set their language. Placeholders: {ServerName}, {AvailableLanguages}, {PlayerName}");
Localizer.Initialize();
CommandHandler.Initialize();
}
/// <summary>
/// Called by BepInEx to unload and clean up the plugin.
/// </summary>
/// <returns>True if the plugin was unloaded successfully.</returns>
public override bool Unload() {
_harmony?.UnpatchSelf();
SharedDatabase.Shutdown();
return true;
}
}