Skip to content

Commit

Permalink
Add icons to settings pages
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE committed Sep 24, 2024
1 parent 0cac88c commit f3f1f9d
Show file tree
Hide file tree
Showing 22 changed files with 32 additions and 29 deletions.
2 changes: 2 additions & 0 deletions proto/src/main/proto/soulfire/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ message SettingsPage {
// What namespace the settings of this page represent
string namespace = 4;
repeated SettingEntry entries = 5;
// https://lucide.dev icon id for this page (Usually rendered left of the page name)
string iconId = 6;
}

message PermissionMessage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ public SoulFireServer(
new ServerSettingsRegistryInitEvent(
serverSettingsRegistry =
new ServerSettingsRegistry(SettingsPage.Type.SERVER)
.addClass(DevSettings.class, "Dev Settings")));
.addClass(DevSettings.class, "Dev Settings", "bug")));
postEvent(
new InstanceSettingsRegistryInitEvent(
instanceSettingsRegistry =
new ServerSettingsRegistry(SettingsPage.Type.INSTANCE)
// Needs Via loaded to have all protocol versions
.addClass(BotSettings.class, "Bot Settings")
.addClass(AccountSettings.class, "Account Settings")
.addClass(ProxySettings.class, "Proxy Settings")));
.addClass(BotSettings.class, "Bot Settings", "bot")
.addClass(AccountSettings.class, "Account Settings", "users")
.addClass(ProxySettings.class, "Proxy Settings", "waypoints")));

