Skip to content

Commit

Permalink
Fix plugin names in performance screen
Browse files Browse the repository at this point in the history
  • Loading branch information
shedaniel committed Aug 8, 2023
1 parent ebbf6cf commit 67f366d
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void init() {
RoughlyEnoughItemsCore.PERFORMANCE_LOGGER.getStages().forEach((stage, inner) -> {
List<PerformanceEntryImpl> entries = new ArrayList<>();
inner.times().forEach((obj, time) -> {
entries.add(new PerformanceEntryImpl(new TextComponent(obj instanceof Pair ? ((Pair<REIPluginProvider<?>, REIPlugin<?>>) obj).getFirst().getPluginProviderName() : Objects.toString(obj)), time));
entries.add(new PerformanceEntryImpl(new TextComponent(obj instanceof Pair ? getNameOfPlugin(obj) : Objects.toString(obj)), time));
});
Collection<Long> values = inner.times().values();
long separateTime;
Expand All @@ -167,6 +167,24 @@ public void init() {
addWidget(list);
}

private String getNameOfPlugin(Object obj) {
Pair<REIPluginProvider<?>, REIPlugin<?>> pair = (Pair<REIPluginProvider<?>, REIPlugin<?>>) obj;
REIPluginProvider<?> provider = pair.getFirst();
REIPlugin<?> plugin = pair.getSecond();

String providerName = provider.getPluginProviderName();

if (provider.provide().size() >= 1) {
String pluginName = plugin.getPluginProviderName();

if (!providerName.equals(pluginName)) {
providerName = pluginName + " of " + providerName;
}
}

return providerName;
}

@Override
public void render(PoseStack poses, int mouseX, int mouseY, float delta) {
renderDirtBackground(0);
Expand Down

0 comments on commit 67f366d

Please sign in to comment.