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

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

View File

@@ -16,6 +16,13 @@ export default class HooksL5r5e {
* Do anything once the system is 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
if (game.l5r5e.migrations.needUpdate(game.l5r5e.migrations.NEEDED_VERSION)) {
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
*/
static async migrateWorld(options = { force: false }) {
if (!game.user.isGM) {
if (!game.user.isFirstGM) {
return;
}

View File

@@ -44,9 +44,9 @@ export class SocketHandlerL5r5e {
});
}
_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
if (!game.user.isGM || !game.settings.get("l5r5e", "rnk-deleteOldMessage")) {
if (!game.user.isFirstGM || !game.settings.get("l5r5e", "rnk-deleteOldMessage")) {
return;
}
const message = game.messages.get(data.messageId);