Skip to content

Commit 2506dec

Browse files
authored
Merge pull request #620 from Multiverse/feat/conflict-checking
Improve group conflict checking api and apply to all group modify commands
2 parents 969941f + efbebae commit 2506dec

17 files changed

+186
-55
lines changed

src/main/java/org/mvplugins/multiverse/inventories/MultiverseInventories.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ public void reloadConfig() {
261261

262262
inventoriesConfig.get().setFirstRun(false);
263263
}
264-
worldGroupManager.get().checkForConflicts(null);
264+
worldGroupManager.get().checkForConflicts()
265+
.sendConflictIssue(commandManagerProvider.get().getConsoleCommandIssuer());
265266
}, 1L);
266267
}
267268
}

src/main/java/org/mvplugins/multiverse/inventories/commands/AddDisabledSharesCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@ void onAddDisabledSharesCommand(
4949
issuer.sendInfo(MVInvi18n.DISABLEDSHARES_NOWSHARING,
5050
replace("{group}").with(group.getName()),
5151
replace("{shares}").with(group.getDisabledShares().toStringList()));
52+
worldGroupManager.checkForConflicts().sendConflictIssue(issuer);
5253
}
5354
}

src/main/java/org/mvplugins/multiverse/inventories/commands/AddSharesCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,6 @@ void onAddSharesCommand(
5454
replace("{group}").with(group.getName()),
5555
replace("{shares}").with(group.getShares().toStringList()),
5656
replace("{negativeshares}").with(negativeshares.toStringList()));
57+
worldGroupManager.checkForConflicts().sendConflictIssue(issuer);
5758
}
5859
}

src/main/java/org/mvplugins/multiverse/inventories/commands/AddWorldsCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ void onAddWorldCommand(
8686
issuer.sendInfo(MVInvi18n.ADDWORLD_WORLDADDED,
8787
replace("{group}").with(group.getName()),
8888
replace("{world}").with(worldNamesString));
89+
worldGroupManager.checkForConflicts().sendConflictIssue(issuer);
8990
}
9091

9192
@Service
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package org.mvplugins.multiverse.inventories.commands;
2+
3+
import org.jvnet.hk2.annotations.Service;
4+
import org.mvplugins.multiverse.core.command.MVCommandIssuer;
5+
import org.mvplugins.multiverse.external.acf.commands.annotation.CommandPermission;
6+
import org.mvplugins.multiverse.external.acf.commands.annotation.Description;
7+
import org.mvplugins.multiverse.external.acf.commands.annotation.Subcommand;
8+
import org.mvplugins.multiverse.external.jakarta.inject.Inject;
9+
import org.mvplugins.multiverse.external.jetbrains.annotations.NotNull;
10+
import org.mvplugins.multiverse.inventories.profile.group.GroupingConflictResult;
11+
import org.mvplugins.multiverse.inventories.profile.group.WorldGroupManager;
12+
import org.mvplugins.multiverse.inventories.util.MVInvi18n;
13+
14+
@Service
15+
final class CheckGroupConflictsCommand extends InventoriesCommand {
16+
private final WorldGroupManager worldGroupManager;
17+
18+
@Inject
19+
CheckGroupConflictsCommand(@NotNull WorldGroupManager worldGroupManager) {
20+
this.worldGroupManager = worldGroupManager;
21+
}
22+
23+
@Subcommand("check-group-conflicts")
24+
@CommandPermission("multiverse.inventories.checkgroupconflict")
25+
@Description("Check for conflicts in World Groups.")
26+
void onCommand(@NotNull MVCommandIssuer issuer) {
27+
issuer.sendInfo(MVInvi18n.CONFLICT_CHECKING);
28+
GroupingConflictResult groupingConflictResult = worldGroupManager.checkForConflicts();
29+
if (groupingConflictResult.hasConflict()) {
30+
groupingConflictResult.sendConflictIssue(issuer);
31+
} else {
32+
issuer.sendInfo(MVInvi18n.CONFLICT_NOTFOUND);
33+
}
34+
}
35+
}

src/main/java/org/mvplugins/multiverse/inventories/commands/CreateGroupCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,6 @@ void onCreateGroupCommand(
6262
issuer.sendInfo(MVInvi18n.GROUP_CREATIONCOMPLETE, replace("{group}").with(groupName));
6363
issuer.sendInfo(MVInvi18n.INFO_GROUP_INFO, replace("{worlds}").with(worldGroup.getConfigWorlds()));
6464
issuer.sendInfo(MVInvi18n.INFO_GROUP_INFOSHARES, replace("{shares}").with(worldGroup.getShares()));
65+
worldGroupManager.checkForConflicts().sendConflictIssue(issuer);
6566
}
6667
}

src/main/java/org/mvplugins/multiverse/inventories/commands/DeleteGroupCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ void onDeleteGroupCommand(
4949
commandQueueManager.addToQueue(CommandQueuePayload.issuer(issuer)
5050
.prompt(Message.of(MVInvi18n.DELETEGROUP_CONFIRMPROMPT, replace("{group}").with(group.getName())))
5151
.action(() -> doDeleteGroup(issuer, group)));
52+
worldGroupManager.checkForConflicts().sendConflictIssue(issuer);
5253
}
5354

5455
private void doDeleteGroup(MVCommandIssuer issuer, WorldGroup group) {

src/main/java/org/mvplugins/multiverse/inventories/commands/RemoveDisabledSharesCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@ void onRemoveSharesCommand(
4949
issuer.sendInfo(MVInvi18n.DISABLEDSHARES_NOWSHARING,
5050
replace("{group}").with(group.getName()),
5151
replace("{shares}").with(group.getDisabledShares().toStringList()));
52+
worldGroupManager.checkForConflicts().sendConflictIssue(issuer);
5253
}
5354
}

src/main/java/org/mvplugins/multiverse/inventories/commands/RemoveSharesCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,6 @@ void onRemoveSharesCommand(
5252
replace("{group}").with(group.getName()),
5353
replace("{shares}").with(group.getShares().toStringList()),
5454
replace("{negativeshares}").with(negativeshares.toStringList()));
55+
worldGroupManager.checkForConflicts().sendConflictIssue(issuer);
5556
}
5657
}

src/main/java/org/mvplugins/multiverse/inventories/commands/RemoveWorldsCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,6 @@ void onRemoveWorldCommand(
5858
issuer.sendInfo(MVInvi18n.REMOVEWORLD_WORLDREMOVED,
5959
replace("{group}").with(group.getName()),
6060
replace("{world}").with(worldNames));
61+
worldGroupManager.checkForConflicts().sendConflictIssue(issuer);
6162
}
6263
}

0 commit comments

Comments
 (0)