Skip to content

Commit

Permalink
Fix /reload not handling dialogue additions or removals
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrofab committed Feb 12, 2024
1 parent 75d22df commit bbf46a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public final class BlabberRegistrar implements EntityComponentInitializer {
).buildAndRegister();
public static final SuggestionProvider<ServerCommandSource> ALL_DIALOGUES = SuggestionProviders.register(
Blabber.id("available_dialogues"),
(context, builder) -> CommandSource.suggestIdentifiers(DialogueRegistry.getIds(), builder)
(context, builder) -> CommandSource.suggestIdentifiers(context.getSource() instanceof ServerCommandSource ? DialogueRegistry.getIds() : DialogueRegistry.getClientIds(), builder)
);

public static void init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import net.minecraft.util.Identifier;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.ladysnake.blabber.impl.common.model.DialogueTemplate;

import java.util.Map;
Expand All @@ -37,11 +36,15 @@
*/

public final class DialogueRegistry {
private static @Nullable Set<Identifier> clientDialogueIds = null;
private static Set<Identifier> clientDialogueIds = Set.of();
private static Map<Identifier, DialogueTemplate> entries = Map.of();

public static Set<Identifier> getClientIds() {
return clientDialogueIds;
}

public static Set<Identifier> getIds() {
return clientDialogueIds == null ? entries.keySet() : clientDialogueIds;
return entries.keySet();
}

public static Optional<DialogueTemplate> getOrEmpty(Identifier id) {
Expand All @@ -57,7 +60,7 @@ static void setEntries(Map<Identifier, DialogueTemplate> newEntries) {
}

@ApiStatus.Internal // highly internal
public static void setClientIds(@Nullable Set<Identifier> dialogueIds) {
public static void setClientIds(Set<Identifier> dialogueIds) {
clientDialogueIds = dialogueIds;
}
}

0 comments on commit bbf46a2

Please sign in to comment.