Skip to content

Commit

Permalink
Split registries hard
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE committed Jan 1, 2025
1 parent 210362f commit 8299fd6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
9 changes: 2 additions & 7 deletions proto/src/main/proto/soulfire/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,6 @@ message SettingEntry {
}

message SettingsPage {
enum Type {
SERVER = 0;
INSTANCE = 1;
}

Type type = 1;
optional string owning_plugin = 2;
// The name of the page for these settings
string page_name = 3;
Expand Down Expand Up @@ -141,7 +135,8 @@ message ClientDataResponse {
string email = 8;
repeated GlobalPermissionState server_permissions = 2;
repeated ServerPlugin plugins = 3;
repeated SettingsPage settings = 5;
repeated SettingsPage server_settings = 9;
repeated SettingsPage instance_settings = 10;
}

service ConfigService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import ch.jalu.injector.Injector;
import ch.jalu.injector.InjectorBuilder;
import com.soulfiremc.builddata.BuildData;
import com.soulfiremc.grpc.generated.SettingsPage;
import com.soulfiremc.server.api.SoulFireAPI;
import com.soulfiremc.server.api.event.attack.InstanceInitEvent;
import com.soulfiremc.server.api.event.lifecycle.InstanceSettingsRegistryInitEvent;
Expand Down Expand Up @@ -192,14 +191,14 @@ public SoulFireServer(
new ServerSettingsRegistryInitEvent(
this,
serverSettingsRegistry =
new ServerSettingsRegistry(SettingsPage.Type.SERVER)
new ServerSettingsRegistry()
.addClass(ServerSettings.class, "Server Settings", "server")
.addClass(DevSettings.class, "Dev Settings", "bug")));
SoulFireAPI.postEvent(
new InstanceSettingsRegistryInitEvent(
this,
instanceSettingsRegistry =
new ServerSettingsRegistry(SettingsPage.Type.INSTANCE)
new ServerSettingsRegistry()
// Needs Via loaded to have all protocol versions
.addClass(BotSettings.class, "Bot Settings", "bot")
.addClass(AccountSettings.class, "Account Settings", "users")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public void getClientData(
})
.addAllServerPermissions(getGlobalPermissions())
.addAllPlugins(getPlugins())
.addAllSettings(soulFireServer.serverSettingsRegistry().exportSettingsMeta())
.addAllSettings(soulFireServer.instanceSettingsRegistry().exportSettingsMeta())
.addAllServerSettings(soulFireServer.serverSettingsRegistry().exportSettingsMeta())
.addAllInstanceSettings(soulFireServer.instanceSettingsRegistry().exportSettingsMeta())
.build());
responseObserver.onCompleted();
} catch (Throwable t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

@RequiredArgsConstructor
public class ServerSettingsRegistry {
private final SettingsPage.Type type;
private final Map<String, NamespaceRegistry> namespaceMap = new LinkedHashMap<>();

private static IntSetting createIntSetting(IntProperty property) {
Expand Down Expand Up @@ -241,7 +240,6 @@ yield fillProperties(comboProperty)
}

var settingsPageBuilder = SettingsPage.newBuilder()
.setType(type)
.setPageName(namespaceRegistry.pageName)
.setNamespace(namespaceEntry.getKey())
.addAllEntries(entries)
Expand Down

0 comments on commit 8299fd6

Please sign in to comment.