Added a game.user.isFirstGM property

This commit is contained in:
Vlyan
2022-07-18 18:19:47 +02:00
parent d74d91d8b8
commit cf937c4979
6 changed files with 17 additions and 6 deletions

View File

@@ -1,6 +1,10 @@
# Changelog # Changelog
Date format : day/month/year Date format : day/month/year
## 1.9.0 - ??/??/2022 - Foundry v10 Compatibility
- Updated the System to FoundryVTT v10.
- Added a `game.user.isFirstGM` property for some traitements (socket and migration) to prevent multiple executions with multiple GM connected.
## 1.8.2 - 24/06/2022 - Unofficial Italian translation ## 1.8.2 - 24/06/2022 - Unofficial Italian translation
- Added Unofficial Italian translation (Corebook only for compendiums), all thanks to EldritchTranslator. - Added Unofficial Italian translation (Corebook only for compendiums), all thanks to EldritchTranslator.
- Added French translation for Tables. - Added French translation for Tables.

View File

@@ -676,7 +676,7 @@ export class RollnKeepDialog extends FormApplication {
// Delete old chat message related to this series // Delete old chat message related to this series
if (game.settings.get("l5r5e", "rnk-deleteOldMessage")) { if (game.settings.get("l5r5e", "rnk-deleteOldMessage")) {
if (game.user.isGM) { if (game.user.isFirstGM) {
const message = game.messages.get(msgOldId); const message = game.messages.get(msgOldId);
if (message) { if (message) {
message.delete(); message.delete();

View File

@@ -16,6 +16,13 @@ export default class HooksL5r5e {
* Do anything once the system is ready * Do anything once the system is ready
*/ */
static async ready() { static async ready() {
// If multiple GM connected, tag the 1st alive, useful for some traitements
Object.defineProperty(game.user, "isFirstGM", {
get: function () {
return game.user.isGM && game.user.id === game.users.find((u) => u.active && u.isGM)?.id;
},
});
// Migration stuff // Migration stuff
if (game.l5r5e.migrations.needUpdate(game.l5r5e.migrations.NEEDED_VERSION)) { if (game.l5r5e.migrations.needUpdate(game.l5r5e.migrations.NEEDED_VERSION)) {
game.l5r5e.migrations.migrateWorld({ force: false }); game.l5r5e.migrations.migrateWorld({ force: false });

View File

@@ -24,7 +24,7 @@ export class MigrationL5r5e {
* @return {Promise<void>} A Promise which resolves once the migration is completed * @return {Promise<void>} A Promise which resolves once the migration is completed
*/ */
static async migrateWorld(options = { force: false }) { static async migrateWorld(options = { force: false }) {
if (!game.user.isGM) { if (!game.user.isFirstGM) {
return; return;
} }

View File

@@ -44,9 +44,9 @@ export class SocketHandlerL5r5e {
}); });
} }
_onDeleteChatMessage(data) { _onDeleteChatMessage(data) {
// Only delete the message if the user is a GM (otherwise it have no real effect) // Only delete the message if the user is a GM (otherwise it has no real effect)
// Currently only used in RnK // Currently only used in RnK
if (!game.user.isGM || !game.settings.get("l5r5e", "rnk-deleteOldMessage")) { if (!game.user.isFirstGM || !game.settings.get("l5r5e", "rnk-deleteOldMessage")) {
return; return;
} }
const message = game.messages.get(data.messageId); const message = game.messages.get(data.messageId);

View File

@@ -6,8 +6,8 @@
"readme": "https://gitlab.com/teaml5r/l5r5e/-/blob/master/README.md", "readme": "https://gitlab.com/teaml5r/l5r5e/-/blob/master/README.md",
"changelog": "https://gitlab.com/teaml5r/l5r5e/-/blob/master/CHANGELOG.md", "changelog": "https://gitlab.com/teaml5r/l5r5e/-/blob/master/CHANGELOG.md",
"manifest": "https://gitlab.com/teaml5r/l5r5e/-/raw/master/system/system.json", "manifest": "https://gitlab.com/teaml5r/l5r5e/-/raw/master/system/system.json",
"download": "https://gitlab.com/teaml5r/l5r5e/-/jobs/artifacts/v1.8.2/raw/l5r5e.zip?job=build", "download": "https://gitlab.com/teaml5r/l5r5e/-/jobs/artifacts/v1.9.0/raw/l5r5e.zip?job=build",
"version": "1.8.2", "version": "1.9.0",
"minimumCoreVersion": "9", "minimumCoreVersion": "9",
"compatibleCoreVersion": "9", "compatibleCoreVersion": "9",
"manifestPlusVersion": "1.2.0", "manifestPlusVersion": "1.2.0",