diff --git a/Plan/common/src/main/java/com/djrapitops/plan/data/plugin/PluginData.java b/Plan/common/src/main/java/com/djrapitops/plan/data/plugin/PluginData.java index 86740abd8..3c881b160 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/data/plugin/PluginData.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/data/plugin/PluginData.java @@ -18,8 +18,8 @@ package com.djrapitops.plan.data.plugin; import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.element.InspectContainer; -import com.djrapitops.plan.delivery.rendering.html.icon.Color; -import com.djrapitops.plan.delivery.rendering.html.icon.Icon; +import com.djrapitops.plan.utilities.html.icon.Color; +import com.djrapitops.plan.utilities.html.icon.Icon; import java.util.Collection; import java.util.Objects; diff --git a/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/icon/Color.java b/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/icon/Color.java new file mode 100644 index 000000000..46e70c69e --- /dev/null +++ b/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/icon/Color.java @@ -0,0 +1,86 @@ +/* + * This file is part of Player Analytics (Plan). + * + * Plan is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License v3 as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Plan is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Plan. If not, see . + */ +package com.djrapitops.plan.utilities.html.icon; + +import java.util.Optional; + +/** + * @deprecated This Class exists to keep plugins that used PluginData from breaking. + */ +@Deprecated +public enum Color { + RED("col-red"), + PINK("col-pink"), + PURPLE("col-purple"), + DEEP_PURPLE("col-deep-purple"), + INDIGO("col-indigo"), + BLUE("col-blue"), + LIGHT_BLUE("col-light-blue"), + CYAN("col-cyan"), + TEAL("col-teal"), + GREEN("col-green"), + LIGHT_GREEN("col-light-green"), + LIME("col-lime"), + YELLOW("col-yellow"), + AMBER("col-amber"), + ORANGE("col-orange"), + DEEP_ORANGE("col-deep-orange"), + BROWN("col-brown"), + GREY("col-grey"), + BLUE_GREY("col-blue-grey"), + BLACK("col-black"), + NONE(""); + + private final String htmlClass; + + Color(String htmlClass) { + this.htmlClass = htmlClass; + } + + /** + * @deprecated This Class exists to keep plugins that used PluginData from breaking. + */ + @Deprecated + public static Color matchString(String name) { + String lowerCaseName = name.toLowerCase(); + for (Color color : values()) { + if (color.htmlClass.contains(lowerCaseName)) { + return color; + } + } + return Color.BLACK; + } + + /** + * @deprecated This Class exists to keep plugins that used PluginData from breaking. + */ + @Deprecated + public static Optional getByName(String name) { + if (name == null) { + return Optional.empty(); + } + try { + return Optional.of(valueOf(name)); + } catch (IllegalArgumentException e) { + return Optional.empty(); + } + } + + public String getHtmlClass() { + return htmlClass; + } +} diff --git a/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/icon/Family.java b/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/icon/Family.java new file mode 100644 index 000000000..e13b676a7 --- /dev/null +++ b/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/icon/Family.java @@ -0,0 +1,62 @@ +/* + * This file is part of Player Analytics (Plan). + * + * Plan is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License v3 as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Plan is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Plan. If not, see . + */ +package com.djrapitops.plan.utilities.html.icon; + +import java.util.Optional; + +/** + * @deprecated This Class exists to keep plugins that used PluginData from breaking. + */ +@Deprecated +public enum Family { + SOLID(" fa fa-", "\">"), + REGULAR(" far fa-", "\">"), + BRAND(" fab fa-", "\">"), + @Deprecated + LINE(" material-icons\">", ""); + + private final String middle; + private final String suffix; + + Family(String middle, String suffix) { + this.middle = middle; + this.suffix = suffix; + } + + /** + * @deprecated This Class exists to keep plugins that used PluginData from breaking. + */ + @Deprecated + public static Optional getByName(String name) { + if (name == null) { + return Optional.empty(); + } + try { + return Optional.of(valueOf(name)); + } catch (IllegalArgumentException e) { + return Optional.empty(); + } + } + + /** + * @deprecated This Class exists to keep plugins that used PluginData from breaking. + */ + @Deprecated + public String appendAround(String color, String name) { + return ". + */ +package com.djrapitops.plan.utilities.html.icon; + +import com.djrapitops.plugin.utilities.Verify; + +/** + * @deprecated This Class exists to keep plugins that used PluginData from breaking. + */ +@Deprecated +public class Icon { + + private Family type; + private String name; + private Color color; + + private Icon() { + type = Family.SOLID; + color = Color.NONE; + } + + /** + * @deprecated This Class exists to keep plugins that used PluginData from breaking. + */ + @Deprecated + public Icon(Family type, String name, Color color) { + this.type = type; + this.name = name; + this.color = color; + } + + /** + * @deprecated This Class exists to keep plugins that used PluginData from breaking. + */ + @Deprecated + public static Builder called(String name) { + return new Builder().called(name); + } + + public static Builder of(Family type) { + return new Builder().of(type); + } + + public static Builder of(Color color) { + return new Builder().of(color); + } + + public void setColor(Color color) { + this.color = color; + } + + public String toHtml() { + return type.appendAround(color.getHtmlClass(), name); + } + + @Override + public String toString() { + return toHtml(); + } + + /** + * @deprecated This Class exists to keep plugins that used PluginData from breaking. + */ + @Deprecated + public static class Builder { + + private final Icon icon; + + Builder() { + this.icon = new Icon(); + } + + public Builder called(String name) { + icon.name = name; + return this; + } + + public Builder of(Color color) { + icon.color = color; + return this; + } + + public Builder of(Family type) { + icon.type = type; + return this; + } + + public Icon build() { + Verify.nullCheck(icon.name, () -> new IllegalStateException("'name' was not defined yet!")); + return icon; + } + + @Override + public String toString() { + return build().toHtml(); + } + } +}