mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-27 10:31:42 +01:00
Information annotations for DataExtension API
This commit is contained in:
parent
b4a3feddf5
commit
5f2e097ac3
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.extension;
|
||||
|
||||
/**
|
||||
* Interface to implement data extensions with.
|
||||
* <p>
|
||||
* The class implementing this interface should be annotated with {@link com.djrapitops.plan.extension.annotation.PluginInfo}.
|
||||
* <p>
|
||||
* If the extension is given to Plan API without the annotation it will be rejected.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public interface DataExtension {
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.extension;
|
||||
|
||||
/**
|
||||
* Enum representing big elements of a plugin.
|
||||
* <p>
|
||||
* Used for determining in which order elements are placed on a {@link com.djrapitops.plan.extension.annotation.Tab} by
|
||||
* using {@link com.djrapitops.plan.extension.annotation.TabInfo}.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public enum ElementOrder {
|
||||
/**
|
||||
* Represents text - value pair box.
|
||||
*/
|
||||
VALUES,
|
||||
/**
|
||||
* Represents tables.
|
||||
*/
|
||||
TABLE,
|
||||
/**
|
||||
* Represents graphs.
|
||||
*/
|
||||
GRAPH
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.extension.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Method Annotation to determine that a method can not be called unless a condition is fulfilled.
|
||||
* <p>
|
||||
* Condition information is provided with {@link com.djrapitops.plan.extension.annotation.data.BooleanProvider}.
|
||||
* If {@link com.djrapitops.plan.extension.annotation.data.BooleanProvider} for the condition is not specified the
|
||||
* method tagged with this annotation will not be called, (Condition is assumed false).
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface Conditional {
|
||||
|
||||
/**
|
||||
* Name of the condition limited to 50 characters.
|
||||
*
|
||||
* @return Case sensitive string of max 50 characters.
|
||||
*/
|
||||
String value();
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.extension.annotation;
|
||||
|
||||
import com.djrapitops.plan.extension.icon.Color;
|
||||
import com.djrapitops.plan.extension.icon.Family;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Class Annotation for informing Plan about a plugin.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @see TabOrder to determine preferred tab ordering if you use {@link Tab}s.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface PluginInfo {
|
||||
|
||||
/**
|
||||
* Name of the plugin, limited to 50 characters.
|
||||
*
|
||||
* @return String of max 50 characters, remainder will be clipped.
|
||||
*/
|
||||
String name();
|
||||
|
||||
/**
|
||||
* Name of Font Awesome icon.
|
||||
* <p>
|
||||
* See https://fontawesome.com/icons?d=gallery&m=free for icons and their {@link Family}.
|
||||
*
|
||||
* @return Name of the icon, if name is not valid no icon is shown.
|
||||
*/
|
||||
String iconName() default "cube";
|
||||
|
||||
/**
|
||||
* Family of Font Awesome icon.
|
||||
* <p>
|
||||
* See https://fontawesome.com/icons?d=gallery&m=free for icons and their {@link Family}.
|
||||
*
|
||||
* @return Family that matches an icon, if there is no icon for this family no icon is shown.
|
||||
*/
|
||||
Family iconFamily() default Family.SOLID;
|
||||
|
||||
/**
|
||||
* Color preference of the plugin.
|
||||
* <p>
|
||||
* This color will be set as the default color to use for plugin's elements.
|
||||
*
|
||||
* @return Preferred color. If none are specified defaults are used.
|
||||
*/
|
||||
Color color() default Color.NONE;
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.extension.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Method Annotation for determining Tab the given element should appear on.
|
||||
* <p>
|
||||
* If not specified Plan places the item on the default tab.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @see TabInfo if you want to determine an icon or element order for a Tab.
|
||||
* @see TabOrder to determine preferred tab ordering if you use Tabs.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface Tab {
|
||||
|
||||
/**
|
||||
* Name of the tab to place this item on.
|
||||
*
|
||||
* @return Tab name, limited to 50 characters.
|
||||
*/
|
||||
String value();
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.extension.annotation;
|
||||
|
||||
import com.djrapitops.plan.extension.ElementOrder;
|
||||
import com.djrapitops.plan.extension.icon.Family;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Class Annotation that allows determining an Icon and {@link ElementOrder} of a tab.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface TabInfo {
|
||||
|
||||
/**
|
||||
* Name of the tab this information is about.
|
||||
*
|
||||
* @return Tab name, limited to 50 characters.
|
||||
*/
|
||||
String tab();
|
||||
|
||||
/**
|
||||
* Name of Font Awesome icon.
|
||||
* <p>
|
||||
* See https://fontawesome.com/icons?d=gallery&m=free for icons and their {@link Family}.
|
||||
*
|
||||
* @return Name of the icon, if name is not valid no icon is shown.
|
||||
*/
|
||||
String iconName() default "circle";
|
||||
|
||||
/**
|
||||
* Family of Font Awesome icon.
|
||||
* <p>
|
||||
* See https://fontawesome.com/icons?d=gallery&m=free for icons and their {@link Family}.
|
||||
*
|
||||
* @return Family that matches an icon, if there is no icon for this family no icon is shown.
|
||||
*/
|
||||
Family iconFamily() default Family.SOLID;
|
||||
|
||||
/**
|
||||
* Order preference for the large elements of a tab.
|
||||
* <p>
|
||||
* If an ordering is not present they will be added to the end in the default order.
|
||||
* If a duplicate ordering exists only the first will be used for determining the order.
|
||||
*
|
||||
* @return ElementOrders in the order that they want to be displayed in.
|
||||
*/
|
||||
ElementOrder[] elementOrder();
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.extension.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Class Annotation for informing Plan about plugin's tab order preference.
|
||||
* <p>
|
||||
* If tab order is not defined alphabetical order is used.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface TabOrder {
|
||||
|
||||
/**
|
||||
* Order preference of different {@link Tab}s.
|
||||
* <p>
|
||||
* If a tab is defined that is not present it is ignored.
|
||||
* If a tab is not defined but is present alphabetical order is used.
|
||||
*
|
||||
* @return Names of the defined tabs (case sensitive).
|
||||
*/
|
||||
String[] value();
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.extension.icon;
|
||||
|
||||
/**
|
||||
* Enum to determine what color to use for some element.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public enum Color {
|
||||
|
||||
RED,
|
||||
PINK,
|
||||
PURPLE,
|
||||
DEEP_PURPLE,
|
||||
INDIGO,
|
||||
BLUE,
|
||||
LIGHT_BLUE,
|
||||
CYAN,
|
||||
TEAL,
|
||||
GREEN,
|
||||
LIGHT_GREEN,
|
||||
LIME,
|
||||
YELLOW,
|
||||
AMBER,
|
||||
ORANGE,
|
||||
DEEP_ORANGE,
|
||||
BROWN,
|
||||
GREY,
|
||||
BLUE_GREY,
|
||||
BLACK,
|
||||
NONE
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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.extension.icon;
|
||||
|
||||
/**
|
||||
* Enum to determine font-awesome icon family.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public enum Family {
|
||||
SOLID,
|
||||
REGULAR,
|
||||
BRAND
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* 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.extension.icon;
|
||||
|
||||
/**
|
||||
* Object that represents an icon on the website.
|
||||
* <p>
|
||||
* See https://fontawesome.com/icons?d=gallery&m=free for icons and their {@link Family}.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class Icon {
|
||||
|
||||
private Family type;
|
||||
private String name;
|
||||
private Color color;
|
||||
|
||||
private Icon() {
|
||||
type = Family.SOLID;
|
||||
color = Color.NONE;
|
||||
}
|
||||
|
||||
public Icon(Family type, String name, Color color) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
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 Family getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
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() {
|
||||
if (icon.name == null) {
|
||||
throw new IllegalStateException("'name' was not defined yet!");
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user