Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions core/src/main/java/org/geysermc/geyser/GeyserImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
import org.geysermc.geyser.level.WorldManager;
import org.geysermc.geyser.network.GameProtocol;
import org.geysermc.geyser.network.netty.GeyserServer;
import org.geysermc.geyser.pack.SkullResourcePackManager;
import org.geysermc.geyser.ping.GeyserLegacyPingPassthrough;
import org.geysermc.geyser.registry.BlockRegistries;
import org.geysermc.geyser.registry.Registries;
Expand Down Expand Up @@ -305,6 +306,10 @@ private void startInstance() {
if (isReloading) {
// If we're reloading, the default locale in the config might have changed.
GeyserLocale.finalizeDefaultLocale(this);

Registries.load();
BlockRegistries.populate();
Registries.populate();
} else {
CodeOfConductManager.load();
}
Expand Down Expand Up @@ -777,6 +782,11 @@ public void reloadGeyser() {
this.eventBus.fire(new GeyserPreReloadEvent(this.extensionManager, this.eventBus));

bootstrap.onGeyserDisable();

BlockRegistries.reset();
Registries.reset();
SkullResourcePackManager.SKULL_SKINS.clear();

bootstrap.onGeyserEnable();

isReloading = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.registry.loader.RegistryLoader;

import java.util.Arrays;
import java.util.function.Supplier;

/**
Expand Down Expand Up @@ -148,4 +149,9 @@ public static <I, M> ArrayRegistry<M> create(RegistryLoader<I, M[]> registryLoad
public static <I, M> ArrayRegistry<M> create(I input, RegistryLoader<I, M[]> registryLoader) {
return new ArrayRegistry<>(input, registryLoader);
}

@Override
public void clear() {
Arrays.fill(this.mappings, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,21 @@ public static void populate() {
BlockRegistryPopulator.populate(BlockRegistryPopulator.Stage.INIT_BEDROCK);
BlockRegistryPopulator.populate(BlockRegistryPopulator.Stage.POST_INIT);
}

public static void reset() {
BLOCKS.clear();
JAVA_BLOCK_STATE_IDENTIFIER_TO_ID.clear();
NON_VANILLA_BLOCK_IDS.clear();
WATERLOGGED.clear();
INTERACTIVE.clear();
INTERACTIVE_MAY_BUILD.clear();
CUSTOM_BLOCKS.clear();
CUSTOM_BLOCK_STATE_OVERRIDES.clear();
NON_VANILLA_BLOCK_STATE_OVERRIDES.clear();
CUSTOM_BLOCK_ITEM_OVERRIDES.clear();
EXTENDED_COLLISION_BOXES.clear();
CUSTOM_SKULLS.clear();

COLLISIONS.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ public boolean loaded() {
return this.loaded;
}

@Override
public void clear() {
if (!this.loaded) {
return;
}
this.backingRegistry.clear();
}

/**
* A registry initializer.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,12 @@ interface IRegistry<M> {
* @param consumer the consumer
*/
void register(Consumer<M> consumer);

/**
* Clears The Underlying Mappings.
* Throws {@link UnsupportedOperationException} When The Registry Doesn't Support It.
Comment on lines +62 to +63
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect capitalization in Javadoc. Standard Javadoc style uses sentence case, not title case. Should be "Clears the underlying mappings" and "Throws {@link UnsupportedOperationException} when the registry doesn't support it."

Suggested change
* Clears The Underlying Mappings.
* Throws {@link UnsupportedOperationException} When The Registry Doesn't Support It.
* Clears the underlying mappings.
* Throws {@link UnsupportedOperationException} when the registry doesn't support it.

Copilot uses AI. Check for mistakes.
*/
default void clear() {
throw new UnsupportedOperationException("Registry does not support clear.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,14 @@ public static void load() {
DANGEROUS_ENTITIES.load();
}

public static void reset() {
loaded = false;

ITEMS.clear();
TAGS.clear();
POTION_MIXES.clear();
}

public static void populate() {
PacketRegistryPopulator.populate();
DataComponentRegistryPopulator.populate();
Expand Down
19 changes: 19 additions & 0 deletions core/src/main/java/org/geysermc/geyser/registry/Registry.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@

package org.geysermc.geyser.registry;

import java.util.BitSet;
import java.util.Collection;
import java.util.Map;
import java.util.function.Consumer;
import org.geysermc.geyser.registry.loader.RegistryLoader;

Expand Down Expand Up @@ -110,4 +113,20 @@ public void set(M mappings) {
public void register(Consumer<M> consumer) {
consumer.accept(this.mappings);
}

/**
* Clears The Mappings.
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect capitalization in Javadoc. Standard Javadoc style uses sentence case, not title case. Should be "Clears the mappings."

Suggested change
* Clears The Mappings.
* Clears the mappings.

Copilot uses AI. Check for mistakes.
*/
@Override
public void clear() {
if (this.mappings instanceof Collection) {
((Collection<?>) this.mappings).clear();
} else if (this.mappings instanceof Map) {
((Map<?, ?>) this.mappings).clear();
} else if (this.mappings instanceof BitSet) {
((BitSet) this.mappings).clear();
} else {
throw new UnsupportedOperationException("Cannot clear registry of type " + (this.mappings == null ? "null" : this.mappings.getClass().getName()));
}
}
}