• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ

よく使われているワード(クリックで追加)

javaandroidc++linuxc#objective-ccocoa誰得qtrubybathyscaphegamephpguiwindowsc翻訳pythonomegattwitterframeworkbtronarduinovb.net計画中(planning stage)directxpreviewertestゲームエンジンdom

Administrator's Toolkit VS plugin


コミットメタ情報

リビジョン8fd88dcb4ab0a1fe38b74b43b44c7c57d2795260 (tree)
日時2019-08-31 05:45:50
作者melchior <melchior@user...>
コミッターmelchior

ログメッセージ

Enabled multi-lingual Rules text support,
Game time elapsed message for players joining,
Version bump & V1.10 API update (lang code)

変更サマリ

差分

--- a/AdminToolkit/AdminToolkitMod.cs
+++ b/AdminToolkit/AdminToolkitMod.cs
@@ -22,6 +22,7 @@ namespace AdminToolkit
2222 * Server RULES Printout {richtext / multi-linugual }
2323 * Optional: ACCEPTANCE / REJECT of server rules {changes players role}
2424 * List all Admins (online or offline) & track last logoff date
25+ * Keeps track of Elapsed game calendar days for players
2526 * { Alter ADMIN text to look 'different' }
2627 * Cyclic automatic Backups
2728 */
@@ -51,6 +52,7 @@ namespace AdminToolkit
5152 };
5253
5354 internal const string _lastLoginKey = @"LastLogin";
55+ internal const string _lastGameDayCountKey = @"LastDayCount";
5456 internal const string _configFilename = @"admintoolkit.json";
5557
5658 internal static List<string> AdminRoles;
@@ -97,7 +99,7 @@ namespace AdminToolkit
9799 if (CachedConfiguration.BoomingVoice) {
98100 this.ServerAPI.Event.PlayerChat += BoomingVoiceOfAuthority;
99101 }
100-
102+ //TODO: Server MOTD / Name, DYNAMIC status info [season, moon-phase, events... ect]
101103
102104 this.ServerAPI.Event.ServerRunPhase(EnumServerRunPhase.Shutdown, SaveConfigSettings);
103105 }
--- a/AdminToolkit/Commands/RulesCommand.cs
+++ b/AdminToolkit/Commands/RulesCommand.cs
@@ -42,10 +42,10 @@ namespace AdminToolkit
4242 Rules = new Dictionary<string, List<string>>( );
4343 RulesPath = ServerAPI.GetOrCreateDataPath(_rulesPathKey);
4444
45- string[] lang_codes = { "en", /*"fr", "es", "de", "ru", "kr" */};//FIXME: this should not be hardcoded
45+ string[] lang_codes = { "en", "de", "it", "fr", "pt-br", "ru" };//FIXME: this should extracted from language codes
4646
4747 foreach (var languageCode in lang_codes) {
48- //For each locale that is configured... get/create rules.txt
48+ //For each locale that is configured... get rules_?.txt
4949 string rulesFilePath = Path.Combine(RulesPath, $"rules_{languageCode}.txt");
5050 if (File.Exists(rulesFilePath)) {
5151 using (var ruleFileStream = File.OpenRead(rulesFilePath)) {
@@ -68,7 +68,7 @@ namespace AdminToolkit
6868 ruleReader.Close( );
6969 }
7070 } else {
71- Logger.Error("Non existant '{0}' file for Rules-text!!!", $"rules_{languageCode}.txt");
71+ Logger.Warning("Non existant '{0}' file for Rules-text", $"rules_{languageCode}.txt");
7272 }
7373 }
7474 }
@@ -114,23 +114,6 @@ namespace AdminToolkit
114114 if (args.Length == 1) {
115115 string word = args.PopWord( );
116116
117- /*
118- #if DEBUG
119- if (string.Compare("demote", word, StringComparison.InvariantCultureIgnoreCase) == 0)
120- {
121- IPlayerRole restrainRole = ServerAPI.Server.Config.Roles.Single(rl => string.Compare(rl.Code, this.CachedConfiguration.PlayerRoleRestrain, StringComparison.InvariantCultureIgnoreCase) == 0);
122- player.SendMessage(groupId, $"{player.PlayerName} was demoted", EnumChatType.CommandSuccess);
123- ServerAPI.Permissions.SetRole(player, restrainRole.Code);
124- }
125-
126- if (string.Compare("promote", word, StringComparison.InvariantCultureIgnoreCase) == 0) {
127- IPlayerRole normalRole = ServerAPI.Server.Config.Roles.Single(rl => string.Compare(rl.Code, this.CachedConfiguration.PlayerRoleNormal, StringComparison.InvariantCultureIgnoreCase) == 0);
128- player.SendMessage(groupId, $"{player.PlayerName} was promoted", EnumChatType.CommandSuccess);
129- ServerAPI.Permissions.SetRole(player, normalRole.Code);
130- }
131- #endif
132- */
133-
134117 if (string.Compare(_acceptKeyword, word, StringComparison.InvariantCultureIgnoreCase) == 0) {
135118
136119 if (CheckRuleAccepted(player) == false) {
@@ -144,7 +127,7 @@ namespace AdminToolkit
144127 }
145128
146129 } else {
147- var targetLocale = "en";//TODO: actually get locale!
130+ var targetLocale = player.LanguageCode;
148131
149132 if (Rules.ContainsKey(targetLocale)) {
150133
@@ -153,15 +136,16 @@ namespace AdminToolkit
153136 player.SendMessage(groupId, line, EnumChatType.OthersMessage);
154137 }
155138 } else {
156- player.SendMessage(groupId, "* MISSING RULES FILE ! *", EnumChatType.CommandError);
139+ //Subsitute rules?
140+ player.SendMessage(groupId, $"* MISSING RULES FILE ({targetLocale})! *", EnumChatType.CommandError);
157141 }
158142 }
159143 }
160144
161- /// <summary>
162- /// Send Rule info text or Admin welcome
163- /// </summary>
164- /// <param name="byPlayer">By player.</param>
145+ /// <summary>
146+ /// Send Rule info text or Admin welcome, plus other info
147+ /// </summary>
148+ /// <param name="byPlayer">By player.</param>
165149 private void UponJoin(IServerPlayer byPlayer)
166150 {
167151 if (AdminToolkit.AdminRoles.Contains(byPlayer.Role.Code)) {
@@ -174,11 +158,10 @@ namespace AdminToolkit
174158 ServerAPI.SendMessageToGroup(GlobalConstants.AllChatGroups, adminMessage.ToString( ), EnumChatType.AllGroups);
175159
176160 byPlayer.ServerData.CustomPlayerData[AdminToolkit._lastLoginKey] = DateTimeOffset.UtcNow.ToString("u");
177-
178161 } else {
179162 //For regular players
180163 if (RulesCommand.CheckRuleAccepted(byPlayer) == false) {
181- //TODO: localize somehow?
164+ //TODO: localize
182165 byPlayer.SendMessage(GlobalConstants.CurrentChatGroup, "type ' /rules ' command for reading server rules.", EnumChatType.Notification);
183166
184167 if (this.CachedConfiguration.RuleRoleChangerEnabled) {
@@ -186,6 +169,22 @@ namespace AdminToolkit
186169 }
187170 }
188171 }
172+
173+ double elapsedDays = 0D;
174+ string elapsedDayStr;
175+
176+ if (byPlayer.ServerData.CustomPlayerData.TryGetValue(AdminToolkit._lastGameDayCountKey, out elapsedDayStr)
177+ &&
178+ double.TryParse(elapsedDayStr, out elapsedDays))
179+ {
180+ elapsedDays = ServerAPI.World.Calendar.TotalDays - elapsedDays;
181+ byPlayer.SendMessage(GlobalConstants.CurrentChatGroup, $"Meantime... {elapsedDays.ToString("F1")} days have passed. ", EnumChatType.OthersMessage);
182+ } else
183+ {
184+ byPlayer.SendMessage(GlobalConstants.CurrentChatGroup, $"In the year; {ServerAPI.World.Calendar.PrettyDate( )}", EnumChatType.OthersMessage);
185+ }
186+
187+ byPlayer.ServerData.CustomPlayerData[AdminToolkit._lastGameDayCountKey] = ServerAPI.World.Calendar.TotalDays.ToString("R");
189188 }
190189
191190 private void PlayerAcceptsRulesAction(IServerPlayer byPlayer )
--- a/AdminToolkit/MechTurk.cs
+++ b/AdminToolkit/MechTurk.cs
@@ -81,6 +81,12 @@ namespace AdminToolkit
8181 }
8282 }
8383
84+ public string LanguageCode {
85+ get {
86+ return @"en";//ISO639-2 ?
87+ }
88+ }
89+
8490 public float Ping {
8591 get {
8692 return 0.0f;
--- a/AdminToolkit/modinfo.json
+++ b/AdminToolkit/modinfo.json
@@ -1,9 +1,9 @@
11 {
22 "type": "code",
33 "name": "Administrator's Toolkit mod",
4- "description" : "Provides misc. Admin functions;\n list admins, print & accept rules , auto-backup...",
4+ "description" : "Provides misc. Admin functions;\n list admins, print & accept rules (multi-lingual) , auto-backup...",
55 "authors": ["Melchior", ],
6- "version": "0.3.1",
6+ "version": "0.3.2",
77 "dependencies": {
88 "game": "1.10.0"
99 },