Skip to content

Commit

Permalink
apply hotfix for worlds being registered twice when running resetmap …
Browse files Browse the repository at this point in the history
…command
granny committed Jul 24, 2024
1 parent c7ab36a commit d308f70
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@
import net.pl3x.map.core.command.Sender;
import net.pl3x.map.core.command.parser.WorldParser;
import net.pl3x.map.core.configuration.Lang;
import net.pl3x.map.core.log.Logger;
import net.pl3x.map.core.util.FileUtil;
import net.pl3x.map.core.world.World;
import org.incendo.cloud.context.CommandContext;
@@ -63,12 +64,6 @@ private void executeAsync(@NotNull CommandContext<@NotNull Sender> context) {
Sender sender = context.sender();
World world = context.get("world");

// TODO: Look into why it seems to inconsistently initialize the world twice when called as a player :/
if (sender instanceof Sender.Player<?> player) {
sender.sendMessage("<yellow>Resetting the map in-game is temporarily disabled. Please run this command in the console instead.");
return;
}

TagResolver.Single worldPlaceholder = Placeholder.unparsed("world", world.getName());
sender.sendMessage(Lang.COMMAND_RESETMAP_BEGIN, worldPlaceholder);

@@ -86,7 +81,11 @@ private void executeAsync(@NotNull CommandContext<@NotNull Sender> context) {
}

// create a new world and register it
Pl3xMap.api().getWorldRegistry().register(Pl3xMap.api().cloneWorld(world));
// hotfix: only do so if there's no players online. an unloaded world gets registered if a player is found in it.
// UpdateSettingsData#parseSettings->PlayerRegistry#parsePlayers->Player#getWorld
if (world.getPlayers().isEmpty()) {
Pl3xMap.api().getWorldRegistry().register(Pl3xMap.api().cloneWorld(world));
}

sender.sendMessage(result, worldPlaceholder);
});
Original file line number Diff line number Diff line change
@@ -94,6 +94,9 @@ public void cancel() {
if (this.future != null) {
this.future.cancel(true);
}
if (this.executor != null) {
this.executor.shutdownNow();
}
}

public abstract void parse();

0 comments on commit d308f70

Please sign in to comment.