mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-09-07 04:18:26 +02:00
PluginData API suspenders for old plugins
This commit is contained in:
parent
585a2ecf52
commit
64e15ad103
@ -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;
|
||||
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Color> 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;
|
||||
}
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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-", "\"></i>"),
|
||||
REGULAR(" far fa-", "\"></i>"),
|
||||
BRAND(" fab fa-", "\"></i>"),
|
||||
@Deprecated
|
||||
LINE(" material-icons\">", "</i>");
|
||||
|
||||
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<Family> 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 "<i class=\"" + color + middle + name + suffix;
|
||||
}
|
||||
}
|
@ -0,0 +1,112 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user