log.info("Loading instances...");
loadInstances();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static void onJoined(BotJoinedEvent event) {

@EventHandler
public static void onSettingsRegistryInit(InstanceSettingsRegistryInitEvent event) {
event.settingsRegistry().addClass(AntiAFKSettings.class, "Anti AFK", PLUGIN_INFO);
event.settingsRegistry().addClass(AntiAFKSettings.class, "Anti AFK", PLUGIN_INFO, "activity");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static void onJoined(BotJoinedEvent event) {

@EventHandler
public static void onSettingsRegistryInit(InstanceSettingsRegistryInitEvent event) {
event.settingsRegistry().addClass(AutoArmorSettings.class, "Auto Armor", PLUGIN_INFO);
event.settingsRegistry().addClass(AutoArmorSettings.class, "Auto Armor", PLUGIN_INFO, "shield");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static void onJoined(BotJoinedEvent event) {

@EventHandler
public static void onSettingsRegistryInit(InstanceSettingsRegistryInitEvent event) {
event.settingsRegistry().addClass(AutoChatMessageSettings.class, "Auto Chat Message", PLUGIN_INFO);
event.settingsRegistry().addClass(AutoChatMessageSettings.class, "Auto Chat Message", PLUGIN_INFO, "message-circle-code");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static void onJoined(BotJoinedEvent event) {

@EventHandler
public static void onSettingsRegistryInit(InstanceSettingsRegistryInitEvent event) {
event.settingsRegistry().addClass(AutoEatSettings.class, "Auto Eat", PLUGIN_INFO);
event.settingsRegistry().addClass(AutoEatSettings.class, "Auto Eat", PLUGIN_INFO, "drumstick");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static void onJoined(BotJoinedEvent event) {

@EventHandler
public static void onSettingsRegistryInit(InstanceSettingsRegistryInitEvent event) {
event.settingsRegistry().addClass(AutoJumpSettings.class, "Auto Jump", PLUGIN_INFO);
event.settingsRegistry().addClass(AutoJumpSettings.class, "Auto Jump", PLUGIN_INFO, "footprints");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class AutoReconnect implements InternalPlugin {

@EventHandler
public static void onSettingsRegistryInit(InstanceSettingsRegistryInitEvent event) {
event.settingsRegistry().addClass(AutoReconnectSettings.class, "Auto Reconnect", PLUGIN_INFO);
event.settingsRegistry().addClass(AutoReconnectSettings.class, "Auto Reconnect", PLUGIN_INFO, "refresh-ccw");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static void onChat(ChatMessageReceiveEvent event) {

@EventHandler
public static void onSettingsRegistryInit(InstanceSettingsRegistryInitEvent event) {
event.settingsRegistry().addClass(AutoRegisterSettings.class, "Auto Register", PLUGIN_INFO);
event.settingsRegistry().addClass(AutoRegisterSettings.class, "Auto Register", PLUGIN_INFO, "key-round");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static void onPacket(SFPacketReceiveEvent event) {

@EventHandler
public static void onSettingsRegistryInit(InstanceSettingsRegistryInitEvent event) {
event.settingsRegistry().addClass(AutoRespawnSettings.class, "Auto Respawn", PLUGIN_INFO);
event.settingsRegistry().addClass(AutoRespawnSettings.class, "Auto Respawn", PLUGIN_INFO, "repeat");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static void onJoined(BotJoinedEvent event) {

@EventHandler
public static void onSettingsRegistryInit(InstanceSettingsRegistryInitEvent event) {
event.settingsRegistry().addClass(AutoTotemSettings.class, "Auto Totem", PLUGIN_INFO);
event.settingsRegistry().addClass(AutoTotemSettings.class, "Auto Totem", PLUGIN_INFO, "cross");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static void onChat(ChatMessageReceiveEvent event) {

@EventHandler
public static void onSettingsRegistryInit(InstanceSettingsRegistryInitEvent event) {
event.settingsRegistry().addClass(ChatControlSettings.class, "Chat Control", PLUGIN_INFO);
event.settingsRegistry().addClass(ChatControlSettings.class, "Chat Control", PLUGIN_INFO, "joystick");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private static synchronized void logChatMessage(String message) {

@EventHandler
public static void onSettingsRegistryInit(InstanceSettingsRegistryInitEvent event) {
event.settingsRegistry().addClass(ChatMessageSettings.class, "Chat Message Logger", PLUGIN_INFO);
event.settingsRegistry().addClass(ChatMessageSettings.class, "Chat Message Logger", PLUGIN_INFO, "logs");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static void onPacket(SFPacketReceiveEvent event) {

@EventHandler
public static void onSettingsRegistryInit(InstanceSettingsRegistryInitEvent event) {
event.settingsRegistry().addClass(ClientBrandSettings.class, "Client Brand", PLUGIN_INFO);
event.settingsRegistry().addClass(ClientBrandSettings.class, "Client Brand", PLUGIN_INFO, "fingerprint");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static void onPacket(SFPacketReceiveEvent event) {

@EventHandler
public static void onSettingsRegistryInit(InstanceSettingsRegistryInitEvent event) {
event.settingsRegistry().addClass(ClientSettingsSettings.class, "Client Settings", PLUGIN_INFO);
event.settingsRegistry().addClass(ClientSettingsSettings.class, "Client Settings", PLUGIN_INFO, "settings-2");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static void onPacket(SFPacketSendingEvent event) {

@EventHandler
public static void onSettingsRegistryInit(InstanceSettingsRegistryInitEvent event) {
event.settingsRegistry().addClass(FakeVirtualHostSettings.class, "Fake Virtual Host", PLUGIN_INFO);
event.settingsRegistry().addClass(FakeVirtualHostSettings.class, "Fake Virtual Host", PLUGIN_INFO, "globe");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private static ByteBuf createForwardingData(

@EventHandler
public static void onSettingsRegistryInit(InstanceSettingsRegistryInitEvent event) {
event.settingsRegistry().addClass(ForwardingBypassSettings.class, "Forwarding Bypass", PLUGIN_INFO);
event.settingsRegistry().addClass(ForwardingBypassSettings.class, "Forwarding Bypass", PLUGIN_INFO, "milestone");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class KillAura implements InternalPlugin {

@EventHandler
public static void onSettingsRegistryInit(InstanceSettingsRegistryInitEvent event) {
event.settingsRegistry().addClass(KillAuraSettings.class, "Kill Aura", PLUGIN_INFO);
event.settingsRegistry().addClass(KillAuraSettings.class, "Kill Aura", PLUGIN_INFO, "skull");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class ModLoaderSupport implements InternalPlugin {

@EventHandler
public static void onSettingsRegistryInit(InstanceSettingsRegistryInitEvent event) {
event.settingsRegistry().addClass(ModLoaderSettings.class, "Mod Loader Support", PLUGIN_INFO);
event.settingsRegistry().addClass(ModLoaderSettings.class, "Mod Loader Support", PLUGIN_INFO, "package");
}

private static String createFMLAddress(String initialHostname) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public class POVServer implements InternalPlugin {

@EventHandler
public static void onSettingsRegistryInit(InstanceSettingsRegistryInitEvent event) {
event.settingsRegistry().addClass(POVServerSettings.class, "POV Server", PLUGIN_INFO);
event.settingsRegistry().addClass(POVServerSettings.class, "POV Server", PLUGIN_INFO, "view");
}

private static GameProfile getFakePlayerListEntry(Component text) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static void onPreConnect(PreBotConnectEvent event) {

@EventHandler
public static void onSettingsRegistryInit(InstanceSettingsRegistryInitEvent event) {
event.settingsRegistry().addClass(ServerListBypassSettings.class, "Server List Bypass", PLUGIN_INFO);
event.settingsRegistry().addClass(ServerListBypassSettings.class, "Server List Bypass", PLUGIN_INFO, "network");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ private static DoubleSetting createDoubleSetting(DoubleProperty property) {
return builder.build();
}

public ServerSettingsRegistry addClass(Class<? extends SettingsObject> clazz, String pageName) {
return addClass(clazz, pageName, null);
public ServerSettingsRegistry addClass(Class<? extends SettingsObject> clazz, String pageName, String iconId) {
return addClass(clazz, pageName, null, iconId);
}

public ServerSettingsRegistry addClass(
Class<? extends SettingsObject> clazz, String pageName, @Nullable PluginInfo owningPlugin) {
Class<? extends SettingsObject> clazz, String pageName, @Nullable PluginInfo owningPlugin, String iconId) {
for (var field : clazz.getDeclaredFields()) {
if (Modifier.isPublic(field.getModifiers())
&& Modifier.isFinal(field.getModifiers())
Expand All @@ -85,7 +85,7 @@ public ServerSettingsRegistry addClass(

var registry = namespaceMap.get(property.namespace());
if (registry == null) {
registry = new NamespaceRegistry(owningPlugin, pageName, new ArrayList<>());
registry = new NamespaceRegistry(owningPlugin, pageName, new ArrayList<>(), iconId);
namespaceMap.put(property.namespace(), registry);
}

Expand Down Expand Up @@ -216,7 +216,8 @@ public List<SettingsPage> exportSettingsMeta() {
.setType(type)
.setPageName(namespaceRegistry.pageName)
.setNamespace(namespaceEntry.getKey())
.addAllEntries(entries);
.addAllEntries(entries)
.setIconId(namespaceRegistry.iconId);

if (namespaceRegistry.owningPlugin != null) {
settingsPageBuilder.setOwningPlugin(namespaceRegistry.owningPlugin.id());
Expand All @@ -243,5 +244,5 @@ private SettingEntryMinMaxPairSingle.Builder fillMultiProperties(
.setDescription(property.description());
}

private record NamespaceRegistry(@Nullable PluginInfo owningPlugin, String pageName, List<Property> properties) {}
private record NamespaceRegistry(@Nullable PluginInfo owningPlugin, String pageName, List<Property> properties, String iconId) {}
}

0 comments on commit f3f1f9d

Please sign in to comment.