From d265d5b5866944717bbf85b32b51cd09f7b501f8 Mon Sep 17 00:00:00 2001 From: Emilia Dreamer Date: Tue, 6 Jul 2021 20:08:21 +0300 Subject: [PATCH] Use globally unique plugin ID for plugin cards with tabs (#1983) Affects issues: - Fixed #1982 --- .../plan/delivery/rendering/html/Contributors.java | 3 ++- .../delivery/rendering/html/structure/TabsElement.java | 10 ++++++---- .../plan/delivery/rendering/pages/PlayerPluginTab.java | 1 + .../delivery/rendering/pages/ServerPluginTabs.java | 2 ++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/html/Contributors.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/html/Contributors.java index f68bed723..8be254288 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/html/Contributors.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/html/Contributors.java @@ -82,7 +82,8 @@ public class Contributors { new Contributor("4drian3d", LANG), new Contributor("\u6d1b\u4f0a", LANG), new Contributor("portlek", CODE), - new Contributor("mbax", CODE) + new Contributor("mbax", CODE), + new Contributor("rymiel", CODE) }; private Contributors() { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/html/structure/TabsElement.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/html/structure/TabsElement.java index 39941d117..9fe6186e8 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/html/structure/TabsElement.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/html/structure/TabsElement.java @@ -26,9 +26,11 @@ import org.apache.commons.lang3.RegExUtils; */ public class TabsElement { + private final int pluginId; private final Tab[] tabs; - public TabsElement(Tab... tabs) { + public TabsElement(int pluginId, Tab... tabs) { + this.pluginId = pluginId; this.tabs = tabs; } @@ -45,7 +47,7 @@ public class TabsElement { content.append("
"); boolean first = true; for (Tab tab : tabs) { - String id = tab.getId(); + String id = tab.getId(pluginId); String navHtml = tab.getNavHtml(); String contentHtml = tab.getContentHtml(); @@ -83,8 +85,8 @@ public class TabsElement { return contentHtml; } - public String getId() { - return "tab_" + RegExUtils.removeAll(title, "[^a-zA-Z0-9]*").toLowerCase(); + public String getId(int pluginId) { + return "tab_" + pluginId + "_" + RegExUtils.removeAll(title, "[^a-zA-Z0-9]*").toLowerCase(); } } } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/pages/PlayerPluginTab.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/pages/PlayerPluginTab.java index 370f7ea76..e46c1db04 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/pages/PlayerPluginTab.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/pages/PlayerPluginTab.java @@ -112,6 +112,7 @@ public class PlayerPluginTab implements Comparable { tabsElement = buildContentHtml(genericTabData); } else { tabsElement = new TabsElement( + datum.getPluginID(), datum.getTabs().stream().map(this::wrapToTabElementTab).toArray(TabsElement.Tab[]::new) ).toHtmlFull(); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/pages/ServerPluginTabs.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/pages/ServerPluginTabs.java index 7f1a92777..0aa792049 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/pages/ServerPluginTabs.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/pages/ServerPluginTabs.java @@ -112,6 +112,7 @@ public class ServerPluginTabs { tabsElement = buildContentHtml(genericTabData); } else { tabsElement = new TabsElement( + datum.getPluginID(), datum.getTabs().stream().map(this::wrapToTabElementTab).toArray(TabsElement.Tab[]::new) ).toHtmlFull(); } @@ -137,6 +138,7 @@ public class ServerPluginTabs { tabsElement = buildContentHtml(genericTabData); } else { tabsElement = new TabsElement( + datum.getPluginID(), datum.getTabs().stream().map(this::wrapToTabElementTab).toArray(TabsElement.Tab[]::new) ).toHtmlFull(); }