mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-17 21:51:25 +01:00
[Merge] Version 5.0 (#1175)
This commit is contained in:
commit
69efa14825
5
Jenkinsfile
vendored
5
Jenkinsfile
vendored
@ -7,6 +7,11 @@ pipeline {
|
||||
dir("Plan") {
|
||||
script {
|
||||
sh 'rm -rf builds'
|
||||
sh 'sed -i -e s/%buildNumber%/\$BUILD_NUMBER/g build.gradle'
|
||||
sh 'sed -i -e s/%buildNumber%/\$BUILD_NUMBER/g common/src/main/resources/plugin.yml'
|
||||
sh 'sed -i -e s/%buildNumber%/\$BUILD_NUMBER/g common/src/main/resources/bungee.yml'
|
||||
sh 'sed -i -e s/%buildNumber%/\$BUILD_NUMBER/g sponge/src/main/java/com/djrapitops/plan/PlanSponge.java'
|
||||
sh 'sed -i -e s/%buildNumber%/\$BUILD_NUMBER/g velocity/src/main/java/com/djrapitops/plan/PlanVelocity.java'
|
||||
sh './gradlew clean shadowJar --parallel'
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,11 @@ plugins {
|
||||
id "com.jfrog.bintray" version "1.8.4"
|
||||
}
|
||||
|
||||
ext.apiVersion = '0.0.6'
|
||||
dependencies {
|
||||
compileOnly group: 'org.apache.commons', name: 'commons-lang3', version: '3.9'
|
||||
}
|
||||
|
||||
ext.apiVersion = '5.0-R0.3'
|
||||
|
||||
bintray {
|
||||
user = System.getenv('BINTRAY_USER')
|
||||
@ -15,7 +19,7 @@ bintray {
|
||||
issueTrackerUrl = 'https://github.com/plan-player-analytics/Plan/issues'
|
||||
version {
|
||||
name = "$apiVersion"
|
||||
desc = "Plan APIv5 version $apiVersion"
|
||||
desc = "Plan API version $apiVersion"
|
||||
}
|
||||
publications = ['BintrayPublication']
|
||||
}
|
||||
|
@ -41,6 +41,10 @@ enum Capability {
|
||||
* DataExtension API table package, TableProvider, Table and Table.Factory
|
||||
*/
|
||||
DATA_EXTENSION_TABLES,
|
||||
/**
|
||||
* DataExtension API groups, GroupProvider and Group parameter methods
|
||||
*/
|
||||
DATA_EXTENSION_GROUPS,
|
||||
/**
|
||||
* DataExtension API addition, allows throwing {@link com.djrapitops.plan.extension.NotReadyException} inside a Provider method when your API is not ready for a method call.
|
||||
*/
|
||||
@ -52,9 +56,13 @@ enum Capability {
|
||||
*/
|
||||
DATA_EXTENSION_SHOW_IN_PLAYER_TABLE,
|
||||
/**
|
||||
*
|
||||
* QueryService and CommonQueries
|
||||
*/
|
||||
QUERY_API;
|
||||
QUERY_API,
|
||||
/**
|
||||
* SettingsService
|
||||
*/
|
||||
SETTINGS_API;
|
||||
|
||||
static Optional<Capability> getByName(String name) {
|
||||
if (name == null) {
|
||||
|
@ -25,7 +25,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Method annotation to provide a boolean value about a Player.
|
||||
* Method annotation to provide a boolean value.
|
||||
* <p>
|
||||
* Usage: {@code @BooleanProvider boolean method(UUID playerUUID)}
|
||||
* <p>
|
||||
|
@ -28,6 +28,9 @@ import java.lang.annotation.Target;
|
||||
* If {@link com.djrapitops.plan.extension.annotation.BooleanProvider} for the condition is not specified the
|
||||
* method tagged with this annotation will not be called, (Condition is assumed false).
|
||||
*
|
||||
* Please note that Conditional does not cross method parameter boundaries - (Conditional on a player method does not
|
||||
* take into account conditionals of server).
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
@ -25,7 +25,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Method annotation to provide a double value about a Player.
|
||||
* Method annotation to provide a double value.
|
||||
* <p>
|
||||
* Usage: {@code @DoubleProvider double method(UUID playerUUID)}
|
||||
*
|
||||
|
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Method annotation to provide {@code String[]} array of Group names about a Player.
|
||||
* <p>
|
||||
* This method annotation only works when used with {@code UUID} or {@code String} as a method parameter (for Players).
|
||||
* <p>
|
||||
* For example:
|
||||
* {@code @GroupProvider public String[] getJobs(UUID playerUUID) {}}
|
||||
* <p>
|
||||
* Group data is parsed as Table for /server & /network page and similar to {@link StringProvider} for /player page.
|
||||
* <p>
|
||||
* Requires Capability {@code DATA_EXTENSION_GROUPS}
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface GroupProvider {
|
||||
|
||||
/**
|
||||
* Text displayed before the value, limited to 50 characters.
|
||||
* <p>
|
||||
* Should inform the user what the group names represent, for example
|
||||
* "Town" or "Job"
|
||||
*
|
||||
* @return String of max 50 characters, remainder will be clipped.
|
||||
*/
|
||||
String text() default "Group";
|
||||
|
||||
/**
|
||||
* Determine the color of the table header for this group.
|
||||
*
|
||||
* @return Preferred color. If none are specified defaults are used.
|
||||
*/
|
||||
Color groupColor() default Color.NONE;
|
||||
|
||||
/**
|
||||
* Name of Font Awesome icon.
|
||||
* <p>
|
||||
* See https://fontawesome.com/icons (select '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 (select '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;
|
||||
|
||||
}
|
@ -26,7 +26,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Method annotation to provide a long (64bit number) value about a Player.
|
||||
* Method annotation to provide a long (64bit number) value.
|
||||
* <p>
|
||||
* If you want to return int values, use this provider with a long as
|
||||
* return type of the method.
|
||||
|
@ -25,7 +25,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Method annotation to provide a double (Percentage) about a Player.
|
||||
* Method annotation to provide a double (Percentage).
|
||||
* <p>
|
||||
* Usage: {@code @PercentageProvider double method(UUID playerUUID)}
|
||||
* <p>
|
||||
|
@ -25,7 +25,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Method annotation to provide a String value about a Player.
|
||||
* Method annotation to provide a String value.
|
||||
* <p>
|
||||
* Usage: {@code @StringProvider String method(UUID playerUUID)}
|
||||
* <p>
|
||||
|
@ -98,8 +98,10 @@ public final class ExtensionExtractor {
|
||||
|
||||
for (Method method : getMethods()) {
|
||||
int modifiers = method.getModifiers();
|
||||
if (!Modifier.isPublic(modifiers)
|
||||
|| Modifier.isStatic(modifiers)) {
|
||||
if (Modifier.isPrivate(modifiers)
|
||||
|| Modifier.isProtected(modifiers)
|
||||
|| Modifier.isStatic(modifiers)
|
||||
|| Modifier.isNative(modifiers)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -113,17 +115,30 @@ public final class ExtensionExtractor {
|
||||
MethodAnnotations.get(method, Tab.class).ifPresent(annotation -> methodAnnotations.put(method, Tab.class, annotation));
|
||||
|
||||
MethodAnnotations.get(method, TableProvider.class).ifPresent(annotation -> methodAnnotations.put(method, TableProvider.class, annotation));
|
||||
MethodAnnotations.get(method, GroupProvider.class).ifPresent(annotation -> methodAnnotations.put(method, GroupProvider.class, annotation));
|
||||
}
|
||||
|
||||
if (methodAnnotations.isEmpty()) {
|
||||
throw new IllegalArgumentException(extensionName + " class had no methods annotated with a Provider annotation");
|
||||
}
|
||||
|
||||
try {
|
||||
methodAnnotations.makeMethodsAccessible();
|
||||
} catch (SecurityException failedToMakeAccessible) {
|
||||
throw new IllegalArgumentException(extensionName + " has non accessible Provider method that could not be made accessible: " +
|
||||
failedToMakeAccessible.getMessage(), failedToMakeAccessible);
|
||||
}
|
||||
}
|
||||
|
||||
private <T> void validateReturnType(Method method, Class<T> expectedType) {
|
||||
Class<?> returnType = method.getReturnType();
|
||||
if (!expectedType.isAssignableFrom(returnType)) {
|
||||
throw new IllegalArgumentException(extensionName + "." + method.getName() + " has invalid return type. was: " + returnType.getName() + ", expected: " + expectedType.getName());
|
||||
String expectedName = expectedType.getName();
|
||||
throw new IllegalArgumentException(extensionName + "." + method.getName() +
|
||||
" has invalid return type. was: " +
|
||||
returnType.getName() +
|
||||
", expected: " +
|
||||
(expectedName.startsWith("[L") ? expectedName + " (an array)" : expectedName));
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,6 +193,7 @@ public final class ExtensionExtractor {
|
||||
validatePercentageProviderAnnotations();
|
||||
validateStringProviderAnnotations();
|
||||
validateTableProviderAnnotations();
|
||||
validateGroupProviderAnnotations();
|
||||
}
|
||||
|
||||
private void validateBooleanProviderAnnotations() {
|
||||
@ -215,9 +231,9 @@ public final class ExtensionExtractor {
|
||||
}
|
||||
|
||||
private void validateDoubleProviderAnnotations() {
|
||||
for (Map.Entry<Method, DoubleProvider> numberProvider : methodAnnotations.getMethodAnnotations(DoubleProvider.class).entrySet()) {
|
||||
Method method = numberProvider.getKey();
|
||||
DoubleProvider annotation = numberProvider.getValue();
|
||||
for (Map.Entry<Method, DoubleProvider> doubleProvider : methodAnnotations.getMethodAnnotations(DoubleProvider.class).entrySet()) {
|
||||
Method method = doubleProvider.getKey();
|
||||
DoubleProvider annotation = doubleProvider.getValue();
|
||||
|
||||
validateReturnType(method, double.class);
|
||||
validateMethodAnnotationPropertyLength(annotation.text(), "text", 50, method);
|
||||
@ -227,9 +243,9 @@ public final class ExtensionExtractor {
|
||||
}
|
||||
|
||||
private void validatePercentageProviderAnnotations() {
|
||||
for (Map.Entry<Method, PercentageProvider> numberProvider : methodAnnotations.getMethodAnnotations(PercentageProvider.class).entrySet()) {
|
||||
Method method = numberProvider.getKey();
|
||||
PercentageProvider annotation = numberProvider.getValue();
|
||||
for (Map.Entry<Method, PercentageProvider> percentageProvider : methodAnnotations.getMethodAnnotations(PercentageProvider.class).entrySet()) {
|
||||
Method method = percentageProvider.getKey();
|
||||
PercentageProvider annotation = percentageProvider.getValue();
|
||||
|
||||
validateReturnType(method, double.class);
|
||||
validateMethodAnnotationPropertyLength(annotation.text(), "text", 50, method);
|
||||
@ -239,9 +255,9 @@ public final class ExtensionExtractor {
|
||||
}
|
||||
|
||||
private void validateStringProviderAnnotations() {
|
||||
for (Map.Entry<Method, StringProvider> numberProvider : methodAnnotations.getMethodAnnotations(StringProvider.class).entrySet()) {
|
||||
Method method = numberProvider.getKey();
|
||||
StringProvider annotation = numberProvider.getValue();
|
||||
for (Map.Entry<Method, StringProvider> stringProvider : methodAnnotations.getMethodAnnotations(StringProvider.class).entrySet()) {
|
||||
Method method = stringProvider.getKey();
|
||||
StringProvider annotation = stringProvider.getValue();
|
||||
|
||||
validateReturnType(method, String.class);
|
||||
validateMethodAnnotationPropertyLength(annotation.text(), "text", 50, method);
|
||||
@ -257,6 +273,17 @@ public final class ExtensionExtractor {
|
||||
}
|
||||
}
|
||||
|
||||
private void validateGroupProviderAnnotations() {
|
||||
for (Map.Entry<Method, GroupProvider> groupProvider : methodAnnotations.getMethodAnnotations(GroupProvider.class).entrySet()) {
|
||||
Method method = groupProvider.getKey();
|
||||
GroupProvider annotation = groupProvider.getValue();
|
||||
|
||||
validateReturnType(method, String[].class);
|
||||
validateMethodAnnotationPropertyLength(annotation.text(), "text", 50, method);
|
||||
validateMethodArguments(method, true, UUID.class, String.class);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateConditionals() {
|
||||
Collection<Conditional> conditionals = methodAnnotations.getAnnotations(Conditional.class);
|
||||
Collection<BooleanProvider> conditionProviders = methodAnnotations.getAnnotations(BooleanProvider.class);
|
||||
@ -280,7 +307,8 @@ public final class ExtensionExtractor {
|
||||
for (Method conditionalMethod : conditionalMethods) {
|
||||
if (!MethodAnnotations.hasAnyOf(conditionalMethod,
|
||||
BooleanProvider.class, DoubleProvider.class, NumberProvider.class,
|
||||
PercentageProvider.class, StringProvider.class
|
||||
PercentageProvider.class, StringProvider.class, TableProvider.class,
|
||||
GroupProvider.class
|
||||
)) {
|
||||
throw new IllegalArgumentException(extensionName + "." + conditionalMethod.getName() + " did not have any associated Provider for Conditional.");
|
||||
}
|
||||
|
@ -73,4 +73,13 @@ public class MethodAnnotations {
|
||||
public String toString() {
|
||||
return "MethodAnnotations{" + byAnnotationType + '}';
|
||||
}
|
||||
|
||||
void makeMethodsAccessible() {
|
||||
byAnnotationType.values().stream()
|
||||
.map(Map::keySet)
|
||||
.flatMap(Collection::stream)
|
||||
.distinct()
|
||||
.filter(method -> !method.isAccessible())
|
||||
.forEach(method -> method.setAccessible(true));
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@ package com.djrapitops.plan.extension.table;
|
||||
import com.djrapitops.plan.extension.ElementOrder;
|
||||
import com.djrapitops.plan.extension.icon.Color;
|
||||
import com.djrapitops.plan.extension.icon.Icon;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -109,7 +110,7 @@ public final class Table {
|
||||
}
|
||||
|
||||
private Factory column(int indx, String columnName, Icon icon) {
|
||||
building.columns[indx] = columnName;
|
||||
building.columns[indx] = StringUtils.truncate(columnName, 50);
|
||||
building.icons[indx] = icon != null ? Icon.called(icon.getName()).of(icon.getFamily()).build() : Icon.called("question").build();
|
||||
return this;
|
||||
}
|
||||
|
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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.settings;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Service for defining plugin specific settings to the Plan config.
|
||||
* <p>
|
||||
* All given paths will be prepended with "Plugins." to place the settings in the plugins config section.
|
||||
* It is recommended to use setting paths {@code "<Plugin_name>.Some_setting"}
|
||||
* <p>
|
||||
* Requires Capability SETTINGS_API
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public interface SettingsService {
|
||||
|
||||
static SettingsService getInstance() {
|
||||
return Optional.ofNullable(SettingsServiceHolder.service)
|
||||
.orElseThrow(() -> new IllegalStateException("SettingsService has not been initialised yet."));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a String from the config or the default value.
|
||||
*
|
||||
* @param path Path in the config
|
||||
* @param defaultValue Supplier for the default value, {@code () -> "Example"}.
|
||||
* @return value in the config
|
||||
*/
|
||||
String getString(String path, Supplier<String> defaultValue);
|
||||
|
||||
/**
|
||||
* Get a Integer from the config or the default value.
|
||||
*
|
||||
* @param path Path in the config
|
||||
* @param defaultValue Supplier for the default value, {@code () -> 500}.
|
||||
* @return value in the config
|
||||
*/
|
||||
Integer getInteger(String path, Supplier<Integer> defaultValue);
|
||||
|
||||
/**
|
||||
* Get a String list from the config or the default value.
|
||||
*
|
||||
* @param path Path in the config
|
||||
* @param defaultValue Supplier for the default value, {@code () -> Arrays.asList("Example", "Another")}.
|
||||
* @return value in the config
|
||||
*/
|
||||
List<String> getStringList(String path, Supplier<List<String>> defaultValue);
|
||||
|
||||
class SettingsServiceHolder {
|
||||
static SettingsService service;
|
||||
|
||||
private SettingsServiceHolder() {
|
||||
/* Static variable holder */
|
||||
}
|
||||
|
||||
static void set(SettingsService service) {
|
||||
SettingsServiceHolder.service = service;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -17,6 +17,7 @@
|
||||
package com.djrapitops.plan.extension.extractor;
|
||||
|
||||
import com.djrapitops.plan.extension.DataExtension;
|
||||
import com.djrapitops.plan.extension.Group;
|
||||
import com.djrapitops.plan.extension.annotation.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.platform.runner.JUnitPlatform;
|
||||
@ -180,6 +181,34 @@ class ExtensionExtractorTest {
|
||||
assertEquals("Extension.method has invalid return type. was: java.lang.Double, expected: com.djrapitops.plan.extension.table.Table", assertThrows(IllegalArgumentException.class, underTest::validateAnnotations).getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void groupProviderMustGroupArray() {
|
||||
@PluginInfo(name = "Extension")
|
||||
class Extension implements DataExtension {
|
||||
@GroupProvider
|
||||
public Double method(UUID playerUUID) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
ExtensionExtractor underTest = new ExtensionExtractor(new Extension());
|
||||
assertEquals("Extension.method has invalid return type. was: java.lang.Double, expected: [Ljava.lang.String; (an array)", assertThrows(IllegalArgumentException.class, underTest::validateAnnotations).getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void groupProviderMustGroupArray2() {
|
||||
@PluginInfo(name = "Extension")
|
||||
class Extension implements DataExtension {
|
||||
@GroupProvider
|
||||
public Group method(UUID playerUUID) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
ExtensionExtractor underTest = new ExtensionExtractor(new Extension());
|
||||
assertEquals("Extension.method has invalid return type. was: com.djrapitops.plan.extension.Group, expected: [Ljava.lang.String; (an array)", assertThrows(IllegalArgumentException.class, underTest::validateAnnotations).getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void booleanProviderCanNotSupplyItsOwnConditional() {
|
||||
@PluginInfo(name = "Extension")
|
||||
|
@ -10,7 +10,7 @@ plugins {
|
||||
id "java"
|
||||
id "jacoco"
|
||||
id "checkstyle"
|
||||
id "org.sonarqube" version "2.7.1"
|
||||
id "org.sonarqube" version "2.8"
|
||||
id "net.ltgt.apt" version "0.21"
|
||||
id "net.ltgt.apt-idea" version "0.21"
|
||||
id "com.github.johnrengelman.shadow" version "5.1.0"
|
||||
@ -22,7 +22,7 @@ allprojects {
|
||||
wrapper.gradleVersion = "5.5.1"
|
||||
|
||||
group "com.djrapitops"
|
||||
version "4.9.4"
|
||||
version "5.0 build %buildNumber%"
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
@ -57,7 +57,6 @@ subprojects {
|
||||
ext.daggerCompilerVersion = "2.24"
|
||||
|
||||
ext.abstractPluginFrameworkVersion = "3.4.2"
|
||||
ext.planPluginBridgeVersion = "4.9.0-R0.3"
|
||||
|
||||
ext.bukkitVersion = "1.13.2-R0.1-SNAPSHOT"
|
||||
ext.spigotVersion = "1.13.2-R0.1-SNAPSHOT"
|
||||
@ -67,17 +66,19 @@ subprojects {
|
||||
ext.velocityVersion = "1.0-SNAPSHOT"
|
||||
ext.redisBungeeVersion = "0.3.8-SNAPSHOT"
|
||||
|
||||
ext.httpClientVersion = "4.5.9"
|
||||
ext.commonsTextVersion = "1.7"
|
||||
ext.httpClientVersion = "4.5.10"
|
||||
ext.commonsTextVersion = "1.8"
|
||||
ext.htmlCompressorVersion = "1.5.2"
|
||||
ext.caffeineVersion = "2.8.0"
|
||||
ext.h2Version = "1.4.199"
|
||||
ext.mysqlVersion = "8.0.17"
|
||||
ext.hikariVersion = "3.3.1"
|
||||
ext.hikariVersion = "3.4.1"
|
||||
ext.slf4jVersion = "1.7.28"
|
||||
ext.geoIpVersion = "2.12.0"
|
||||
ext.gsonVersion = "2.8.5"
|
||||
ext.guavaVersion = "28.0-jre"
|
||||
ext.bstatsVersion = "1.4"
|
||||
ext.placeholderapiVersion = "2.9.2"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@ -102,7 +103,7 @@ subprojects {
|
||||
maven { // bStats Repository
|
||||
url = "https://repo.codemc.org/repository/maven-public"
|
||||
}
|
||||
maven { // PlanPluginBridge Repository
|
||||
maven { // Plan Repository
|
||||
url = "https://dl.bintray.com/rsl1122/Plan-repository"
|
||||
}
|
||||
}
|
||||
@ -114,11 +115,11 @@ subprojects {
|
||||
testAnnotationProcessor "com.google.dagger:dagger-compiler:$daggerCompilerVersion"
|
||||
|
||||
// Test Tooling Dependencies
|
||||
testCompile "org.junit.jupiter:junit-jupiter-engine:5.5.1" // JUnit 5
|
||||
testCompile "org.junit.platform:junit-platform-runner:1.5.1" // JUnit 4 runner for JUnit 5 tests
|
||||
testCompile "org.junit.jupiter:junit-jupiter-params:5.5.1" // JUnit 5, parameterized tests
|
||||
testCompile "org.mockito:mockito-core:3.0.0" // Mockito Core
|
||||
testCompile "org.mockito:mockito-junit-jupiter:3.0.0" // Mockito JUnit 5 Extension
|
||||
testCompile "org.junit.jupiter:junit-jupiter-engine:5.5.2" // JUnit 5
|
||||
testCompile "org.junit.platform:junit-platform-runner:1.5.2" // JUnit 4 runner for JUnit 5 tests
|
||||
testCompile "org.junit.jupiter:junit-jupiter-params:5.5.2" // JUnit 5, parameterized tests
|
||||
testCompile "org.mockito:mockito-core:3.1.0" // Mockito Core
|
||||
testCompile "org.mockito:mockito-junit-jupiter:3.1.0" // Mockito JUnit 5 Extension
|
||||
testCompile "org.seleniumhq.selenium:selenium-java:3.141.59" // Selenium (Browser tests)
|
||||
testCompile "com.jayway.awaitility:awaitility:1.7.0" // Awaitility (Concurrent wait conditions)
|
||||
|
||||
|
@ -1,15 +1,18 @@
|
||||
repositories {
|
||||
maven { // Placeholder API repository
|
||||
url = "http://repo.extendedclip.com/content/repositories/placeholderapi/"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(path: ":common", configuration: 'shadow')
|
||||
|
||||
compileOnly project(":api")
|
||||
|
||||
compile "com.djrapitops:AbstractPluginFramework-bukkit:$abstractPluginFrameworkVersion"
|
||||
compile "org.bstats:bstats-bukkit:$bstatsVersion"
|
||||
compileOnly "me.clip:placeholderapi:$placeholderapiVersion"
|
||||
|
||||
// compileOnly "org.spigotmc:spigot-api:$spigotVersion"
|
||||
// compileOnly "org.bukkit:bukkit:$bukkitVersion"
|
||||
compileOnly "com.destroystokyo.paper:paper-api:$paperVersion"
|
||||
|
||||
// testCompile "org.spigotmc:spigot-api:$spigotVersion"
|
||||
// testCompile "org.bukkit:bukkit:$bukkitVersion"
|
||||
testCompile "com.destroystokyo.paper:paper-api:$paperVersion"
|
||||
|
||||
testCompile project(path: ":common", configuration: 'testArtifacts')
|
||||
|
@ -16,8 +16,9 @@
|
||||
*/
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.gathering.ServerShutdownSave;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.utilities.java.Reflection;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
@ -14,21 +14,20 @@
|
||||
* 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.system.tasks;
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.ShutdownHook;
|
||||
import com.djrapitops.plan.db.tasks.DBCleanTask;
|
||||
import com.djrapitops.plan.delivery.webserver.cache.JSONCache;
|
||||
import com.djrapitops.plan.extension.ExtensionServerMethodCallerTask;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DataGatheringSettings;
|
||||
import com.djrapitops.plan.system.settings.paths.TimeSettings;
|
||||
import com.djrapitops.plan.system.tasks.bukkit.BukkitTPSCountTimer;
|
||||
import com.djrapitops.plan.system.tasks.bukkit.PaperTPSCountTimer;
|
||||
import com.djrapitops.plan.system.tasks.bukkit.PingCountTimerBukkit;
|
||||
import com.djrapitops.plan.system.tasks.server.BootAnalysisTask;
|
||||
import com.djrapitops.plan.system.tasks.server.ConfigStoreTask;
|
||||
import com.djrapitops.plan.system.tasks.server.PeriodicAnalysisTask;
|
||||
import com.djrapitops.plan.gathering.ShutdownHook;
|
||||
import com.djrapitops.plan.gathering.timed.BukkitPingCounter;
|
||||
import com.djrapitops.plan.gathering.timed.BukkitTPSCounter;
|
||||
import com.djrapitops.plan.gathering.timed.PaperTPSCounter;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.DataGatheringSettings;
|
||||
import com.djrapitops.plan.settings.config.paths.TimeSettings;
|
||||
import com.djrapitops.plan.settings.upkeep.ConfigStoreTask;
|
||||
import com.djrapitops.plan.storage.upkeep.DBCleanTask;
|
||||
import com.djrapitops.plan.storage.upkeep.LogsFolderCleanTask;
|
||||
import com.djrapitops.plugin.api.Check;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import com.djrapitops.plugin.task.RunnableFactory;
|
||||
@ -45,14 +44,18 @@ import java.util.concurrent.TimeUnit;
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Singleton
|
||||
public class BukkitTaskSystem extends ServerTaskSystem {
|
||||
public class BukkitTaskSystem extends TaskSystem {
|
||||
|
||||
private final Plan plugin;
|
||||
private final PlanConfig config;
|
||||
private final ShutdownHook shutdownHook;
|
||||
private final PingCountTimerBukkit pingCountTimer;
|
||||
private final JSONCache.CleanTask jsonCacheCleanTask;
|
||||
private final LogsFolderCleanTask logsFolderCleanTask;
|
||||
private final BukkitPingCounter pingCounter;
|
||||
private final ConfigStoreTask configStoreTask;
|
||||
private final DBCleanTask dbCleanTask;
|
||||
private final ExtensionServerMethodCallerTask extensionServerMethodCallerTask;
|
||||
private BukkitTPSCounter tpsCounter;
|
||||
|
||||
@Inject
|
||||
public BukkitTaskSystem(
|
||||
@ -60,61 +63,77 @@ public class BukkitTaskSystem extends ServerTaskSystem {
|
||||
PlanConfig config,
|
||||
ShutdownHook shutdownHook,
|
||||
RunnableFactory runnableFactory,
|
||||
PaperTPSCountTimer paperTPSCountTimer,
|
||||
BukkitTPSCountTimer bukkitTPSCountTimer,
|
||||
BootAnalysisTask bootAnalysisTask,
|
||||
PeriodicAnalysisTask periodicAnalysisTask,
|
||||
PingCountTimerBukkit pingCountTimer,
|
||||
|
||||
PaperTPSCounter paperTPSCountTimer,
|
||||
BukkitTPSCounter bukkitTPSCountTimer,
|
||||
BukkitPingCounter pingCounter,
|
||||
ExtensionServerMethodCallerTask extensionServerMethodCallerTask,
|
||||
|
||||
LogsFolderCleanTask logsFolderCleanTask,
|
||||
PlayersPageRefreshTask playersPageRefreshTask,
|
||||
ConfigStoreTask configStoreTask,
|
||||
DBCleanTask dbCleanTask,
|
||||
ExtensionServerMethodCallerTask extensionServerMethodCallerTask
|
||||
JSONCache.CleanTask jsonCacheCleanTask
|
||||
) {
|
||||
super(
|
||||
runnableFactory,
|
||||
Check.isPaperAvailable() ? paperTPSCountTimer : bukkitTPSCountTimer,
|
||||
config,
|
||||
bootAnalysisTask,
|
||||
periodicAnalysisTask,
|
||||
logsFolderCleanTask,
|
||||
playersPageRefreshTask);
|
||||
super(runnableFactory);
|
||||
this.plugin = plugin;
|
||||
this.config = config;
|
||||
this.shutdownHook = shutdownHook;
|
||||
this.pingCountTimer = pingCountTimer;
|
||||
this.jsonCacheCleanTask = jsonCacheCleanTask;
|
||||
|
||||
this.tpsCounter = Check.isPaperAvailable() ? paperTPSCountTimer : bukkitTPSCountTimer;
|
||||
this.pingCounter = pingCounter;
|
||||
this.extensionServerMethodCallerTask = extensionServerMethodCallerTask;
|
||||
|
||||
this.logsFolderCleanTask = logsFolderCleanTask;
|
||||
this.configStoreTask = configStoreTask;
|
||||
this.dbCleanTask = dbCleanTask;
|
||||
this.extensionServerMethodCallerTask = extensionServerMethodCallerTask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
super.enable();
|
||||
try {
|
||||
Long pingDelay = config.get(TimeSettings.PING_SERVER_ENABLE_DELAY);
|
||||
if (pingDelay < TimeUnit.HOURS.toMillis(1L) && config.get(DataGatheringSettings.PING)) {
|
||||
plugin.registerListener(pingCountTimer);
|
||||
long startDelay = TimeAmount.toTicks(pingDelay, TimeUnit.MILLISECONDS);
|
||||
registerTask(pingCountTimer).runTaskTimer(startDelay, 40L);
|
||||
}
|
||||
} catch (ExceptionInInitializerError | NoClassDefFoundError ignore) {
|
||||
// Running CraftBukkit
|
||||
}
|
||||
registerTPSCounter();
|
||||
registerPingCounter();
|
||||
registerExtensionDataGatheringTask();
|
||||
registerUpkeepTasks();
|
||||
|
||||
shutdownHook.register();
|
||||
}
|
||||
|
||||
private void registerUpkeepTasks() {
|
||||
// +40 ticks / 2 seconds so that update check task runs first.
|
||||
long storeDelay = TimeAmount.toTicks(config.get(TimeSettings.CONFIG_UPDATE_INTERVAL), TimeUnit.MILLISECONDS) + 40;
|
||||
registerTask(configStoreTask).runTaskLaterAsynchronously(storeDelay);
|
||||
|
||||
registerTask(logsFolderCleanTask).runTaskLaterAsynchronously(TimeAmount.toTicks(30L, TimeUnit.SECONDS));
|
||||
registerTask(dbCleanTask).runTaskTimerAsynchronously(
|
||||
TimeAmount.toTicks(20, TimeUnit.SECONDS),
|
||||
TimeAmount.toTicks(config.get(TimeSettings.CLEAN_DATABASE_PERIOD), TimeUnit.MILLISECONDS)
|
||||
);
|
||||
long minute = TimeAmount.toTicks(1, TimeUnit.MINUTES);
|
||||
registerTask(jsonCacheCleanTask).runTaskTimerAsynchronously(minute, minute);
|
||||
}
|
||||
|
||||
private void registerTPSCounter() {
|
||||
registerTask(tpsCounter).runTaskTimer(1000, TimeAmount.toTicks(1L, TimeUnit.SECONDS));
|
||||
}
|
||||
|
||||
private void registerPingCounter() {
|
||||
try {
|
||||
Long pingDelay = config.get(TimeSettings.PING_SERVER_ENABLE_DELAY);
|
||||
if (pingDelay < TimeUnit.HOURS.toMillis(1L) && config.get(DataGatheringSettings.PING)) {
|
||||
plugin.registerListener(pingCounter);
|
||||
long startDelay = TimeAmount.toTicks(pingDelay, TimeUnit.MILLISECONDS);
|
||||
registerTask(pingCounter).runTaskTimer(startDelay, 40L);
|
||||
}
|
||||
} catch (ExceptionInInitializerError | NoClassDefFoundError ignore) {
|
||||
// Running CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
private void registerExtensionDataGatheringTask() {
|
||||
long extensionRefreshPeriod = TimeAmount.toTicks(config.get(TimeSettings.EXTENSION_DATA_REFRESH_PERIOD), TimeUnit.MILLISECONDS);
|
||||
registerTask(extensionServerMethodCallerTask).runTaskTimerAsynchronously(
|
||||
TimeAmount.toTicks(30, TimeUnit.SECONDS), extensionRefreshPeriod
|
||||
);
|
||||
shutdownHook.register();
|
||||
}
|
||||
|
||||
@Override
|
@ -16,16 +16,18 @@
|
||||
*/
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.command.PlanCommand;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.PluginLang;
|
||||
import com.djrapitops.plan.system.settings.theme.PlanColorScheme;
|
||||
import com.djrapitops.plan.addons.placeholderapi.PlaceholderRegistrar;
|
||||
import com.djrapitops.plan.commands.PlanCommand;
|
||||
import com.djrapitops.plan.exceptions.EnableException;
|
||||
import com.djrapitops.plan.gathering.ServerShutdownSave;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.PluginLang;
|
||||
import com.djrapitops.plan.settings.theme.PlanColorScheme;
|
||||
import com.djrapitops.plugin.BukkitPlugin;
|
||||
import com.djrapitops.plugin.benchmarking.Benchmark;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.util.logging.Level;
|
||||
@ -53,6 +55,7 @@ public class Plan extends BukkitPlugin implements PlanPlugin {
|
||||
system.enable();
|
||||
|
||||
registerMetrics();
|
||||
registerPlaceholderAPIExtension();
|
||||
|
||||
logger.debug("Verbose debug messages are enabled.");
|
||||
String benchTime = " (" + timings.end("Enable").map(Benchmark::toDurationString).orElse("-") + ")";
|
||||
@ -79,6 +82,21 @@ public class Plan extends BukkitPlugin implements PlanPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
private void registerPlaceholderAPIExtension() {
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||
runnableFactory.create("Placeholders Registrar", new AbsRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
PlaceholderRegistrar.register(system, errorHandler);
|
||||
} catch (Exception | NoClassDefFoundError | NoSuchMethodError failed) {
|
||||
logger.warn("Failed to register PlaceholderAPI placeholders: " + failed.toString());
|
||||
}
|
||||
}
|
||||
}).runTask();
|
||||
}
|
||||
}
|
||||
|
||||
private void registerMetrics() {
|
||||
Plan plugin = this;
|
||||
// Spigot 1.14 requires Sync events to be fired from a server thread.
|
||||
|
@ -16,16 +16,14 @@
|
||||
*/
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.command.PlanCommand;
|
||||
import com.djrapitops.plan.commands.PlanCommand;
|
||||
import com.djrapitops.plan.gathering.ServerShutdownSave;
|
||||
import com.djrapitops.plan.modules.APFModule;
|
||||
import com.djrapitops.plan.modules.FilesModule;
|
||||
import com.djrapitops.plan.modules.ServerSuperClassBindingModule;
|
||||
import com.djrapitops.plan.modules.SystemObjectProvidingModule;
|
||||
import com.djrapitops.plan.modules.bukkit.BukkitPlanModule;
|
||||
import com.djrapitops.plan.modules.bukkit.BukkitServerPropertiesModule;
|
||||
import com.djrapitops.plan.modules.bukkit.BukkitSuperClassBindingModule;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.pluginbridge.plan.PluginBridgeModule;
|
||||
import dagger.BindsInstance;
|
||||
import dagger.Component;
|
||||
|
||||
@ -43,9 +41,7 @@ import javax.inject.Singleton;
|
||||
APFModule.class,
|
||||
FilesModule.class,
|
||||
BukkitServerPropertiesModule.class,
|
||||
ServerSuperClassBindingModule.class,
|
||||
BukkitSuperClassBindingModule.class,
|
||||
PluginBridgeModule.Bukkit.class
|
||||
BukkitSuperClassBindingModule.class
|
||||
})
|
||||
public interface PlanBukkitComponent {
|
||||
|
||||
|
@ -14,24 +14,23 @@
|
||||
* 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.api.exceptions.connection;
|
||||
package com.djrapitops.plan.addons.placeholderapi;
|
||||
|
||||
import com.djrapitops.plan.PlanSystem;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
||||
/**
|
||||
* Thrown when ConnectionSystem can not find any servers to send request to.
|
||||
* Additional wrapper to register PlaceholderAPI placeholders.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class NoServersException extends WebException {
|
||||
public class PlaceholderRegistrar {
|
||||
|
||||
public NoServersException(String message) {
|
||||
super(message);
|
||||
private PlaceholderRegistrar() {
|
||||
}
|
||||
|
||||
public NoServersException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
public static void register(PlanSystem system, ErrorHandler errorHandler) {
|
||||
new PlanPlaceHolders(system, errorHandler).register();
|
||||
}
|
||||
|
||||
public NoServersException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
/*
|
||||
* 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.addons.placeholderapi;
|
||||
|
||||
import com.djrapitops.plan.PlanSystem;
|
||||
import com.djrapitops.plan.addons.placeholderapi.placeholders.*;
|
||||
import com.djrapitops.plan.delivery.domain.keys.ServerKeys;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatters;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.version.VersionCheckSystem;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Placeholder expansion used to provide data from Plan.
|
||||
*
|
||||
* <p>
|
||||
* <b>Current used services for placeholders:</b>
|
||||
* <ul>
|
||||
* <li>{@link ServerPlaceHolders}:
|
||||
* {@link ServerKeys#TPS},{@link ServerKeys#NAME},
|
||||
* {@link ServerKeys#SERVER_UUID}</li>
|
||||
* <li>{@link OperatorPlaceholders}: {@link ServerKeys#OPERATORS}</li>
|
||||
* <li>{@link WorldTimePlaceHolder}: {@link ServerKeys#WORLD_TIMES}</li>
|
||||
* <li>{@link SessionPlaceHolder}: {@link ServerKeys#SESSIONS},
|
||||
* {@link ServerKeys#PLAYERS},{@link ServerKeys#PING},{@link ServerKeys#ALL_TIME_PEAK_PLAYERS},
|
||||
* {@link ServerKeys#RECENT_PEAK_PLAYERS}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author aidn5
|
||||
*/
|
||||
public class PlanPlaceHolders extends PlaceholderExpansion {
|
||||
public final ErrorHandler errorHandler;
|
||||
|
||||
private final Collection<AbstractPlanPlaceHolder> placeholders = new ArrayList<>();
|
||||
private final VersionCheckSystem versionCheckSystem;
|
||||
|
||||
public PlanPlaceHolders(
|
||||
PlanSystem system,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
this.versionCheckSystem = system.getVersionCheckSystem();
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
PlanConfig config = system.getConfigSystem().getConfig();
|
||||
DBSystem databaseSystem = system.getDatabaseSystem();
|
||||
ServerInfo serverInfo = system.getServerInfo();
|
||||
Formatters formatters = system.getDeliveryUtilities().getFormatters();
|
||||
|
||||
placeholders.add(new ServerPlaceHolders(databaseSystem, serverInfo, formatters));
|
||||
placeholders.add(new OperatorPlaceholders(databaseSystem, serverInfo));
|
||||
placeholders.add(new WorldTimePlaceHolder(databaseSystem, serverInfo, formatters));
|
||||
placeholders.add(new SessionPlaceHolder(config, databaseSystem, serverInfo, formatters));
|
||||
placeholders.add(new PlayerPlaceHolder(databaseSystem, serverInfo, formatters));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean persist() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRegister() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "plan";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlugin() {
|
||||
return "Plan";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthor() {
|
||||
return "Rsl1122";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return versionCheckSystem.getCurrentVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player p, String params) {
|
||||
try {
|
||||
for (AbstractPlanPlaceHolder placeholder : placeholders) {
|
||||
String value = placeholder.onPlaceholderRequest(p, params);
|
||||
if (value == null) continue;
|
||||
|
||||
return value;
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
errorHandler.log(L.WARN, getClass(), e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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.addons.placeholderapi.placeholders;
|
||||
|
||||
import com.djrapitops.plan.addons.placeholderapi.PlanPlaceHolders;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* abstract class used for plan placeholders list. This class contains most used
|
||||
* methods (static methods and non-static one). It is also used as a universe
|
||||
* interface for the Plan-placeholders instances
|
||||
* {@link #onPlaceholderRequest(Player, String)}. Check {@link PlanPlaceHolders}
|
||||
* to learn more how it is used.
|
||||
*
|
||||
* @author aidn5
|
||||
* @see PlanPlaceHolders
|
||||
*/
|
||||
public abstract class AbstractPlanPlaceHolder {
|
||||
|
||||
protected final ServerInfo serverInfo;
|
||||
|
||||
AbstractPlanPlaceHolder(ServerInfo serverInfo) {
|
||||
this.serverInfo = serverInfo;
|
||||
}
|
||||
|
||||
static long now() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
|
||||
static long dayAgo() {
|
||||
return now() - TimeUnit.DAYS.toMillis(1L);
|
||||
}
|
||||
|
||||
static long weekAgo() {
|
||||
return now() - (TimeUnit.DAYS.toMillis(7L));
|
||||
}
|
||||
|
||||
static long monthAgo() {
|
||||
return now() - (TimeUnit.DAYS.toMillis(30L));
|
||||
}
|
||||
|
||||
UUID serverUUID() {
|
||||
return serverInfo.getServerUUID();
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up the placeholder and check if it is registered in this instance.
|
||||
*
|
||||
* @param p the player who is viewing the placeholder
|
||||
* @param params the placeholder to look up to.
|
||||
* @return the value of the placeholder if found, or empty {@link String} if no
|
||||
* value found but the placeholder is registered,
|
||||
* otherwise {@code null}
|
||||
* @throws Exception if any error occurs
|
||||
*/
|
||||
public abstract String onPlaceholderRequest(Player p, String params) throws Exception;
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.addons.placeholderapi.placeholders;
|
||||
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.queries.analysis.PlayerCountQueries;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Placeholders about operators.
|
||||
*
|
||||
* @author aidn5, Rsl1122
|
||||
*/
|
||||
public class OperatorPlaceholders extends AbstractPlanPlaceHolder {
|
||||
|
||||
private final DBSystem dbSystem;
|
||||
|
||||
public OperatorPlaceholders(DBSystem dbSystem, ServerInfo serverInfo) {
|
||||
super(serverInfo);
|
||||
this.dbSystem = dbSystem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player p, String params) throws Exception {
|
||||
if ("operators_total".equalsIgnoreCase(params)) {
|
||||
return dbSystem.getDatabase().query(PlayerCountQueries.operators(serverUUID())).toString();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* 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.addons.placeholderapi.placeholders;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.container.PlayerContainer;
|
||||
import com.djrapitops.plan.delivery.domain.keys.PlayerKeys;
|
||||
import com.djrapitops.plan.delivery.domain.mutators.PingMutator;
|
||||
import com.djrapitops.plan.delivery.domain.mutators.PvpInfoMutator;
|
||||
import com.djrapitops.plan.delivery.domain.mutators.SessionsMutator;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatter;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatters;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.queries.containers.ContainerFetchQueries;
|
||||
import com.djrapitops.plan.utilities.Predicates;
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Placeholders about a player.
|
||||
*
|
||||
* @author aidn5, Rsl1122
|
||||
*/
|
||||
public class PlayerPlaceHolder extends AbstractPlanPlaceHolder {
|
||||
|
||||
private final DBSystem dbSystem;
|
||||
private Formatter<Long> year;
|
||||
|
||||
public PlayerPlaceHolder(
|
||||
DBSystem dbSystem,
|
||||
ServerInfo serverInfo,
|
||||
Formatters formatters
|
||||
) {
|
||||
super(serverInfo);
|
||||
this.dbSystem = dbSystem;
|
||||
year = formatters.yearLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player p, String params) throws Exception {
|
||||
Serializable got = get(params, p.getUniqueId());
|
||||
return got != null ? got.toString() : null;
|
||||
}
|
||||
|
||||
// Checkstyle.OFF: CyclomaticComplexity
|
||||
|
||||
public Serializable get(String params, UUID playerUUID) {
|
||||
PlayerContainer player = getPlayer(playerUUID);
|
||||
|
||||
switch (params.toLowerCase()) {
|
||||
case "player_banned":
|
||||
return player.getValue(PlayerKeys.BANNED)
|
||||
.orElse(Boolean.FALSE) ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
|
||||
case "player_operator":
|
||||
return player.getValue(PlayerKeys.OPERATOR)
|
||||
.orElse(Boolean.FALSE) ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
|
||||
|
||||
case "player_sessions_count":
|
||||
return SessionsMutator.forContainer(player).count();
|
||||
|
||||
case "player_kick_count":
|
||||
return player.getValue(PlayerKeys.KICK_COUNT).orElse(0);
|
||||
case "player_death_count":
|
||||
return player.getValue(PlayerKeys.DEATH_COUNT).orElse(0);
|
||||
case "player_mob_kill_count":
|
||||
return player.getValue(PlayerKeys.MOB_KILL_COUNT).orElse(0);
|
||||
case "player_player_kill_count":
|
||||
return player.getValue(PlayerKeys.PLAYER_KILL_COUNT).orElse(0);
|
||||
case "player_kill_death_ratio":
|
||||
return PvpInfoMutator.forContainer(player).killDeathRatio();
|
||||
|
||||
case "player_ping_average_day":
|
||||
return PingMutator.forContainer(player).filterBy(Predicates.within(dayAgo(), now())).average();
|
||||
case "player_ping_average_week":
|
||||
return PingMutator.forContainer(player).filterBy(Predicates.within(weekAgo(), now())).average();
|
||||
|
||||
case "player_ping_average_month":
|
||||
return PingMutator.forContainer(player).filterBy(Predicates.within(monthAgo(), now())).average();
|
||||
|
||||
case "player_lastseen":
|
||||
return year.apply(player.getValue(PlayerKeys.LAST_SEEN).orElse((long) 0));
|
||||
case "player_registered":
|
||||
return year.apply(player.getValue(PlayerKeys.REGISTERED).orElse((long) 0));
|
||||
|
||||
case "player_time_active":
|
||||
return year.apply(SessionsMutator.forContainer(player)
|
||||
.toActivePlaytime());
|
||||
case "player_time_afk":
|
||||
return year.apply(SessionsMutator.forContainer(player)
|
||||
.toAfkTime());
|
||||
|
||||
case "player_time_total":
|
||||
return year.apply(SessionsMutator.forContainer(player)
|
||||
.toPlaytime());
|
||||
case "player_time_day":
|
||||
return year.apply(SessionsMutator.forContainer(player)
|
||||
.filterSessionsBetween(dayAgo(), now())
|
||||
.toPlaytime());
|
||||
case "player_time_week":
|
||||
return year.apply(SessionsMutator.forContainer(player)
|
||||
.filterSessionsBetween(weekAgo(), now())
|
||||
.toPlaytime());
|
||||
case "player_time_month":
|
||||
return year.apply(SessionsMutator.forContainer(player)
|
||||
.filterSessionsBetween(monthAgo(), now())
|
||||
.toPlaytime());
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Checkstyle.ON: CyclomaticComplexity
|
||||
|
||||
private PlayerContainer getPlayer(UUID playerUUID) {
|
||||
return dbSystem.getDatabase().query(ContainerFetchQueries.fetchPlayerContainer(playerUUID));
|
||||
}
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* 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.addons.placeholderapi.placeholders;
|
||||
|
||||
import com.djrapitops.plan.delivery.formatting.Formatter;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatters;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.TPSQueries;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Placeholders about a servers.
|
||||
*
|
||||
* @author aidn5, Rsl1122
|
||||
*/
|
||||
public class ServerPlaceHolders extends AbstractPlanPlaceHolder {
|
||||
|
||||
private final DBSystem dbSystem;
|
||||
private Formatter<Double> decimals;
|
||||
private Formatter<Double> percentage;
|
||||
|
||||
public ServerPlaceHolders(
|
||||
DBSystem dbSystem,
|
||||
ServerInfo serverInfo,
|
||||
Formatters formatters
|
||||
) {
|
||||
super(serverInfo);
|
||||
this.dbSystem = dbSystem;
|
||||
decimals = formatters.decimals();
|
||||
percentage = formatters.percentage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player p, String params) throws Exception {
|
||||
Database database = dbSystem.getDatabase();
|
||||
UUID serverUUID = serverUUID();
|
||||
Serializable got = get(params, database, serverUUID);
|
||||
return got != null ? got.toString() : null;
|
||||
}
|
||||
|
||||
// Checkstyle.OFF: CyclomaticComplexity
|
||||
|
||||
public Serializable get(String params, Database database, UUID serverUUID) {
|
||||
switch (params.toLowerCase()) {
|
||||
case "server_tps_day":
|
||||
return decimals.apply(database.query(TPSQueries.averageTPS(dayAgo(), now(), serverUUID)));
|
||||
case "server_tps_week":
|
||||
return decimals.apply(database.query(TPSQueries.averageTPS(weekAgo(), now(), serverUUID)));
|
||||
case "server_tps_month":
|
||||
return decimals.apply(database.query(TPSQueries.averageTPS(monthAgo(), now(), serverUUID)));
|
||||
|
||||
case "server_cpu_day":
|
||||
return percentage.apply(database.query(TPSQueries.averageCPU(dayAgo(), now(), serverUUID)));
|
||||
case "server_cpu_week":
|
||||
return percentage.apply(database.query(TPSQueries.averageCPU(weekAgo(), now(), serverUUID)));
|
||||
case "server_cpu_month":
|
||||
return percentage.apply(database.query(TPSQueries.averageCPU(monthAgo(), now(), serverUUID)));
|
||||
|
||||
case "server_ram_day":
|
||||
return database.query(TPSQueries.averageRAM(dayAgo(), now(), serverUUID)) + " MB";
|
||||
case "server_ram_week":
|
||||
return database.query(TPSQueries.averageRAM(weekAgo(), now(), serverUUID)) + " MB";
|
||||
case "server_ram_month":
|
||||
return database.query(TPSQueries.averageRAM(monthAgo(), now(), serverUUID)) + " MB";
|
||||
|
||||
case "server_chunks_day":
|
||||
return database.query(TPSQueries.averageChunks(dayAgo(), now(), serverUUID));
|
||||
case "server_chunks_week":
|
||||
return database.query(TPSQueries.averageChunks(weekAgo(), now(), serverUUID));
|
||||
case "server_chunks_month":
|
||||
return database.query(TPSQueries.averageChunks(monthAgo(), now(), serverUUID));
|
||||
|
||||
case "server_entities_day":
|
||||
return database.query(TPSQueries.averageEntities(dayAgo(), now(), serverUUID));
|
||||
case "server_entities_week":
|
||||
return database.query(TPSQueries.averageEntities(weekAgo(), now(), serverUUID));
|
||||
case "server_entities_month":
|
||||
return database.query(TPSQueries.averageEntities(monthAgo(), now(), serverUUID));
|
||||
|
||||
case "server_max_free_disk_day":
|
||||
return database.query(TPSQueries.maxFreeDisk(dayAgo(), now(), serverUUID));
|
||||
case "server_max_free_disk_week":
|
||||
return database.query(TPSQueries.maxFreeDisk(weekAgo(), now(), serverUUID));
|
||||
case "server_max_free_disk_month":
|
||||
return database.query(TPSQueries.maxFreeDisk(monthAgo(), now(), serverUUID));
|
||||
|
||||
case "server_min_free_disk_day":
|
||||
return database.query(TPSQueries.minFreeDisk(dayAgo(), now(), serverUUID));
|
||||
case "server_min_free_disk_week":
|
||||
return database.query(TPSQueries.minFreeDisk(weekAgo(), now(), serverUUID));
|
||||
case "server_min_free_disk_month":
|
||||
return database.query(TPSQueries.minFreeDisk(monthAgo(), now(), serverUUID));
|
||||
|
||||
case "server_average_free_disk_day":
|
||||
return database.query(TPSQueries.averageFreeDisk(dayAgo(), now(), serverUUID));
|
||||
case "server_average_free_disk_week":
|
||||
return database.query(TPSQueries.averageFreeDisk(weekAgo(), now(), serverUUID));
|
||||
case "server_average_free_disk_month":
|
||||
return database.query(TPSQueries.averageFreeDisk(monthAgo(), now(), serverUUID));
|
||||
|
||||
case "server_name":
|
||||
return serverInfo.getServer().getName();
|
||||
case "server_uuid":
|
||||
return serverInfo.getServerUUID();
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Checkstyle.ON: CyclomaticComplexity
|
||||
}
|
@ -0,0 +1,195 @@
|
||||
/*
|
||||
* 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.addons.placeholderapi.placeholders;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.DateHolder;
|
||||
import com.djrapitops.plan.delivery.domain.DateObj;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatter;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatters;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.queries.analysis.PlayerCountQueries;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.KillQueries;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.PingQueries;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.SessionQueries;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.TPSQueries;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Placeholders about a sessions.
|
||||
*
|
||||
* @author aidn5, Rsl1122
|
||||
*/
|
||||
public class SessionPlaceHolder extends AbstractPlanPlaceHolder {
|
||||
|
||||
private final DBSystem dbSystem;
|
||||
private Formatter<Long> timeAmount;
|
||||
private int tzOffsetMs;
|
||||
private Formatter<DateHolder> year;
|
||||
|
||||
public SessionPlaceHolder(
|
||||
PlanConfig config,
|
||||
DBSystem dbSystem,
|
||||
ServerInfo serverInfo,
|
||||
Formatters formatters
|
||||
) {
|
||||
super(serverInfo);
|
||||
this.dbSystem = dbSystem;
|
||||
|
||||
tzOffsetMs = config.getTimeZone().getOffset(System.currentTimeMillis());
|
||||
timeAmount = formatters.timeAmount();
|
||||
year = formatters.year();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player p, String params) throws Exception {
|
||||
Serializable got = get(params);
|
||||
return got != null ? got.toString() : null;
|
||||
}
|
||||
|
||||
// Checkstyle.OFF: CyclomaticComplexity
|
||||
|
||||
public Serializable get(String params) {
|
||||
Database database = dbSystem.getDatabase();
|
||||
UUID serverUUID = serverUUID();
|
||||
|
||||
switch (params.toLowerCase()) {
|
||||
|
||||
case "sessions_play_time_total":
|
||||
return timeAmount.apply(database.query(SessionQueries.playtime(0L, now(), serverUUID)));
|
||||
case "sessions_play_time_day":
|
||||
return timeAmount.apply(database.query(SessionQueries.playtime(dayAgo(), now(), serverUUID)));
|
||||
case "sessions_play_time_week":
|
||||
return timeAmount.apply(database.query(SessionQueries.playtime(weekAgo(), now(), serverUUID)));
|
||||
case "sessions_play_time_month":
|
||||
return timeAmount.apply(database.query(SessionQueries.playtime(monthAgo(), now(), serverUUID)));
|
||||
|
||||
case "sessions_active_time_total":
|
||||
return timeAmount.apply(database.query(SessionQueries.activePlaytime(0L, now(), serverUUID)));
|
||||
case "sessions_active_time_day":
|
||||
return timeAmount.apply(database.query(SessionQueries.activePlaytime(dayAgo(), now(), serverUUID)));
|
||||
case "sessions_active_time_week":
|
||||
return timeAmount.apply(database.query(SessionQueries.activePlaytime(weekAgo(), now(), serverUUID)));
|
||||
case "sessions_active_time_month":
|
||||
return timeAmount.apply(database.query(SessionQueries.activePlaytime(monthAgo(), now(), serverUUID)));
|
||||
|
||||
case "sessions_afk_time_total":
|
||||
return timeAmount.apply(database.query(SessionQueries.afkTime(0L, now(), serverUUID)));
|
||||
case "sessions_afk_time_day":
|
||||
return timeAmount.apply(database.query(SessionQueries.afkTime(dayAgo(), now(), serverUUID)));
|
||||
case "sessions_afk_time_week":
|
||||
return timeAmount.apply(database.query(SessionQueries.afkTime(weekAgo(), now(), serverUUID)));
|
||||
case "sessions_afk_time_month":
|
||||
return timeAmount.apply(database.query(SessionQueries.afkTime(monthAgo(), now(), serverUUID)));
|
||||
|
||||
case "sessions_unique_players_total":
|
||||
case "sessions_new_players_total":
|
||||
return database.query(PlayerCountQueries.newPlayerCount(0L, now(), serverUUID));
|
||||
case "sessions_unique_players_day":
|
||||
return database.query(PlayerCountQueries.uniquePlayerCount(dayAgo(), now(), serverUUID));
|
||||
case "sessions_unique_players_week":
|
||||
return database.query(PlayerCountQueries.uniquePlayerCount(weekAgo(), now(), serverUUID));
|
||||
case "sessions_unique_players_month":
|
||||
return database.query(PlayerCountQueries.uniquePlayerCount(monthAgo(), now(), serverUUID));
|
||||
|
||||
case "sessions_players_death_total":
|
||||
return database.query(KillQueries.deathCount(0L, now(), serverUUID));
|
||||
case "sessions_players_death_day":
|
||||
return database.query(KillQueries.deathCount(dayAgo(), now(), serverUUID));
|
||||
case "sessions_players_death_week":
|
||||
return database.query(KillQueries.deathCount(weekAgo(), now(), serverUUID));
|
||||
case "sessions_players_death_month":
|
||||
return database.query(KillQueries.deathCount(monthAgo(), now(), serverUUID));
|
||||
|
||||
case "sessions_players_kill_total":
|
||||
return database.query(KillQueries.playerKillCount(0L, now(), serverUUID));
|
||||
case "sessions_players_kill_day":
|
||||
return database.query(KillQueries.playerKillCount(dayAgo(), now(), serverUUID));
|
||||
case "sessions_players_kill_week":
|
||||
return database.query(KillQueries.playerKillCount(weekAgo(), now(), serverUUID));
|
||||
case "sessions_players_kill_month":
|
||||
return database.query(KillQueries.playerKillCount(monthAgo(), now(), serverUUID));
|
||||
|
||||
case "sessions_mob_kill_total":
|
||||
return database.query(KillQueries.mobKillCount(0L, now(), serverUUID));
|
||||
case "sessions_mob_kill_day":
|
||||
return database.query(KillQueries.mobKillCount(dayAgo(), now(), serverUUID));
|
||||
case "sessions_mob_kill_week":
|
||||
return database.query(KillQueries.mobKillCount(weekAgo(), now(), serverUUID));
|
||||
case "sessions_mob_kill_month":
|
||||
return database.query(KillQueries.mobKillCount(monthAgo(), now(), serverUUID));
|
||||
|
||||
case "sessions_average_session_length_total":
|
||||
return getPlaytime(database, 0L, now(), serverUUID);
|
||||
case "sessions_average_session_length_day":
|
||||
return getPlaytime(database, dayAgo(), now(), serverUUID);
|
||||
case "sessions_average_session_length_week":
|
||||
return getPlaytime(database, weekAgo(), now(), serverUUID);
|
||||
case "sessions_average_session_length_month":
|
||||
return getPlaytime(database, monthAgo(), now(), serverUUID);
|
||||
|
||||
case "sessions_average_unique_players_total":
|
||||
return database.query(PlayerCountQueries.averageUniquePlayerCount(0L, now(), tzOffsetMs, serverUUID));
|
||||
case "sessions_average_unique_players_day":
|
||||
return database.query(PlayerCountQueries.averageUniquePlayerCount(dayAgo(), now(), tzOffsetMs, serverUUID));
|
||||
case "sessions_average_unique_players_week":
|
||||
return database.query(PlayerCountQueries.averageUniquePlayerCount(weekAgo(), now(), tzOffsetMs, serverUUID));
|
||||
case "sessions_average_unique_players_month":
|
||||
return database.query(PlayerCountQueries.averageUniquePlayerCount(monthAgo(), now(), tzOffsetMs, serverUUID));
|
||||
case "sessions_new_players_day":
|
||||
return database.query(PlayerCountQueries.newPlayerCount(dayAgo(), now(), serverUUID));
|
||||
case "sessions_new_players_week":
|
||||
return database.query(PlayerCountQueries.newPlayerCount(weekAgo(), now(), serverUUID));
|
||||
case "sessions_new_players_month":
|
||||
return database.query(PlayerCountQueries.newPlayerCount(monthAgo(), now(), serverUUID));
|
||||
|
||||
case "ping_total":
|
||||
return database.query(PingQueries.averagePing(0L, now(), serverUUID));
|
||||
case "ping_day":
|
||||
return database.query(PingQueries.averagePing(dayAgo(), now(), serverUUID));
|
||||
case "ping_week":
|
||||
return database.query(PingQueries.averagePing(weekAgo(), now(), serverUUID));
|
||||
case "ping_month":
|
||||
return database.query(PingQueries.averagePing(monthAgo(), now(), serverUUID));
|
||||
|
||||
case "sessions_peak_count":
|
||||
return database.query(TPSQueries.fetchAllTimePeakPlayerCount(serverUUID)).map(DateObj::getValue).orElse(0);
|
||||
case "sessions_peak_date":
|
||||
return database.query(TPSQueries.fetchAllTimePeakPlayerCount(serverUUID)).map(year).orElse("-");
|
||||
|
||||
case "sessions_recent_peak_count":
|
||||
return database.query(TPSQueries.fetchPeakPlayerCount(serverUUID, dayAgo() * 2L)).map(DateObj::getValue).orElse(0);
|
||||
case "sessions_recent_peak_date":
|
||||
return database.query(TPSQueries.fetchPeakPlayerCount(serverUUID, dayAgo() * 2L)).map(year).orElse("-");
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// Checkstyle.ON: CyclomaticComplexity
|
||||
|
||||
private String getPlaytime(Database database, long after, long before, UUID serverUUID) {
|
||||
Long playtime = database.query(SessionQueries.playtime(after, before, serverUUID));
|
||||
Long sessionCount = database.query(SessionQueries.sessionCount(after, before, serverUUID));
|
||||
return timeAmount.apply(sessionCount != 0 ? playtime / sessionCount : playtime);
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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.addons.placeholderapi.placeholders;
|
||||
|
||||
import com.djrapitops.plan.delivery.formatting.Formatter;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatters;
|
||||
import com.djrapitops.plan.gathering.domain.WorldTimes;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.WorldTimesQueries;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Placeholders about a world times.
|
||||
*
|
||||
* @author aidn5, Rsl1122
|
||||
*/
|
||||
public class WorldTimePlaceHolder extends AbstractPlanPlaceHolder {
|
||||
|
||||
private final DBSystem dbSystem;
|
||||
private Formatter<Long> timeAmount;
|
||||
|
||||
public WorldTimePlaceHolder(
|
||||
DBSystem dbSystem,
|
||||
ServerInfo serverInfo,
|
||||
Formatters formatters
|
||||
) {
|
||||
super(serverInfo);
|
||||
this.dbSystem = dbSystem;
|
||||
timeAmount = formatters.timeAmount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player p, String params) throws Exception {
|
||||
String string = params.toLowerCase();
|
||||
|
||||
if (StringUtils.startsWith(string, "worlds_playtime_total_")) {
|
||||
// get world total play time
|
||||
// e.g. "plan_worlds_playtime_total_%worldname%"
|
||||
// where %worldname% is "world_nether"
|
||||
|
||||
String worldName = StringUtils.removeStart(string, "worlds_playtime_total_");
|
||||
WorldTimes worldTimes = dbSystem.getDatabase().query(WorldTimesQueries.fetchServerTotalWorldTimes(serverUUID()));
|
||||
|
||||
return timeAmount.apply(worldTimes.getWorldPlaytime(worldName));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -14,9 +14,9 @@
|
||||
* 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.system.importing;
|
||||
package com.djrapitops.plan.gathering.importing;
|
||||
|
||||
import com.djrapitops.plan.system.importing.importers.OfflinePlayerImporter;
|
||||
import com.djrapitops.plan.gathering.importing.importers.OfflinePlayerImporter;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
@ -14,10 +14,10 @@
|
||||
* 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.system.importing.data;
|
||||
package com.djrapitops.plan.gathering.importing.data;
|
||||
|
||||
import com.djrapitops.plan.DebugChannels;
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.system.DebugChannels;
|
||||
import com.djrapitops.plugin.api.utility.UUIDFetcher;
|
||||
import com.djrapitops.plugin.benchmarking.Timings;
|
||||
import org.bukkit.OfflinePlayer;
|
@ -14,25 +14,21 @@
|
||||
* 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.system.importing.importers;
|
||||
package com.djrapitops.plan.gathering.importing.importers;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.data.container.BaseUser;
|
||||
import com.djrapitops.plan.data.container.GeoInfo;
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.container.UserInfo;
|
||||
import com.djrapitops.plan.data.store.objects.Nickname;
|
||||
import com.djrapitops.plan.data.time.WorldTimes;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.access.queries.LargeStoreQueries;
|
||||
import com.djrapitops.plan.db.access.queries.objects.UserIdentifierQueries;
|
||||
import com.djrapitops.plan.db.access.transactions.Transaction;
|
||||
import com.djrapitops.plan.system.cache.GeolocationCache;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.importing.data.BukkitUserImportRefiner;
|
||||
import com.djrapitops.plan.system.importing.data.ServerImportData;
|
||||
import com.djrapitops.plan.system.importing.data.UserImportData;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.delivery.domain.Nickname;
|
||||
import com.djrapitops.plan.gathering.cache.GeolocationCache;
|
||||
import com.djrapitops.plan.gathering.domain.*;
|
||||
import com.djrapitops.plan.gathering.importing.data.BukkitUserImportRefiner;
|
||||
import com.djrapitops.plan.gathering.importing.data.ServerImportData;
|
||||
import com.djrapitops.plan.gathering.importing.data.UserImportData;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.queries.LargeStoreQueries;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.UserIdentifierQueries;
|
||||
import com.djrapitops.plan.storage.database.transactions.Transaction;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import java.util.*;
|
||||
@ -102,7 +98,6 @@ public abstract class BukkitImporter implements Importer {
|
||||
@Override
|
||||
protected void performOperations() {
|
||||
execute(LargeStoreQueries.storeAllTPSData(Collections.singletonMap(serverUUID.get(), serverImportData.getTpsData())));
|
||||
execute(LargeStoreQueries.storeAllCommandUsageData(Collections.singletonMap(serverUUID.get(), serverImportData.getCommandUsages())));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -204,7 +199,7 @@ public abstract class BukkitImporter implements Importer {
|
||||
return userImportData.getIps().parallelStream()
|
||||
.map(ip -> {
|
||||
String geoLoc = geolocationCache.getCountry(ip);
|
||||
return new GeoInfo(ip, geoLoc, date);
|
||||
return new GeoInfo(geoLoc, date);
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
}
|
@ -14,14 +14,14 @@
|
||||
* 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.system.importing.importers;
|
||||
package com.djrapitops.plan.gathering.importing.importers;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.system.cache.GeolocationCache;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.importing.data.ServerImportData;
|
||||
import com.djrapitops.plan.system.importing.data.UserImportData;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.gathering.cache.GeolocationCache;
|
||||
import com.djrapitops.plan.gathering.importing.data.ServerImportData;
|
||||
import com.djrapitops.plan.gathering.importing.data.UserImportData;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
@ -14,14 +14,13 @@
|
||||
* 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.system.listeners;
|
||||
package com.djrapitops.plan.gathering.listeners;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.events.PlanBukkitEnableEvent;
|
||||
import com.djrapitops.plan.capability.CapabilityServiceImplementation;
|
||||
import com.djrapitops.plan.system.listeners.bukkit.*;
|
||||
import com.djrapitops.plan.system.status.Status;
|
||||
import com.djrapitops.plan.gathering.listeners.bukkit.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@ -36,9 +35,8 @@ public class BukkitListenerSystem extends ListenerSystem {
|
||||
private final ChatListener chatListener;
|
||||
private final GameModeChangeListener gamemodeChangeListener;
|
||||
private final WorldChangeListener worldChangeListener;
|
||||
private final CommandListener commandListener;
|
||||
private final DeathEventListener deathEventListener;
|
||||
private final AFKListener afkListener;
|
||||
private final BukkitAFKListener afkListener;
|
||||
|
||||
@Inject
|
||||
public BukkitListenerSystem(Plan plugin,
|
||||
@ -47,9 +45,8 @@ public class BukkitListenerSystem extends ListenerSystem {
|
||||
ChatListener chatListener,
|
||||
GameModeChangeListener gamemodeChangeListener,
|
||||
WorldChangeListener worldChangeListener,
|
||||
CommandListener commandListener,
|
||||
DeathEventListener deathEventListener,
|
||||
AFKListener afkListener
|
||||
BukkitAFKListener afkListener
|
||||
) {
|
||||
this.plugin = plugin;
|
||||
this.status = status;
|
||||
@ -58,7 +55,6 @@ public class BukkitListenerSystem extends ListenerSystem {
|
||||
this.chatListener = chatListener;
|
||||
this.gamemodeChangeListener = gamemodeChangeListener;
|
||||
this.worldChangeListener = worldChangeListener;
|
||||
this.commandListener = commandListener;
|
||||
this.deathEventListener = deathEventListener;
|
||||
this.afkListener = afkListener;
|
||||
}
|
||||
@ -70,7 +66,6 @@ public class BukkitListenerSystem extends ListenerSystem {
|
||||
chatListener,
|
||||
gamemodeChangeListener,
|
||||
worldChangeListener,
|
||||
commandListener,
|
||||
deathEventListener,
|
||||
afkListener
|
||||
);
|
@ -14,11 +14,11 @@
|
||||
* 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.system.listeners.bukkit;
|
||||
package com.djrapitops.plan.gathering.listeners.bukkit;
|
||||
|
||||
import com.djrapitops.plan.system.afk.AFKTracker;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.gathering.afk.AFKTracker;
|
||||
import com.djrapitops.plan.settings.Permissions;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -40,7 +40,7 @@ import java.util.UUID;
|
||||
* @author Rsl1122
|
||||
* @see PlayerOnlineListener
|
||||
*/
|
||||
public class AFKListener implements Listener {
|
||||
public class BukkitAFKListener implements Listener {
|
||||
|
||||
// Static so that /reload does not cause afk tracking to fail.
|
||||
static AFKTracker AFK_TRACKER;
|
||||
@ -49,11 +49,11 @@ public class AFKListener implements Listener {
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
public AFKListener(PlanConfig config, ErrorHandler errorHandler) {
|
||||
public BukkitAFKListener(PlanConfig config, ErrorHandler errorHandler) {
|
||||
this.errorHandler = errorHandler;
|
||||
this.ignorePermissionInfo = new HashMap<>();
|
||||
|
||||
AFKListener.assignAFKTracker(config);
|
||||
BukkitAFKListener.assignAFKTracker(config);
|
||||
}
|
||||
|
||||
private static void assignAFKTracker(PlanConfig config) {
|
@ -14,13 +14,13 @@
|
||||
* 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.system.listeners.bukkit;
|
||||
package com.djrapitops.plan.gathering.listeners.bukkit;
|
||||
|
||||
import com.djrapitops.plan.data.store.objects.Nickname;
|
||||
import com.djrapitops.plan.db.access.transactions.events.NicknameStoreTransaction;
|
||||
import com.djrapitops.plan.system.cache.NicknameCache;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.delivery.domain.Nickname;
|
||||
import com.djrapitops.plan.gathering.cache.NicknameCache;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import org.bukkit.entity.Player;
|
@ -14,15 +14,15 @@
|
||||
* 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.system.listeners.bukkit;
|
||||
package com.djrapitops.plan.gathering.listeners.bukkit;
|
||||
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.processing.processors.player.MobKillProcessor;
|
||||
import com.djrapitops.plan.system.processing.processors.player.PlayerKillProcessor;
|
||||
import com.djrapitops.plan.utilities.formatting.EntityNameFormatter;
|
||||
import com.djrapitops.plan.utilities.formatting.ItemNameFormatter;
|
||||
import com.djrapitops.plan.delivery.formatting.EntityNameFormatter;
|
||||
import com.djrapitops.plan.delivery.formatting.ItemNameFormatter;
|
||||
import com.djrapitops.plan.gathering.cache.SessionCache;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.processing.Processing;
|
||||
import com.djrapitops.plan.processing.processors.player.MobKillProcessor;
|
||||
import com.djrapitops.plan.processing.processors.player.PlayerKillProcessor;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import org.bukkit.Material;
|
@ -14,14 +14,14 @@
|
||||
* 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.system.listeners.bukkit;
|
||||
package com.djrapitops.plan.gathering.listeners.bukkit;
|
||||
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.db.access.transactions.events.WorldNameStoreTransaction;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.settings.config.WorldAliasSettings;
|
||||
import com.djrapitops.plan.gathering.cache.SessionCache;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import org.bukkit.entity.Player;
|
@ -14,24 +14,28 @@
|
||||
* 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.system.listeners.bukkit;
|
||||
package com.djrapitops.plan.gathering.listeners.bukkit;
|
||||
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.store.objects.Nickname;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.access.transactions.events.*;
|
||||
import com.djrapitops.plan.delivery.domain.Nickname;
|
||||
import com.djrapitops.plan.delivery.domain.keys.SessionKeys;
|
||||
import com.djrapitops.plan.delivery.export.Exporter;
|
||||
import com.djrapitops.plan.delivery.webserver.cache.DataID;
|
||||
import com.djrapitops.plan.delivery.webserver.cache.JSONCache;
|
||||
import com.djrapitops.plan.extension.CallEvents;
|
||||
import com.djrapitops.plan.extension.ExtensionServiceImplementation;
|
||||
import com.djrapitops.plan.system.cache.GeolocationCache;
|
||||
import com.djrapitops.plan.system.cache.NicknameCache;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.processing.processors.Processors;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DataGatheringSettings;
|
||||
import com.djrapitops.plan.system.status.Status;
|
||||
import com.djrapitops.plan.gathering.cache.GeolocationCache;
|
||||
import com.djrapitops.plan.gathering.cache.NicknameCache;
|
||||
import com.djrapitops.plan.gathering.cache.SessionCache;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.gathering.listeners.Status;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.processing.Processing;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.DataGatheringSettings;
|
||||
import com.djrapitops.plan.settings.config.paths.ExportSettings;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.*;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -55,11 +59,11 @@ import java.util.UUID;
|
||||
public class PlayerOnlineListener implements Listener {
|
||||
|
||||
private final PlanConfig config;
|
||||
private final Processors processors;
|
||||
private final Processing processing;
|
||||
private final ServerInfo serverInfo;
|
||||
private final DBSystem dbSystem;
|
||||
private final ExtensionServiceImplementation extensionService;
|
||||
private final Exporter exporter;
|
||||
private final GeolocationCache geolocationCache;
|
||||
private final NicknameCache nicknameCache;
|
||||
private final SessionCache sessionCache;
|
||||
@ -69,11 +73,11 @@ public class PlayerOnlineListener implements Listener {
|
||||
@Inject
|
||||
public PlayerOnlineListener(
|
||||
PlanConfig config,
|
||||
Processors processors,
|
||||
Processing processing,
|
||||
ServerInfo serverInfo,
|
||||
DBSystem dbSystem,
|
||||
ExtensionServiceImplementation extensionService,
|
||||
Exporter exporter,
|
||||
GeolocationCache geolocationCache,
|
||||
NicknameCache nicknameCache,
|
||||
SessionCache sessionCache,
|
||||
@ -81,11 +85,11 @@ public class PlayerOnlineListener implements Listener {
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
this.config = config;
|
||||
this.processors = processors;
|
||||
this.processing = processing;
|
||||
this.serverInfo = serverInfo;
|
||||
this.dbSystem = dbSystem;
|
||||
this.extensionService = extensionService;
|
||||
this.exporter = exporter;
|
||||
this.geolocationCache = geolocationCache;
|
||||
this.nicknameCache = nicknameCache;
|
||||
this.sessionCache = sessionCache;
|
||||
@ -122,7 +126,7 @@ public class PlayerOnlineListener implements Listener {
|
||||
return;
|
||||
}
|
||||
UUID uuid = event.getPlayer().getUniqueId();
|
||||
if (AFKListener.AFK_TRACKER.isAfk(uuid)) {
|
||||
if (BukkitAFKListener.AFK_TRACKER.isAfk(uuid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -147,8 +151,10 @@ public class PlayerOnlineListener implements Listener {
|
||||
UUID playerUUID = player.getUniqueId();
|
||||
UUID serverUUID = serverInfo.getServerUUID();
|
||||
long time = System.currentTimeMillis();
|
||||
JSONCache.invalidate(DataID.SERVER_OVERVIEW, serverUUID);
|
||||
JSONCache.invalidate(DataID.GRAPH_PERFORMANCE, serverUUID);
|
||||
|
||||
AFKListener.AFK_TRACKER.performedAction(playerUUID, time);
|
||||
BukkitAFKListener.AFK_TRACKER.performedAction(playerUUID, time);
|
||||
|
||||
String world = player.getWorld().getName();
|
||||
String gm = player.getGameMode().name();
|
||||
@ -169,7 +175,10 @@ public class PlayerOnlineListener implements Listener {
|
||||
}
|
||||
|
||||
database.executeTransaction(new PlayerServerRegisterTransaction(playerUUID, player::getFirstPlayed, playerName, serverUUID));
|
||||
sessionCache.cacheSession(playerUUID, new Session(playerUUID, serverUUID, time, world, gm))
|
||||
Session session = new Session(playerUUID, serverUUID, time, world, gm);
|
||||
session.putRawData(SessionKeys.NAME, playerName);
|
||||
session.putRawData(SessionKeys.SERVER_NAME, serverInfo.getServer().getIdentifiableName());
|
||||
sessionCache.cacheSession(playerUUID, session)
|
||||
.ifPresent(previousSession -> database.executeTransaction(new SessionEndTransaction(previousSession)));
|
||||
|
||||
database.executeTransaction(new NicknameStoreTransaction(
|
||||
@ -177,8 +186,10 @@ public class PlayerOnlineListener implements Listener {
|
||||
(uuid, name) -> name.equals(nicknameCache.getDisplayName(uuid))
|
||||
));
|
||||
|
||||
processing.submitNonCritical(processors.info().playerPageUpdateProcessor(playerUUID));
|
||||
processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, CallEvents.PLAYER_JOIN));
|
||||
if (config.get(ExportSettings.EXPORT_ON_ONLINE_STATUS_CHANGE)) {
|
||||
processing.submitNonCritical(() -> exporter.exportPlayerPage(playerUUID, playerName));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@ -201,9 +212,13 @@ public class PlayerOnlineListener implements Listener {
|
||||
private void actOnQuitEvent(PlayerQuitEvent event) {
|
||||
long time = System.currentTimeMillis();
|
||||
Player player = event.getPlayer();
|
||||
String playerName = player.getName();
|
||||
UUID playerUUID = player.getUniqueId();
|
||||
UUID serverUUID = serverInfo.getServerUUID();
|
||||
JSONCache.invalidate(DataID.SERVER_OVERVIEW, serverUUID);
|
||||
JSONCache.invalidate(DataID.GRAPH_PERFORMANCE, serverUUID);
|
||||
|
||||
AFKListener.AFK_TRACKER.loggedOut(playerUUID, time);
|
||||
BukkitAFKListener.AFK_TRACKER.loggedOut(playerUUID, time);
|
||||
|
||||
nicknameCache.removeDisplayName(playerUUID);
|
||||
|
||||
@ -212,6 +227,8 @@ public class PlayerOnlineListener implements Listener {
|
||||
sessionCache.endSession(playerUUID, time)
|
||||
.ifPresent(endedSession -> dbSystem.getDatabase().executeTransaction(new SessionEndTransaction(endedSession)));
|
||||
|
||||
processing.submit(processors.info().playerPageUpdateProcessor(playerUUID));
|
||||
if (config.get(ExportSettings.EXPORT_ON_ONLINE_STATUS_CHANGE)) {
|
||||
processing.submitNonCritical(() -> exporter.exportPlayerPage(playerUUID, playerName));
|
||||
}
|
||||
}
|
||||
}
|
@ -14,14 +14,14 @@
|
||||
* 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.system.listeners.bukkit;
|
||||
package com.djrapitops.plan.gathering.listeners.bukkit;
|
||||
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.db.access.transactions.events.WorldNameStoreTransaction;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.settings.config.WorldAliasSettings;
|
||||
import com.djrapitops.plan.gathering.cache.SessionCache;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import org.bukkit.entity.Player;
|
@ -21,14 +21,14 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.djrapitops.plan.system.tasks.bukkit;
|
||||
package com.djrapitops.plan.gathering.timed;
|
||||
|
||||
import com.djrapitops.plan.data.store.objects.DateObj;
|
||||
import com.djrapitops.plan.db.access.transactions.events.PingStoreTransaction;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.TimeSettings;
|
||||
import com.djrapitops.plan.delivery.domain.DateObj;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.TimeSettings;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.PingStoreTransaction;
|
||||
import com.djrapitops.plan.utilities.java.Reflection;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
@ -60,7 +60,7 @@ import java.util.logging.Logger;
|
||||
* @author games647
|
||||
*/
|
||||
@Singleton
|
||||
public class PingCountTimerBukkit extends AbsRunnable implements Listener {
|
||||
public class BukkitPingCounter extends AbsRunnable implements Listener {
|
||||
|
||||
//the server is pinging the client every 40 Ticks (2 sec) - so check it then
|
||||
//https://github.com/bergerkiller/CraftSource/blob/master/net.minecraft.server/PlayerConnection.java#L178
|
||||
@ -112,7 +112,7 @@ public class PingCountTimerBukkit extends AbsRunnable implements Listener {
|
||||
private final RunnableFactory runnableFactory;
|
||||
|
||||
@Inject
|
||||
public PingCountTimerBukkit(
|
||||
public BukkitPingCounter(
|
||||
PlanConfig config,
|
||||
DBSystem dbSystem,
|
||||
ServerInfo serverInfo,
|
@ -14,15 +14,14 @@
|
||||
* 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.system.tasks.bukkit;
|
||||
package com.djrapitops.plan.gathering.timed;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.data.container.TPS;
|
||||
import com.djrapitops.plan.data.container.builders.TPSBuilder;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||
import com.djrapitops.plan.system.tasks.TPSCountTimer;
|
||||
import com.djrapitops.plan.gathering.domain.TPS;
|
||||
import com.djrapitops.plan.gathering.domain.builders.TPSBuilder;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.identification.properties.ServerProperties;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import org.bukkit.World;
|
||||
@ -32,14 +31,14 @@ import javax.inject.Singleton;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Singleton
|
||||
public class BukkitTPSCountTimer extends TPSCountTimer {
|
||||
public class BukkitTPSCounter extends TPSCounter {
|
||||
|
||||
protected final Plan plugin;
|
||||
private ServerProperties serverProperties;
|
||||
private long lastCheckNano;
|
||||
|
||||
@Inject
|
||||
public BukkitTPSCountTimer(
|
||||
public BukkitTPSCounter(
|
||||
Plan plugin,
|
||||
DBSystem dbSystem,
|
||||
ServerInfo serverInfo,
|
@ -14,23 +14,23 @@
|
||||
* 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.system.tasks.bukkit;
|
||||
package com.djrapitops.plan.gathering.timed;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.data.container.TPS;
|
||||
import com.djrapitops.plan.data.container.builders.TPSBuilder;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.gathering.domain.TPS;
|
||||
import com.djrapitops.plan.gathering.domain.builders.TPSBuilder;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import org.bukkit.World;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class PaperTPSCountTimer extends BukkitTPSCountTimer {
|
||||
public class PaperTPSCounter extends BukkitTPSCounter {
|
||||
|
||||
@Inject
|
||||
public PaperTPSCountTimer(
|
||||
public PaperTPSCounter(
|
||||
Plan plugin,
|
||||
DBSystem dbSystem,
|
||||
ServerInfo serverInfo,
|
@ -14,7 +14,7 @@
|
||||
* 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.system.info.server.properties;
|
||||
package com.djrapitops.plan.identification.properties;
|
||||
|
||||
import org.bukkit.Server;
|
||||
|
@ -18,7 +18,7 @@ package com.djrapitops.plan.modules.bukkit;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.command.PlanCommand;
|
||||
import com.djrapitops.plan.commands.PlanCommand;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
|
@ -17,8 +17,8 @@
|
||||
package com.djrapitops.plan.modules.bukkit;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.system.info.server.properties.BukkitServerProperties;
|
||||
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||
import com.djrapitops.plan.identification.properties.BukkitServerProperties;
|
||||
import com.djrapitops.plan.identification.properties.ServerProperties;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
|
@ -17,19 +17,19 @@
|
||||
package com.djrapitops.plan.modules.bukkit;
|
||||
|
||||
import com.djrapitops.plan.BukkitServerShutdownSave;
|
||||
import com.djrapitops.plan.ServerShutdownSave;
|
||||
import com.djrapitops.plan.system.database.BukkitDBSystem;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.importing.BukkitImportSystem;
|
||||
import com.djrapitops.plan.system.importing.ImportSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.info.server.ServerServerInfo;
|
||||
import com.djrapitops.plan.system.listeners.BukkitListenerSystem;
|
||||
import com.djrapitops.plan.system.listeners.ListenerSystem;
|
||||
import com.djrapitops.plan.system.settings.BukkitConfigSystem;
|
||||
import com.djrapitops.plan.system.settings.ConfigSystem;
|
||||
import com.djrapitops.plan.system.tasks.BukkitTaskSystem;
|
||||
import com.djrapitops.plan.system.tasks.TaskSystem;
|
||||
import com.djrapitops.plan.BukkitTaskSystem;
|
||||
import com.djrapitops.plan.TaskSystem;
|
||||
import com.djrapitops.plan.gathering.ServerShutdownSave;
|
||||
import com.djrapitops.plan.gathering.importing.BukkitImportSystem;
|
||||
import com.djrapitops.plan.gathering.importing.ImportSystem;
|
||||
import com.djrapitops.plan.gathering.listeners.BukkitListenerSystem;
|
||||
import com.djrapitops.plan.gathering.listeners.ListenerSystem;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.identification.ServerServerInfo;
|
||||
import com.djrapitops.plan.settings.BukkitConfigSystem;
|
||||
import com.djrapitops.plan.settings.ConfigSystem;
|
||||
import com.djrapitops.plan.storage.database.BukkitDBSystem;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
|
||||
|
@ -14,15 +14,12 @@
|
||||
* 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.system.database;
|
||||
package com.djrapitops.plan.storage.database;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.db.H2DB;
|
||||
import com.djrapitops.plan.db.MySQLDB;
|
||||
import com.djrapitops.plan.db.SQLiteDB;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DatabaseSettings;
|
||||
import com.djrapitops.plan.exceptions.EnableException;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.DatabaseSettings;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plugin.benchmarking.Timings;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
@ -1,108 +0,0 @@
|
||||
/*
|
||||
* 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.system.listeners.bukkit;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.db.access.transactions.events.CommandStoreTransaction;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DataGatheringSettings;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Event Listener for PlayerCommandPreprocessEvents.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class CommandListener implements Listener {
|
||||
|
||||
private final Plan plugin;
|
||||
private final PlanConfig config;
|
||||
private final ServerInfo serverInfo;
|
||||
private final DBSystem dbSystem;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
public CommandListener(
|
||||
Plan plugin,
|
||||
PlanConfig config,
|
||||
ServerInfo serverInfo,
|
||||
DBSystem dbSystem,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
this.plugin = plugin;
|
||||
this.config = config;
|
||||
this.serverInfo = serverInfo;
|
||||
this.dbSystem = dbSystem;
|
||||
this.errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
|
||||
boolean hasIgnorePermission = event.getPlayer().hasPermission(Permissions.IGNORE_COMMAND_USE.getPermission());
|
||||
if (event.isCancelled() || hasIgnorePermission) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
actOnCommandEvent(event);
|
||||
} catch (Exception e) {
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void actOnCommandEvent(PlayerCommandPreprocessEvent event) {
|
||||
String commandName = event.getMessage().substring(1).split(" ")[0].toLowerCase();
|
||||
|
||||
boolean logUnknownCommands = config.isTrue(DataGatheringSettings.LOG_UNKNOWN_COMMANDS);
|
||||
boolean combineCommandAliases = config.isTrue(DataGatheringSettings.COMBINE_COMMAND_ALIASES);
|
||||
|
||||
if (!logUnknownCommands || combineCommandAliases) {
|
||||
Command command = getBukkitCommand(commandName);
|
||||
if (command == null) {
|
||||
if (!logUnknownCommands) {
|
||||
return;
|
||||
}
|
||||
} else if (combineCommandAliases) {
|
||||
commandName = command.getName();
|
||||
}
|
||||
}
|
||||
dbSystem.getDatabase().executeTransaction(new CommandStoreTransaction(serverInfo.getServerUUID(), commandName));
|
||||
}
|
||||
|
||||
private Command getBukkitCommand(String commandName) {
|
||||
Command command = plugin.getServer().getPluginCommand(commandName);
|
||||
if (command == null) {
|
||||
try {
|
||||
command = plugin.getServer().getCommandMap().getCommand(commandName);
|
||||
} catch (NoSuchMethodError ignored) {
|
||||
/* Ignored, Bukkit 1.8 has no such method. This method is from Paper */
|
||||
}
|
||||
}
|
||||
return command;
|
||||
}
|
||||
}
|
@ -16,21 +16,19 @@
|
||||
*/
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.access.queries.objects.ServerQueries;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plan.system.settings.ConfigSettingKeyTest;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.WebserverSettings;
|
||||
import com.djrapitops.plan.system.settings.paths.key.Setting;
|
||||
import com.djrapitops.plan.exceptions.EnableException;
|
||||
import com.djrapitops.plan.identification.Server;
|
||||
import com.djrapitops.plan.settings.ConfigSettingKeyTest;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.WebserverSettings;
|
||||
import com.djrapitops.plan.settings.config.paths.key.Setting;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.ServerQueries;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import org.junit.platform.runner.JUnitPlatform;
|
||||
import org.junit.runner.RunWith;
|
||||
import utilities.OptionalAssert;
|
||||
import utilities.RandomData;
|
||||
import utilities.mocks.BukkitMockComponent;
|
||||
|
||||
@ -38,6 +36,7 @@ import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
|
||||
@ -78,7 +77,7 @@ public class BukkitSystemTest {
|
||||
Optional<String> found = database.query(ServerQueries.fetchServerMatchingIdentifier(system.getServerInfo().getServerUUID()))
|
||||
.map(Server::getWebAddress);
|
||||
|
||||
OptionalAssert.equals(expectedAddress, found);
|
||||
assertEquals(expectedAddress, found.orElse(null));
|
||||
} finally {
|
||||
system.disable();
|
||||
}
|
||||
|
@ -14,11 +14,11 @@
|
||||
* 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.system.listeners;
|
||||
package com.djrapitops.plan.gathering.listeners;
|
||||
|
||||
import com.djrapitops.plan.system.listeners.bukkit.AFKListener;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.TimeSettings;
|
||||
import com.djrapitops.plan.gathering.listeners.bukkit.BukkitAFKListener;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.TimeSettings;
|
||||
import com.djrapitops.plugin.logging.console.TestPluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ConsoleErrorLogger;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -37,21 +37,21 @@ import java.util.concurrent.TimeUnit;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* Test for {@link AFKListener}
|
||||
* Test for {@link BukkitAFKListener}
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@RunWith(JUnitPlatform.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class AFKListenerTest {
|
||||
public class BukkitAFKListenerTest {
|
||||
|
||||
private static AFKListener underTest;
|
||||
private static BukkitAFKListener underTest;
|
||||
|
||||
@BeforeAll
|
||||
static void setUp() {
|
||||
PlanConfig config = Mockito.mock(PlanConfig.class);
|
||||
when(config.get(TimeSettings.AFK_THRESHOLD)).thenReturn(TimeUnit.MINUTES.toMillis(3));
|
||||
underTest = new AFKListener(config, new ConsoleErrorLogger(new TestPluginLogger()));
|
||||
underTest = new BukkitAFKListener(config, new ConsoleErrorLogger(new TestPluginLogger()));
|
||||
}
|
||||
|
||||
@Test
|
@ -19,7 +19,7 @@ package utilities.mocks;
|
||||
import com.djrapitops.plan.DaggerPlanBukkitComponent;
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.PlanBukkitComponent;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.PlanSystem;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
|
@ -38,9 +38,9 @@ import utilities.mocks.objects.TestLogger;
|
||||
import utilities.mocks.objects.TestRunnableFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
|
||||
@ -90,11 +90,10 @@ public class PlanBukkitMocker extends Mocker {
|
||||
}
|
||||
|
||||
PlanBukkitMocker withPluginDescription() {
|
||||
try {
|
||||
File pluginYml = getFile("/plugin.yml");
|
||||
PluginDescriptionFile description = new PluginDescriptionFile(new FileInputStream(pluginYml));
|
||||
try (InputStream in = Files.newInputStream(getFile("/plugin.yml").toPath())) {
|
||||
PluginDescriptionFile description = new PluginDescriptionFile(in);
|
||||
doReturn(description).when(planMock).getDescription();
|
||||
} catch (FileNotFoundException | InvalidDescriptionException e) {
|
||||
} catch (IOException | InvalidDescriptionException e) {
|
||||
System.out.println("Error while setting plugin description");
|
||||
}
|
||||
return this;
|
||||
|
@ -1,5 +1,6 @@
|
||||
dependencies {
|
||||
compile project(path: ":common", configuration: 'shadow')
|
||||
compileOnly project(":api")
|
||||
|
||||
compile "com.djrapitops:AbstractPluginFramework-bungeecord:$abstractPluginFrameworkVersion"
|
||||
compile "org.bstats:bstats-bungeecord:$bstatsVersion"
|
||||
|
@ -16,24 +16,22 @@
|
||||
*/
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.ServerQueries;
|
||||
import org.bstats.bungeecord.Metrics;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class BStatsBungee {
|
||||
|
||||
private final PlanBungee plugin;
|
||||
private final Database database;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
|
||||
private Metrics metrics;
|
||||
|
||||
public BStatsBungee(PlanBungee plugin, Database database, ConnectionSystem connectionSystem) {
|
||||
public BStatsBungee(PlanBungee plugin, Database database) {
|
||||
this.plugin = plugin;
|
||||
this.database = database;
|
||||
this.connectionSystem = connectionSystem;
|
||||
}
|
||||
|
||||
public void registerMetrics() {
|
||||
@ -44,15 +42,12 @@ public class BStatsBungee {
|
||||
}
|
||||
|
||||
private void registerConfigSettingGraphs() {
|
||||
String serverType = plugin.getProxy().getName();
|
||||
String databaseType = database.getType().getName();
|
||||
|
||||
addStringSettingPie("server_type", serverType);
|
||||
addStringSettingPie("database_type", databaseType);
|
||||
addStringSettingPie("network_servers", connectionSystem.getDataServers().size());
|
||||
addStringSettingPie("server_type", () -> plugin.getProxy().getName());
|
||||
addStringSettingPie("database_type", () -> database.getType().getName());
|
||||
addStringSettingPie("network_servers", () -> String.valueOf(database.query(ServerQueries.fetchPlanServerInformationCollection()).size()));
|
||||
}
|
||||
|
||||
protected void addStringSettingPie(String id, Serializable setting) {
|
||||
metrics.addCustomChart(new Metrics.SimplePie(id, setting::toString));
|
||||
protected void addStringSettingPie(String id, Supplier<String> setting) {
|
||||
metrics.addCustomChart(new Metrics.SimplePie(id, setting::get));
|
||||
}
|
||||
}
|
||||
|
@ -14,18 +14,18 @@
|
||||
* 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.system.tasks;
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.PlanBungee;
|
||||
import com.djrapitops.plan.db.tasks.DBCleanTask;
|
||||
import com.djrapitops.plan.delivery.webserver.cache.JSONCache;
|
||||
import com.djrapitops.plan.extension.ExtensionServerMethodCallerTask;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DataGatheringSettings;
|
||||
import com.djrapitops.plan.system.settings.paths.TimeSettings;
|
||||
import com.djrapitops.plan.system.tasks.bungee.BungeeTPSCountTimer;
|
||||
import com.djrapitops.plan.system.tasks.bungee.PingCountTimerBungee;
|
||||
import com.djrapitops.plan.system.tasks.proxy.NetworkConfigStoreTask;
|
||||
import com.djrapitops.plan.system.tasks.proxy.NetworkPageRefreshTask;
|
||||
import com.djrapitops.plan.gathering.timed.BungeePingCounter;
|
||||
import com.djrapitops.plan.gathering.timed.BungeeTPSCounter;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.DataGatheringSettings;
|
||||
import com.djrapitops.plan.settings.config.paths.TimeSettings;
|
||||
import com.djrapitops.plan.settings.upkeep.NetworkConfigStoreTask;
|
||||
import com.djrapitops.plan.storage.upkeep.DBCleanTask;
|
||||
import com.djrapitops.plan.storage.upkeep.LogsFolderCleanTask;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import com.djrapitops.plugin.task.RunnableFactory;
|
||||
|
||||
@ -43,12 +43,12 @@ public class BungeeTaskSystem extends TaskSystem {
|
||||
|
||||
private final PlanBungee plugin;
|
||||
private final PlanConfig config;
|
||||
private final NetworkPageRefreshTask networkPageRefreshTask;
|
||||
private final PingCountTimerBungee pingCountTimer;
|
||||
private final BungeeTPSCounter tpsCounter;
|
||||
private final BungeePingCounter pingCounter;
|
||||
private final LogsFolderCleanTask logsFolderCleanTask;
|
||||
private final PlayersPageRefreshTask playersPageRefreshTask;
|
||||
private final NetworkConfigStoreTask networkConfigStoreTask;
|
||||
private final DBCleanTask dbCleanTask;
|
||||
private final JSONCache.CleanTask jsonCacheCleanTask;
|
||||
private final ExtensionServerMethodCallerTask extensionServerMethodCallerTask;
|
||||
|
||||
@Inject
|
||||
@ -56,25 +56,24 @@ public class BungeeTaskSystem extends TaskSystem {
|
||||
PlanBungee plugin,
|
||||
PlanConfig config,
|
||||
RunnableFactory runnableFactory,
|
||||
BungeeTPSCountTimer bungeeTPSCountTimer,
|
||||
NetworkPageRefreshTask networkPageRefreshTask,
|
||||
PingCountTimerBungee pingCountTimer,
|
||||
BungeeTPSCounter tpsCounter,
|
||||
BungeePingCounter pingCounter,
|
||||
LogsFolderCleanTask logsFolderCleanTask,
|
||||
PlayersPageRefreshTask playersPageRefreshTask,
|
||||
NetworkConfigStoreTask networkConfigStoreTask,
|
||||
DBCleanTask dbCleanTask,
|
||||
JSONCache.CleanTask jsonCacheCleanTask,
|
||||
ExtensionServerMethodCallerTask extensionServerMethodCallerTask
|
||||
) {
|
||||
super(runnableFactory, bungeeTPSCountTimer);
|
||||
super(runnableFactory);
|
||||
this.plugin = plugin;
|
||||
this.config = config;
|
||||
this.tpsCounter = tpsCounter;
|
||||
|
||||
this.networkPageRefreshTask = networkPageRefreshTask;
|
||||
this.pingCountTimer = pingCountTimer;
|
||||
this.pingCounter = pingCounter;
|
||||
this.logsFolderCleanTask = logsFolderCleanTask;
|
||||
this.playersPageRefreshTask = playersPageRefreshTask;
|
||||
this.networkConfigStoreTask = networkConfigStoreTask;
|
||||
this.dbCleanTask = dbCleanTask;
|
||||
this.jsonCacheCleanTask = jsonCacheCleanTask;
|
||||
this.extensionServerMethodCallerTask = extensionServerMethodCallerTask;
|
||||
}
|
||||
|
||||
@ -84,20 +83,16 @@ public class BungeeTaskSystem extends TaskSystem {
|
||||
}
|
||||
|
||||
private void registerTasks() {
|
||||
registerTask(tpsCountTimer).runTaskTimerAsynchronously(1000, TimeAmount.toTicks(1L, TimeUnit.SECONDS));
|
||||
registerTask(networkPageRefreshTask).runTaskTimerAsynchronously(1500, TimeAmount.toTicks(5L, TimeUnit.MINUTES));
|
||||
registerTask(tpsCounter).runTaskTimerAsynchronously(1000, TimeAmount.toTicks(1L, TimeUnit.SECONDS));
|
||||
registerTask(logsFolderCleanTask).runTaskLaterAsynchronously(TimeAmount.toTicks(30L, TimeUnit.SECONDS));
|
||||
|
||||
Long pingDelay = config.get(TimeSettings.PING_SERVER_ENABLE_DELAY);
|
||||
if (pingDelay < TimeUnit.HOURS.toMillis(1L) && config.get(DataGatheringSettings.PING)) {
|
||||
plugin.registerListener(pingCountTimer);
|
||||
plugin.registerListener(pingCounter);
|
||||
long startDelay = TimeAmount.toTicks(pingDelay, TimeUnit.MILLISECONDS);
|
||||
registerTask(pingCountTimer).runTaskTimer(startDelay, 40L);
|
||||
registerTask(pingCounter).runTaskTimer(startDelay, 40L);
|
||||
}
|
||||
|
||||
registerTask(playersPageRefreshTask)
|
||||
.runTaskTimerAsynchronously(TimeAmount.toTicks(5L, TimeUnit.MINUTES), TimeAmount.toTicks(5L, TimeUnit.MINUTES));
|
||||
|
||||
// +40 ticks / 2 seconds so that update check task runs first.
|
||||
long storeDelay = TimeAmount.toTicks(config.get(TimeSettings.CONFIG_UPDATE_INTERVAL), TimeUnit.MILLISECONDS) + 40;
|
||||
registerTask(networkConfigStoreTask).runTaskLaterAsynchronously(storeDelay);
|
||||
@ -106,6 +101,8 @@ public class BungeeTaskSystem extends TaskSystem {
|
||||
TimeAmount.toTicks(20, TimeUnit.SECONDS),
|
||||
TimeAmount.toTicks(config.get(TimeSettings.CLEAN_DATABASE_PERIOD), TimeUnit.MILLISECONDS)
|
||||
);
|
||||
long minute = TimeAmount.toTicks(1, TimeUnit.MINUTES);
|
||||
registerTask(jsonCacheCleanTask).runTaskTimerAsynchronously(minute, minute);
|
||||
|
||||
long extensionRefreshPeriod = TimeAmount.toTicks(config.get(TimeSettings.EXTENSION_DATA_REFRESH_PERIOD), TimeUnit.MILLISECONDS);
|
||||
registerTask(extensionServerMethodCallerTask).runTaskTimerAsynchronously(
|
@ -16,12 +16,11 @@
|
||||
*/
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.command.PlanProxyCommand;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.PluginLang;
|
||||
import com.djrapitops.plan.system.settings.theme.PlanColorScheme;
|
||||
import com.djrapitops.plan.commands.PlanProxyCommand;
|
||||
import com.djrapitops.plan.exceptions.EnableException;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.PluginLang;
|
||||
import com.djrapitops.plan.settings.theme.PlanColorScheme;
|
||||
import com.djrapitops.plugin.BungeePlugin;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
@ -48,8 +47,7 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin {
|
||||
|
||||
new BStatsBungee(
|
||||
this,
|
||||
system.getDatabaseSystem().getDatabase(),
|
||||
system.getInfoSystem().getConnectionSystem()
|
||||
system.getDatabaseSystem().getDatabase()
|
||||
).registerMetrics();
|
||||
|
||||
logger.info(locale.getString(PluginLang.ENABLED));
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.command.PlanProxyCommand;
|
||||
import com.djrapitops.plan.commands.PlanProxyCommand;
|
||||
import com.djrapitops.plan.modules.APFModule;
|
||||
import com.djrapitops.plan.modules.FilesModule;
|
||||
import com.djrapitops.plan.modules.ProxySuperClassBindingModule;
|
||||
@ -25,8 +25,6 @@ import com.djrapitops.plan.modules.bungee.BungeeCommandModule;
|
||||
import com.djrapitops.plan.modules.bungee.BungeePlanModule;
|
||||
import com.djrapitops.plan.modules.bungee.BungeeServerPropertiesModule;
|
||||
import com.djrapitops.plan.modules.bungee.BungeeSuperClassBindingModule;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.pluginbridge.plan.PluginBridgeModule;
|
||||
import dagger.BindsInstance;
|
||||
import dagger.Component;
|
||||
|
||||
@ -46,8 +44,7 @@ import javax.inject.Singleton;
|
||||
FilesModule.class,
|
||||
ProxySuperClassBindingModule.class,
|
||||
BungeeSuperClassBindingModule.class,
|
||||
BungeeServerPropertiesModule.class,
|
||||
PluginBridgeModule.Bungee.class
|
||||
BungeeServerPropertiesModule.class
|
||||
})
|
||||
public interface PlanBungeeComponent {
|
||||
|
||||
|
@ -14,13 +14,13 @@
|
||||
* 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.system.listeners;
|
||||
package com.djrapitops.plan.gathering.listeners;
|
||||
|
||||
import com.djrapitops.plan.PlanBungee;
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.events.PlanBungeeEnableEvent;
|
||||
import com.djrapitops.plan.capability.CapabilityServiceImplementation;
|
||||
import com.djrapitops.plan.system.listeners.bungee.PlayerOnlineListener;
|
||||
import com.djrapitops.plan.gathering.listeners.bungee.PlayerOnlineListener;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -0,0 +1,203 @@
|
||||
/*
|
||||
* 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.gathering.listeners.bungee;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.keys.SessionKeys;
|
||||
import com.djrapitops.plan.delivery.export.Exporter;
|
||||
import com.djrapitops.plan.delivery.webserver.cache.DataID;
|
||||
import com.djrapitops.plan.delivery.webserver.cache.JSONCache;
|
||||
import com.djrapitops.plan.extension.CallEvents;
|
||||
import com.djrapitops.plan.extension.ExtensionServiceImplementation;
|
||||
import com.djrapitops.plan.gathering.cache.GeolocationCache;
|
||||
import com.djrapitops.plan.gathering.cache.SessionCache;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.processing.Processing;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.DataGatheringSettings;
|
||||
import com.djrapitops.plan.settings.config.paths.ExportSettings;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.GeoInfoStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.api.event.ServerSwitchEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.event.EventPriority;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.net.InetAddress;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Player Join listener for Bungee.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class PlayerOnlineListener implements Listener {
|
||||
|
||||
private final PlanConfig config;
|
||||
private final Processing processing;
|
||||
private final DBSystem dbSystem;
|
||||
private final ExtensionServiceImplementation extensionService;
|
||||
private final Exporter exporter;
|
||||
private final GeolocationCache geolocationCache;
|
||||
private final SessionCache sessionCache;
|
||||
private final ServerInfo serverInfo;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
public PlayerOnlineListener(
|
||||
PlanConfig config,
|
||||
Processing processing,
|
||||
DBSystem dbSystem,
|
||||
ExtensionServiceImplementation extensionService,
|
||||
Exporter exporter, GeolocationCache geolocationCache,
|
||||
SessionCache sessionCache,
|
||||
ServerInfo serverInfo,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
this.config = config;
|
||||
this.processing = processing;
|
||||
this.dbSystem = dbSystem;
|
||||
this.extensionService = extensionService;
|
||||
this.exporter = exporter;
|
||||
this.geolocationCache = geolocationCache;
|
||||
this.sessionCache = sessionCache;
|
||||
this.serverInfo = serverInfo;
|
||||
this.errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPostLogin(PostLoginEvent event) {
|
||||
try {
|
||||
actOnLogin(event);
|
||||
} catch (Exception e) {
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void actOnLogin(PostLoginEvent event) {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
UUID playerUUID = player.getUniqueId();
|
||||
String playerName = player.getName();
|
||||
InetAddress address = player.getAddress().getAddress();
|
||||
long time = System.currentTimeMillis();
|
||||
|
||||
Session session = new Session(playerUUID, serverInfo.getServerUUID(), time, null, null);
|
||||
session.putRawData(SessionKeys.NAME, playerName);
|
||||
session.putRawData(SessionKeys.SERVER_NAME, "Proxy Server");
|
||||
sessionCache.cacheSession(playerUUID, session);
|
||||
Database database = dbSystem.getDatabase();
|
||||
|
||||
boolean gatheringGeolocations = config.isTrue(DataGatheringSettings.GEOLOCATIONS);
|
||||
if (gatheringGeolocations) {
|
||||
database.executeTransaction(
|
||||
new GeoInfoStoreTransaction(playerUUID, address, time, geolocationCache::getCountry)
|
||||
);
|
||||
}
|
||||
|
||||
database.executeTransaction(new PlayerRegisterTransaction(playerUUID, () -> time, playerName));
|
||||
processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, CallEvents.PLAYER_JOIN));
|
||||
if (config.get(ExportSettings.EXPORT_ON_ONLINE_STATUS_CHANGE)) {
|
||||
processing.submitNonCritical(() -> exporter.exportPlayerPage(playerUUID, playerName));
|
||||
}
|
||||
|
||||
UUID serverUUID = serverInfo.getServerUUID();
|
||||
JSONCache.invalidateMatching(DataID.SERVER_OVERVIEW);
|
||||
JSONCache.invalidate(DataID.GRAPH_ONLINE, serverUUID);
|
||||
JSONCache.invalidate(DataID.SERVERS);
|
||||
JSONCache.invalidate(DataID.SESSIONS);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void beforeLogout(PlayerDisconnectEvent event) {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
UUID playerUUID = player.getUniqueId();
|
||||
String playerName = player.getName();
|
||||
processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, CallEvents.PLAYER_LEAVE));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onLogout(PlayerDisconnectEvent event) {
|
||||
try {
|
||||
actOnLogout(event);
|
||||
} catch (Exception e) {
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void actOnLogout(PlayerDisconnectEvent event) {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
String playerName = player.getName();
|
||||
UUID playerUUID = player.getUniqueId();
|
||||
|
||||
sessionCache.endSession(playerUUID, System.currentTimeMillis());
|
||||
if (config.get(ExportSettings.EXPORT_ON_ONLINE_STATUS_CHANGE)) {
|
||||
processing.submitNonCritical(() -> exporter.exportPlayerPage(playerUUID, playerName));
|
||||
}
|
||||
processing.submit(() -> {
|
||||
JSONCache.invalidateMatching(
|
||||
DataID.SERVER_OVERVIEW,
|
||||
DataID.SESSIONS,
|
||||
DataID.GRAPH_WORLD_PIE,
|
||||
DataID.GRAPH_PUNCHCARD,
|
||||
DataID.KILLS,
|
||||
DataID.ONLINE_OVERVIEW,
|
||||
DataID.SESSIONS_OVERVIEW,
|
||||
DataID.PVP_PVE,
|
||||
DataID.GRAPH_UNIQUE_NEW,
|
||||
DataID.GRAPH_CALENDAR
|
||||
);
|
||||
UUID serverUUID = serverInfo.getServerUUID();
|
||||
JSONCache.invalidate(DataID.GRAPH_ONLINE, serverUUID);
|
||||
JSONCache.invalidate(DataID.SERVERS);
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onServerSwitch(ServerSwitchEvent event) {
|
||||
try {
|
||||
actOnServerSwitch(event);
|
||||
} catch (Exception e) {
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void actOnServerSwitch(ServerSwitchEvent event) {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
String playerName = player.getName();
|
||||
UUID playerUUID = player.getUniqueId();
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
// Replaces the current session in the cache.
|
||||
Session session = new Session(playerUUID, serverInfo.getServerUUID(), time, null, null);
|
||||
session.putRawData(SessionKeys.NAME, playerName);
|
||||
session.putRawData(SessionKeys.SERVER_NAME, "Proxy Server");
|
||||
sessionCache.cacheSession(playerUUID, session);
|
||||
if (config.get(ExportSettings.EXPORT_ON_ONLINE_STATUS_CHANGE)) {
|
||||
processing.submitNonCritical(() -> exporter.exportPlayerPage(playerUUID, playerName));
|
||||
}
|
||||
|
||||
JSONCache.invalidate(DataID.SERVERS);
|
||||
}
|
||||
}
|
@ -21,14 +21,14 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.djrapitops.plan.system.tasks.bungee;
|
||||
package com.djrapitops.plan.gathering.timed;
|
||||
|
||||
import com.djrapitops.plan.data.store.objects.DateObj;
|
||||
import com.djrapitops.plan.db.access.transactions.events.PingStoreTransaction;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.TimeSettings;
|
||||
import com.djrapitops.plan.delivery.domain.DateObj;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.TimeSettings;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.PingStoreTransaction;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
import com.djrapitops.plugin.task.RunnableFactory;
|
||||
@ -50,7 +50,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* @author BrainStone
|
||||
*/
|
||||
@Singleton
|
||||
public class PingCountTimerBungee extends AbsRunnable implements Listener {
|
||||
public class BungeePingCounter extends AbsRunnable implements Listener {
|
||||
|
||||
private final Map<UUID, List<DateObj<Integer>>> playerHistory;
|
||||
|
||||
@ -60,7 +60,7 @@ public class PingCountTimerBungee extends AbsRunnable implements Listener {
|
||||
private final RunnableFactory runnableFactory;
|
||||
|
||||
@Inject
|
||||
public PingCountTimerBungee(
|
||||
public BungeePingCounter(
|
||||
PlanConfig config,
|
||||
DBSystem dbSystem,
|
||||
ServerInfo serverInfo,
|
@ -14,14 +14,13 @@
|
||||
* 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.system.tasks.bungee;
|
||||
package com.djrapitops.plan.gathering.timed;
|
||||
|
||||
import com.djrapitops.plan.data.container.TPS;
|
||||
import com.djrapitops.plan.data.container.builders.TPSBuilder;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||
import com.djrapitops.plan.system.tasks.TPSCountTimer;
|
||||
import com.djrapitops.plan.gathering.domain.TPS;
|
||||
import com.djrapitops.plan.gathering.domain.builders.TPSBuilder;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.identification.properties.ServerProperties;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
||||
@ -29,12 +28,12 @@ import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class BungeeTPSCountTimer extends TPSCountTimer {
|
||||
public class BungeeTPSCounter extends TPSCounter {
|
||||
|
||||
private final ServerProperties serverProperties;
|
||||
|
||||
@Inject
|
||||
public BungeeTPSCountTimer(
|
||||
public BungeeTPSCounter(
|
||||
DBSystem dbSystem,
|
||||
ServerInfo serverInfo,
|
||||
ServerProperties serverProperties,
|
@ -14,16 +14,16 @@
|
||||
* 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.system.info.server;
|
||||
package com.djrapitops.plan.identification;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.access.queries.objects.ServerQueries;
|
||||
import com.djrapitops.plan.db.access.transactions.StoreServerInformationTransaction;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
import com.djrapitops.plan.delivery.webserver.WebServer;
|
||||
import com.djrapitops.plan.exceptions.EnableException;
|
||||
import com.djrapitops.plan.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.identification.properties.ServerProperties;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.ServerQueries;
|
||||
import com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import dagger.Lazy;
|
||||
|
@ -14,10 +14,10 @@
|
||||
* 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.system.info.server.properties;
|
||||
package com.djrapitops.plan.identification.properties;
|
||||
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.ProxySettings;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.ProxySettings;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
|
||||
/**
|
@ -14,7 +14,7 @@
|
||||
* 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.system.info.server.properties;
|
||||
package com.djrapitops.plan.identification.properties;
|
||||
|
||||
import com.djrapitops.plugin.api.Check;
|
||||
|
@ -14,7 +14,7 @@
|
||||
* 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.system.info.server.properties;
|
||||
package com.djrapitops.plan.identification.properties;
|
||||
|
||||
import com.imaginarycode.minecraft.redisbungee.RedisBungee;
|
||||
|
@ -18,7 +18,7 @@ package com.djrapitops.plan.modules.bungee;
|
||||
|
||||
import com.djrapitops.plan.PlanBungee;
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.command.PlanProxyCommand;
|
||||
import com.djrapitops.plan.commands.PlanProxyCommand;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
|
@ -17,9 +17,9 @@
|
||||
package com.djrapitops.plan.modules.bungee;
|
||||
|
||||
import com.djrapitops.plan.PlanBungee;
|
||||
import com.djrapitops.plan.system.info.server.properties.BungeeServerProperties;
|
||||
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.identification.properties.BungeeServerProperties;
|
||||
import com.djrapitops.plan.identification.properties.ServerProperties;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
|
@ -16,12 +16,12 @@
|
||||
*/
|
||||
package com.djrapitops.plan.modules.bungee;
|
||||
|
||||
import com.djrapitops.plan.system.info.server.BungeeServerInfo;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.listeners.BungeeListenerSystem;
|
||||
import com.djrapitops.plan.system.listeners.ListenerSystem;
|
||||
import com.djrapitops.plan.system.tasks.BungeeTaskSystem;
|
||||
import com.djrapitops.plan.system.tasks.TaskSystem;
|
||||
import com.djrapitops.plan.BungeeTaskSystem;
|
||||
import com.djrapitops.plan.TaskSystem;
|
||||
import com.djrapitops.plan.gathering.listeners.BungeeListenerSystem;
|
||||
import com.djrapitops.plan.gathering.listeners.ListenerSystem;
|
||||
import com.djrapitops.plan.identification.BungeeServerInfo;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
|
||||
|
@ -1,153 +0,0 @@
|
||||
/*
|
||||
* 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.system.listeners.bungee;
|
||||
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.access.transactions.events.GeoInfoStoreTransaction;
|
||||
import com.djrapitops.plan.db.access.transactions.events.PlayerRegisterTransaction;
|
||||
import com.djrapitops.plan.extension.CallEvents;
|
||||
import com.djrapitops.plan.extension.ExtensionServiceImplementation;
|
||||
import com.djrapitops.plan.system.cache.GeolocationCache;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.processing.processors.Processors;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DataGatheringSettings;
|
||||
import com.djrapitops.plan.system.webserver.cache.PageId;
|
||||
import com.djrapitops.plan.system.webserver.cache.ResponseCache;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.api.event.ServerSwitchEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.event.EventPriority;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.net.InetAddress;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Player Join listener for Bungee.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class PlayerOnlineListener implements Listener {
|
||||
|
||||
private final PlanConfig config;
|
||||
private final Processors processors;
|
||||
private final Processing processing;
|
||||
private final DBSystem dbSystem;
|
||||
private final ExtensionServiceImplementation extensionService;
|
||||
private final GeolocationCache geolocationCache;
|
||||
private final SessionCache sessionCache;
|
||||
private final ServerInfo serverInfo;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
public PlayerOnlineListener(
|
||||
PlanConfig config,
|
||||
Processors processors,
|
||||
Processing processing,
|
||||
DBSystem dbSystem,
|
||||
ExtensionServiceImplementation extensionService,
|
||||
GeolocationCache geolocationCache,
|
||||
SessionCache sessionCache,
|
||||
ServerInfo serverInfo,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
this.config = config;
|
||||
this.processors = processors;
|
||||
this.processing = processing;
|
||||
this.dbSystem = dbSystem;
|
||||
this.extensionService = extensionService;
|
||||
this.geolocationCache = geolocationCache;
|
||||
this.sessionCache = sessionCache;
|
||||
this.serverInfo = serverInfo;
|
||||
this.errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPostLogin(PostLoginEvent event) {
|
||||
try {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
UUID playerUUID = player.getUniqueId();
|
||||
String playerName = player.getName();
|
||||
InetAddress address = player.getAddress().getAddress();
|
||||
long time = System.currentTimeMillis();
|
||||
|
||||
sessionCache.cacheSession(playerUUID, new Session(playerUUID, serverInfo.getServerUUID(), time, null, null));
|
||||
Database database = dbSystem.getDatabase();
|
||||
|
||||
boolean gatheringGeolocations = config.isTrue(DataGatheringSettings.GEOLOCATIONS);
|
||||
if (gatheringGeolocations) {
|
||||
database.executeTransaction(
|
||||
new GeoInfoStoreTransaction(playerUUID, address, time, geolocationCache::getCountry)
|
||||
);
|
||||
}
|
||||
|
||||
database.executeTransaction(new PlayerRegisterTransaction(playerUUID, () -> time, playerName));
|
||||
processing.submit(processors.info().playerPageUpdateProcessor(playerUUID));
|
||||
processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, CallEvents.PLAYER_JOIN));
|
||||
ResponseCache.clearResponse(PageId.SERVER.of(serverInfo.getServerUUID()));
|
||||
} catch (Exception e) {
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void beforeLogout(PlayerDisconnectEvent event) {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
UUID playerUUID = player.getUniqueId();
|
||||
String playerName = player.getName();
|
||||
processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, CallEvents.PLAYER_LEAVE));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onLogout(PlayerDisconnectEvent event) {
|
||||
try {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
UUID playerUUID = player.getUniqueId();
|
||||
|
||||
sessionCache.endSession(playerUUID, System.currentTimeMillis());
|
||||
processing.submit(processors.info().playerPageUpdateProcessor(playerUUID));
|
||||
ResponseCache.clearResponse(PageId.SERVER.of(serverInfo.getServerUUID()));
|
||||
} catch (Exception e) {
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onServerSwitch(ServerSwitchEvent event) {
|
||||
try {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
UUID playerUUID = player.getUniqueId();
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
// Replaces the current session in the cache.
|
||||
sessionCache.cacheSession(playerUUID, new Session(playerUUID, serverInfo.getServerUUID(), time, null, null));
|
||||
processing.submit(processors.info().playerPageUpdateProcessor(playerUUID));
|
||||
} catch (Exception e) {
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
}
|
||||
}
|
||||
}
|
@ -16,13 +16,12 @@
|
||||
*/
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.db.SQLiteDB;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.ProxySettings;
|
||||
import com.djrapitops.plan.system.settings.paths.WebserverSettings;
|
||||
import com.djrapitops.plan.exceptions.EnableException;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.ProxySettings;
|
||||
import com.djrapitops.plan.settings.config.paths.WebserverSettings;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.SQLiteDB;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -19,7 +19,7 @@ package utilities.mocks;
|
||||
import com.djrapitops.plan.DaggerPlanBungeeComponent;
|
||||
import com.djrapitops.plan.PlanBungee;
|
||||
import com.djrapitops.plan.PlanBungeeComponent;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.PlanSystem;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
|
@ -2,7 +2,6 @@ dependencies {
|
||||
compile "com.djrapitops:AbstractPluginFramework-api:$abstractPluginFrameworkVersion"
|
||||
compile project(":api")
|
||||
compile project(path: ":extensions", configuration: 'shadow')
|
||||
compile "com.djrapitops:PlanPluginBridge:$planPluginBridgeVersion"
|
||||
compile "org.apache.httpcomponents:httpclient:$httpClientVersion"
|
||||
compile "org.apache.commons:commons-text:$commonsTextVersion"
|
||||
compile "com.googlecode.htmlcompressor:htmlcompressor:$htmlCompressorVersion"
|
||||
@ -13,10 +12,10 @@ dependencies {
|
||||
compile "org.slf4j:slf4j-nop:$slf4jVersion"
|
||||
compile "org.slf4j:slf4j-api:$slf4jVersion"
|
||||
compile "com.maxmind.geoip2:geoip2:$geoIpVersion"
|
||||
compileOnly "com.google.guava:guava:$guavaVersion"
|
||||
compile "com.google.code.gson:gson:$gsonVersion"
|
||||
|
||||
testCompile project(":api")
|
||||
testCompile "com.google.code.gson:gson:2.8.5"
|
||||
testCompile "com.google.code.gson:gson:$gsonVersion"
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
@ -41,6 +40,7 @@ shadowJar {
|
||||
relocate 'com.zaxxer', 'plan.com.zaxxer'
|
||||
relocate 'com.github.benmanes', 'plan.com.github.benmanes'
|
||||
relocate 'com.googlecode', 'plan.com.googlecode'
|
||||
relocate 'com.google', 'plan.com.google'
|
||||
relocate 'org.h2', 'plan.org.h2'
|
||||
relocate 'org.bstats', 'plan.org.bstats'
|
||||
relocate 'org.slf4j', 'plan.org.slf4j'
|
||||
|
@ -14,7 +14,7 @@
|
||||
* 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.system;
|
||||
package com.djrapitops.plan;
|
||||
|
||||
/**
|
||||
* Identifiers for different Debug channels.
|
||||
@ -28,10 +28,6 @@ public class DebugChannels {
|
||||
/* Static variable class */
|
||||
}
|
||||
|
||||
public static final String ANALYSIS = "Analysis";
|
||||
public static final String INFO_REQUESTS = "InfoRequests";
|
||||
public static final String CONNECTIONS = "Connections";
|
||||
public static final String WEB_REQUESTS = "Web Requests";
|
||||
public static final String IMPORTING = "Importing";
|
||||
public static final String SQL = "SQL";
|
||||
public static final String DATA_EXTENSIONS = "DataExtensions";
|
@ -16,7 +16,6 @@
|
||||
*/
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plugin.IPlugin;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
|
||||
|
@ -14,30 +14,34 @@
|
||||
* 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.system;
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.api.PlanAPI;
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.capability.CapabilityServiceImplementation;
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.delivery.DeliveryUtilities;
|
||||
import com.djrapitops.plan.delivery.export.ExportSystem;
|
||||
import com.djrapitops.plan.delivery.webserver.NonProxyWebserverDisableChecker;
|
||||
import com.djrapitops.plan.delivery.webserver.WebServer;
|
||||
import com.djrapitops.plan.delivery.webserver.WebServerSystem;
|
||||
import com.djrapitops.plan.exceptions.EnableException;
|
||||
import com.djrapitops.plan.extension.ExtensionService;
|
||||
import com.djrapitops.plan.extension.ExtensionServiceImplementation;
|
||||
import com.djrapitops.plan.gathering.cache.CacheSystem;
|
||||
import com.djrapitops.plan.gathering.importing.ImportSystem;
|
||||
import com.djrapitops.plan.gathering.listeners.ListenerSystem;
|
||||
import com.djrapitops.plan.identification.Server;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.processing.Processing;
|
||||
import com.djrapitops.plan.query.QueryServiceImplementation;
|
||||
import com.djrapitops.plan.system.cache.CacheSystem;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.export.ExportSystem;
|
||||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.importing.ImportSystem;
|
||||
import com.djrapitops.plan.system.info.InfoSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.listeners.ListenerSystem;
|
||||
import com.djrapitops.plan.system.locale.LocaleSystem;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.ConfigSystem;
|
||||
import com.djrapitops.plan.system.tasks.TaskSystem;
|
||||
import com.djrapitops.plan.system.update.VersionCheckSystem;
|
||||
import com.djrapitops.plan.system.webserver.WebServerSystem;
|
||||
import com.djrapitops.plan.settings.ConfigSystem;
|
||||
import com.djrapitops.plan.settings.SettingsServiceImplementation;
|
||||
import com.djrapitops.plan.settings.locale.LocaleSystem;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.ServerQueries;
|
||||
import com.djrapitops.plan.storage.file.PlanFiles;
|
||||
import com.djrapitops.plan.version.VersionCheckSystem;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@ -63,7 +67,6 @@ public class PlanSystem implements SubSystem {
|
||||
private final CacheSystem cacheSystem;
|
||||
private final ListenerSystem listenerSystem;
|
||||
private final TaskSystem taskSystem;
|
||||
private final InfoSystem infoSystem;
|
||||
private final ServerInfo serverInfo;
|
||||
private final WebServerSystem webServerSystem;
|
||||
|
||||
@ -71,11 +74,11 @@ public class PlanSystem implements SubSystem {
|
||||
|
||||
private final ImportSystem importSystem;
|
||||
private final ExportSystem exportSystem;
|
||||
private final HtmlUtilities htmlUtilities;
|
||||
private final HookHandler hookHandler;
|
||||
private final DeliveryUtilities deliveryUtilities;
|
||||
private final ExtensionServiceImplementation extensionService;
|
||||
private final QueryServiceImplementation queryService;
|
||||
private final PlanAPI planAPI;
|
||||
private final SettingsServiceImplementation settingsService;
|
||||
private final PluginLogger logger;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
@ -88,18 +91,18 @@ public class PlanSystem implements SubSystem {
|
||||
CacheSystem cacheSystem,
|
||||
ListenerSystem listenerSystem,
|
||||
TaskSystem taskSystem,
|
||||
InfoSystem infoSystem,
|
||||
ServerInfo serverInfo,
|
||||
WebServerSystem webServerSystem,
|
||||
Processing processing,
|
||||
ImportSystem importSystem,
|
||||
ExportSystem exportSystem,
|
||||
HtmlUtilities htmlUtilities,
|
||||
HookHandler hookHandler,
|
||||
DeliveryUtilities deliveryUtilities,
|
||||
ExtensionServiceImplementation extensionService,
|
||||
QueryServiceImplementation queryService,
|
||||
PlanAPI planAPI,
|
||||
ErrorHandler errorHandler
|
||||
SettingsServiceImplementation settingsService,
|
||||
PluginLogger logger,
|
||||
ErrorHandler errorHandler,
|
||||
PlanAPI.PlanAPIHolder apiHolder
|
||||
) {
|
||||
this.files = files;
|
||||
this.configSystem = configSystem;
|
||||
@ -109,18 +112,36 @@ public class PlanSystem implements SubSystem {
|
||||
this.cacheSystem = cacheSystem;
|
||||
this.listenerSystem = listenerSystem;
|
||||
this.taskSystem = taskSystem;
|
||||
this.infoSystem = infoSystem;
|
||||
this.serverInfo = serverInfo;
|
||||
this.webServerSystem = webServerSystem;
|
||||
this.processing = processing;
|
||||
this.importSystem = importSystem;
|
||||
this.exportSystem = exportSystem;
|
||||
this.htmlUtilities = htmlUtilities;
|
||||
this.hookHandler = hookHandler;
|
||||
this.deliveryUtilities = deliveryUtilities;
|
||||
this.extensionService = extensionService;
|
||||
this.queryService = queryService;
|
||||
this.planAPI = planAPI;
|
||||
this.settingsService = settingsService;
|
||||
this.logger = logger;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
logger.log(L.INFO_COLOR,
|
||||
"",
|
||||
"§2 ██▌",
|
||||
"§2 ██▌ ██▌",
|
||||
"§2 ██▌██▌██▌██▌ §2Player Analytics",
|
||||
"§2 ██▌██▌██▌██▌ §fv" + versionCheckSystem.getCurrentVersion(),
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
public static String getMainAddress(WebServer webServer, DBSystem dbSystem) {
|
||||
return dbSystem.getDatabase().query(ServerQueries.fetchProxyServerInformation())
|
||||
.map(Server::getWebAddress)
|
||||
.orElse(webServer.getAccessAddress());
|
||||
}
|
||||
|
||||
public String getMainAddress() {
|
||||
return PlanSystem.getMainAddress(webServerSystem.getWebServer(), databaseSystem);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -138,12 +159,19 @@ public class PlanSystem implements SubSystem {
|
||||
serverInfo,
|
||||
importSystem,
|
||||
exportSystem,
|
||||
infoSystem,
|
||||
cacheSystem,
|
||||
listenerSystem,
|
||||
taskSystem,
|
||||
hookHandler
|
||||
taskSystem
|
||||
);
|
||||
|
||||
// Disables Webserver if Proxy is detected in the database
|
||||
if (serverInfo.getServer().isNotProxy()) {
|
||||
processing.submitNonCritical(new NonProxyWebserverDisableChecker(
|
||||
configSystem.getConfig(), databaseSystem, webServerSystem, logger, errorHandler
|
||||
));
|
||||
}
|
||||
|
||||
settingsService.register();
|
||||
queryService.register();
|
||||
extensionService.register();
|
||||
enabled = true;
|
||||
@ -160,7 +188,6 @@ public class PlanSystem implements SubSystem {
|
||||
enabled = false;
|
||||
disableSystems(
|
||||
taskSystem,
|
||||
hookHandler,
|
||||
cacheSystem,
|
||||
listenerSystem,
|
||||
importSystem,
|
||||
@ -168,7 +195,6 @@ public class PlanSystem implements SubSystem {
|
||||
processing,
|
||||
databaseSystem,
|
||||
webServerSystem,
|
||||
infoSystem,
|
||||
serverInfo,
|
||||
localeSystem,
|
||||
configSystem,
|
||||
@ -235,18 +261,6 @@ public class PlanSystem implements SubSystem {
|
||||
return cacheSystem;
|
||||
}
|
||||
|
||||
public InfoSystem getInfoSystem() {
|
||||
return infoSystem;
|
||||
}
|
||||
|
||||
public HookHandler getHookHandler() {
|
||||
return hookHandler;
|
||||
}
|
||||
|
||||
public PlanAPI getPlanAPI() {
|
||||
return planAPI;
|
||||
}
|
||||
|
||||
public Processing getProcessing() {
|
||||
return processing;
|
||||
}
|
||||
@ -255,8 +269,8 @@ public class PlanSystem implements SubSystem {
|
||||
return localeSystem;
|
||||
}
|
||||
|
||||
public HtmlUtilities getHtmlUtilities() {
|
||||
return htmlUtilities;
|
||||
public DeliveryUtilities getDeliveryUtilities() {
|
||||
return deliveryUtilities;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
@ -14,9 +14,9 @@
|
||||
* 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.system;
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.exceptions.EnableException;
|
||||
|
||||
/**
|
||||
* Represents a system that can be enabled and disabled.
|
@ -14,9 +14,8 @@
|
||||
* 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.system.tasks;
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.system.SubSystem;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
import com.djrapitops.plugin.task.PluginRunnable;
|
||||
import com.djrapitops.plugin.task.RunnableFactory;
|
||||
@ -30,11 +29,9 @@ import com.djrapitops.plugin.task.RunnableFactory;
|
||||
*/
|
||||
public abstract class TaskSystem implements SubSystem {
|
||||
|
||||
protected final TPSCountTimer tpsCountTimer;
|
||||
protected final RunnableFactory runnableFactory;
|
||||
|
||||
public TaskSystem(RunnableFactory runnableFactory, TPSCountTimer tpsCountTimer) {
|
||||
this.tpsCountTimer = tpsCountTimer;
|
||||
public TaskSystem(RunnableFactory runnableFactory) {
|
||||
this.runnableFactory = runnableFactory;
|
||||
}
|
||||
|
@ -18,17 +18,15 @@ package com.djrapitops.plan.api;
|
||||
|
||||
import com.djrapitops.plan.api.data.PlayerContainer;
|
||||
import com.djrapitops.plan.api.data.ServerContainer;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.data.plugin.PluginData;
|
||||
import com.djrapitops.plan.db.access.Query;
|
||||
import com.djrapitops.plan.db.access.queries.containers.ContainerFetchQueries;
|
||||
import com.djrapitops.plan.db.access.queries.objects.ServerQueries;
|
||||
import com.djrapitops.plan.db.access.queries.objects.UserIdentifierQueries;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.database.databases.operation.FetchOperations;
|
||||
import com.djrapitops.plan.system.database.databases.sql.operation.SQLFetchOps;
|
||||
import com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
import com.djrapitops.plan.delivery.rendering.html.Html;
|
||||
import com.djrapitops.plan.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.identification.UUIDUtility;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.queries.Query;
|
||||
import com.djrapitops.plan.storage.database.queries.containers.ContainerFetchQueries;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.ServerQueries;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.UserIdentifierQueries;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
@ -44,13 +42,14 @@ import java.util.UUID;
|
||||
* PlanAPI extension for all implementations.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @deprecated Plan API v4 has been deprecated, use the APIv5 instead (https://github.com/plan-player-analytics/Plan/wiki/APIv5).
|
||||
*/
|
||||
@Singleton
|
||||
@Deprecated
|
||||
public class CommonAPI implements PlanAPI {
|
||||
|
||||
private final DBSystem dbSystem;
|
||||
private final UUIDUtility uuidUtility;
|
||||
private final HookHandler hookHandler;
|
||||
private final PluginLogger logger;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@ -58,13 +57,11 @@ public class CommonAPI implements PlanAPI {
|
||||
public CommonAPI(
|
||||
DBSystem dbSystem,
|
||||
UUIDUtility uuidUtility,
|
||||
HookHandler hookHandler,
|
||||
PluginLogger logger,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
this.dbSystem = dbSystem;
|
||||
this.uuidUtility = uuidUtility;
|
||||
this.hookHandler = hookHandler;
|
||||
this.logger = logger;
|
||||
this.errorHandler = errorHandler;
|
||||
PlanAPIHolder.set(this);
|
||||
@ -72,7 +69,9 @@ public class CommonAPI implements PlanAPI {
|
||||
|
||||
@Override
|
||||
public void addPluginDataSource(PluginData pluginData) {
|
||||
hookHandler.addPluginDataSource(pluginData);
|
||||
logger.warn(pluginData.getClass().getName() + " was attempted to be registered." +
|
||||
" PluginData API has been decommissioned, so this is a no-op." +
|
||||
" Please move to using DataExtension API. https://github.com/plan-player-analytics/Plan/wiki/APIv5");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -82,7 +81,7 @@ public class CommonAPI implements PlanAPI {
|
||||
|
||||
@Override
|
||||
public String getPlayerInspectPageLink(String playerName) {
|
||||
return "../player/" + playerName;
|
||||
return "../player/" + Html.encodeToURL(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -120,15 +119,6 @@ public class CommonAPI implements PlanAPI {
|
||||
return queryDB(UserIdentifierQueries.fetchPlayerNameOf(playerUUID)).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchOperations fetchFromPlanDB() {
|
||||
logger.warn("PlanAPI#fetchFromPlanDB has been deprecated and will be removed in the future. Stack trace to follow");
|
||||
for (StackTraceElement element : Thread.currentThread().getStackTrace()) {
|
||||
logger.warn(element.toString());
|
||||
}
|
||||
return new SQLFetchOps(dbSystem.getDatabase());
|
||||
}
|
||||
|
||||
private <T> T queryDB(Query<T> query) {
|
||||
return dbSystem.getDatabase().query(query);
|
||||
}
|
||||
|
@ -19,8 +19,13 @@ package com.djrapitops.plan.api;
|
||||
import com.djrapitops.plan.api.data.PlayerContainer;
|
||||
import com.djrapitops.plan.api.data.ServerContainer;
|
||||
import com.djrapitops.plan.data.plugin.PluginData;
|
||||
import com.djrapitops.plan.system.database.databases.operation.FetchOperations;
|
||||
import com.djrapitops.plan.identification.UUIDUtility;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@ -30,7 +35,9 @@ import java.util.UUID;
|
||||
* Interface for PlanAPI methods.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @deprecated Plan API v4 has been deprecated, use the APIv5 instead (https://github.com/plan-player-analytics/Plan/wiki/APIv5).
|
||||
*/
|
||||
@Deprecated
|
||||
public interface PlanAPI {
|
||||
|
||||
static PlanAPI getInstance() {
|
||||
@ -38,6 +45,7 @@ public interface PlanAPI {
|
||||
.orElseThrow(() -> new IllegalStateException("PlanAPI has not been initialised yet."));
|
||||
}
|
||||
|
||||
@Singleton
|
||||
class PlanAPIHolder {
|
||||
static PlanAPI API;
|
||||
|
||||
@ -45,8 +53,14 @@ public interface PlanAPI {
|
||||
PlanAPIHolder.API = api;
|
||||
}
|
||||
|
||||
private PlanAPIHolder() {
|
||||
/* Static variable holder */
|
||||
@Inject
|
||||
public PlanAPIHolder(
|
||||
DBSystem dbSystem,
|
||||
UUIDUtility uuidUtility,
|
||||
PluginLogger logger,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
set(new CommonAPI(dbSystem, uuidUtility, logger, errorHandler));
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,15 +80,6 @@ public interface PlanAPI {
|
||||
|
||||
Map<UUID, String> getKnownPlayerNames();
|
||||
|
||||
/**
|
||||
* Fetch things from the database.
|
||||
*
|
||||
* @return FetchOperations object.
|
||||
* @deprecated FetchOperations interface is going to removed since it is too rigid.
|
||||
*/
|
||||
@Deprecated
|
||||
FetchOperations fetchFromPlanDB();
|
||||
|
||||
/**
|
||||
* Fetch PlayerContainer from the database.
|
||||
* <p>
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
package com.djrapitops.plan.api.data;
|
||||
|
||||
import com.djrapitops.plan.data.store.Key;
|
||||
import com.djrapitops.plan.delivery.domain.keys.Key;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@ -24,22 +24,32 @@ import java.util.Optional;
|
||||
* Wrapper for a PlayerContainer.
|
||||
* <p>
|
||||
* The actual object is wrapped to avoid exposing too much API that might change.
|
||||
* See {@link com.djrapitops.plan.data.store.keys.PlayerKeys} for Key objects.
|
||||
* See {@link com.djrapitops.plan.delivery.domain.keys.PlayerKeys} for Key objects.
|
||||
* <p>
|
||||
* The Keys might change in the future, but the Optional API should help dealing with those cases.
|
||||
*
|
||||
* @deprecated Plan API v4 has been deprecated, use the APIv5 instead (https://github.com/plan-player-analytics/Plan/wiki/APIv5).
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Deprecated
|
||||
public class PlayerContainer {
|
||||
|
||||
private final com.djrapitops.plan.data.store.containers.PlayerContainer container;
|
||||
private final com.djrapitops.plan.delivery.domain.container.PlayerContainer container;
|
||||
|
||||
public PlayerContainer(com.djrapitops.plan.data.store.containers.PlayerContainer container) {
|
||||
public PlayerContainer(com.djrapitops.plan.delivery.domain.container.PlayerContainer container) {
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated loginThreshold no longer used for activity index.
|
||||
*/
|
||||
@Deprecated
|
||||
public double getActivityIndex(long date, long playtimeMsThreshold, int loginThreshold) {
|
||||
return container.getActivityIndex(date, playtimeMsThreshold, loginThreshold).getValue();
|
||||
return getActivityIndex(date, playtimeMsThreshold);
|
||||
}
|
||||
|
||||
public double getActivityIndex(long date, long playtimeMsThreshold) {
|
||||
return container.getActivityIndex(date, playtimeMsThreshold).getValue();
|
||||
}
|
||||
|
||||
public boolean playedBetween(long after, long before) {
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
package com.djrapitops.plan.api.data;
|
||||
|
||||
import com.djrapitops.plan.data.store.Key;
|
||||
import com.djrapitops.plan.delivery.domain.keys.Key;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@ -24,17 +24,19 @@ import java.util.Optional;
|
||||
* Wrapper for a ServerContainer.
|
||||
* <p>
|
||||
* The actual object is wrapped to avoid exposing too much API that might change.
|
||||
* See {@link com.djrapitops.plan.data.store.keys.ServerKeys} for Key objects.
|
||||
* See {@link com.djrapitops.plan.delivery.domain.keys.ServerKeys} for Key objects.
|
||||
* <p>
|
||||
* The Keys might change in the future, but the Optional API should help dealing with those cases.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @deprecated Plan API v4 has been deprecated, use the APIv5 instead (https://github.com/plan-player-analytics/Plan/wiki/APIv5).
|
||||
*/
|
||||
@Deprecated
|
||||
public class ServerContainer {
|
||||
|
||||
private final com.djrapitops.plan.data.store.containers.ServerContainer container;
|
||||
private final com.djrapitops.plan.delivery.domain.container.ServerContainer container;
|
||||
|
||||
public ServerContainer(com.djrapitops.plan.data.store.containers.ServerContainer container) {
|
||||
public ServerContainer(com.djrapitops.plan.delivery.domain.container.ServerContainer container) {
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
|
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* 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.api.exceptions.connection;
|
||||
|
||||
import com.djrapitops.plan.system.webserver.response.ResponseCode;
|
||||
|
||||
/**
|
||||
* Thrown when Connection fails to connect to an address.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class ConnectionFailException extends WebException {
|
||||
|
||||
public ConnectionFailException(String message, Throwable cause) {
|
||||
super(message, cause, ResponseCode.CONNECTION_REFUSED);
|
||||
}
|
||||
|
||||
public ConnectionFailException(Throwable cause) {
|
||||
super(cause, ResponseCode.CONNECTION_REFUSED);
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* 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.api.exceptions.connection;
|
||||
|
||||
import com.djrapitops.plan.system.webserver.response.ResponseCode;
|
||||
|
||||
/**
|
||||
* Thrown when Connection gets a 412 response due to ServerUUID not being in the database.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class UnauthorizedServerException extends WebFailException {
|
||||
|
||||
public UnauthorizedServerException(String message) {
|
||||
super(message, ResponseCode.PRECONDITION_FAILED);
|
||||
}
|
||||
|
||||
public UnauthorizedServerException(String message, Throwable cause) {
|
||||
super(message, cause, ResponseCode.PRECONDITION_FAILED);
|
||||
}
|
||||
|
||||
public UnauthorizedServerException(Throwable cause) {
|
||||
super(cause, ResponseCode.PRECONDITION_FAILED);
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* 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.api.exceptions.connection;
|
||||
|
||||
import com.djrapitops.plan.system.webserver.response.ResponseCode;
|
||||
|
||||
/**
|
||||
* Group of WebExceptions that can be considered a failed connection state on some occasions.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class WebFailException extends WebException {
|
||||
|
||||
public WebFailException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public WebFailException(String message, ResponseCode responseCode) {
|
||||
super(message, responseCode);
|
||||
}
|
||||
|
||||
public WebFailException(String message, Throwable cause, ResponseCode responseCode) {
|
||||
super(message, cause, responseCode);
|
||||
}
|
||||
|
||||
public WebFailException(Throwable cause, ResponseCode responseCode) {
|
||||
super(cause, responseCode);
|
||||
}
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
/*
|
||||
* 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.command.commands;
|
||||
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Command for Toggling whether or not BungeeCord accepts set up requests.
|
||||
* <p>
|
||||
* This was added as a security measure against unwanted MySQL snooping.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class BungeeSetupToggleCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
|
||||
@Inject
|
||||
public BungeeSetupToggleCommand(Locale locale, ConnectionSystem connectionSystem) {
|
||||
super("setup", Permissions.MANAGE.getPermission(), CommandType.ALL);
|
||||
|
||||
this.locale = locale;
|
||||
this.connectionSystem = connectionSystem;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.SETUP));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.SETUP));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(Sender sender, String s, String[] strings) {
|
||||
if (connectionSystem.isSetupAllowed()) {
|
||||
connectionSystem.setSetupAllowed(false);
|
||||
} else {
|
||||
connectionSystem.setSetupAllowed(true);
|
||||
}
|
||||
|
||||
String msg = locale.getString(connectionSystem.isSetupAllowed() ? CommandLang.SETUP_ALLOWED : CommandLang.SETUP_FORBIDDEN);
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
}
|
@ -1,161 +0,0 @@
|
||||
/*
|
||||
* 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.command.commands.manage;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.connection.*;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.access.queries.objects.ServerQueries;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.info.request.InfoRequestFactory;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.ManageLang;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* This manage SubCommand is used to request settings from Bungee so that connection can be established.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Singleton
|
||||
public class ManageConDebugCommand extends CommandNode {
|
||||
|
||||
private final ColorScheme colorScheme;
|
||||
private final Locale locale;
|
||||
private final Processing processing;
|
||||
private final ServerInfo serverInfo;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
private final InfoRequestFactory infoRequestFactory;
|
||||
private final WebServer webServer;
|
||||
private final DBSystem dbSystem;
|
||||
|
||||
@Inject
|
||||
public ManageConDebugCommand(
|
||||
ColorScheme colorScheme,
|
||||
Locale locale,
|
||||
Processing processing,
|
||||
ServerInfo serverInfo,
|
||||
ConnectionSystem connectionSystem,
|
||||
InfoRequestFactory infoRequestFactory,
|
||||
WebServer webServer,
|
||||
DBSystem dbSystem
|
||||
) {
|
||||
super("con", Permissions.MANAGE.getPermission(), CommandType.ALL);
|
||||
|
||||
this.colorScheme = colorScheme;
|
||||
this.locale = locale;
|
||||
this.processing = processing;
|
||||
this.serverInfo = serverInfo;
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.infoRequestFactory = infoRequestFactory;
|
||||
this.webServer = webServer;
|
||||
this.dbSystem = dbSystem;
|
||||
|
||||
boolean isProxy = serverInfo.getServer() != null && serverInfo.getServer().isProxy();
|
||||
setShortHelp(locale.getString(isProxy ? CmdHelpLang.CON : CmdHelpLang.MANAGE_CON));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.MANAGE_CON));
|
||||
}
|
||||
|
||||
private void testServer(Sender sender, Server server, Locale locale) {
|
||||
String address = server.getWebAddress().toLowerCase();
|
||||
boolean usingHttps = address.startsWith("https");
|
||||
boolean local = address.contains("localhost")
|
||||
|| address.startsWith("https://:") // IP empty = Localhost
|
||||
|| address.startsWith("http://:") // IP empty = Localhost
|
||||
|| address.contains("127.0.0.1");
|
||||
|
||||
try {
|
||||
connectionSystem.sendInfoRequest(infoRequestFactory.checkConnectionRequest(address), server);
|
||||
sender.sendMessage(getMsgFor(address, usingHttps, local, true, true));
|
||||
} catch (UnauthorizedServerException e) {
|
||||
sender.sendMessage(getMsgFor(address, usingHttps, local, true, false));
|
||||
sender.sendMessage(locale.getString(ManageLang.CON_UNAUTHORIZED));
|
||||
} catch (ConnectionFailException e) {
|
||||
sender.sendMessage(getMsgFor(address, usingHttps, local, false, false));
|
||||
sender.sendMessage(locale.getString(ManageLang.CON_GENERIC_FAIL) + e.getCause().getClass().getSimpleName() + " " + e.getCause().getMessage());
|
||||
if (!local) {
|
||||
sender.sendMessage(locale.getString(ManageLang.CON_EXTERNAL_URL));
|
||||
}
|
||||
} catch (GatewayException e) {
|
||||
sender.sendMessage(getMsgFor(address, usingHttps, local, true, false));
|
||||
} catch (NotFoundException e) {
|
||||
sender.sendMessage(getMsgFor(address, usingHttps, local, false, false));
|
||||
sender.sendMessage(locale.getString(ManageLang.CON_OLD_VERSION));
|
||||
} catch (WebException e) {
|
||||
sender.sendMessage(getMsgFor(address, usingHttps, local, false, false));
|
||||
sender.sendMessage(locale.getString(ManageLang.CON_EXCEPTION, e.getClass().getSimpleName()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
if (!webServer.isEnabled()) {
|
||||
sender.sendMessage(locale.getString(CommandLang.CONNECT_WEBSERVER_NOT_ENABLED));
|
||||
return;
|
||||
}
|
||||
|
||||
Database.State dbState = dbSystem.getDatabase().getState();
|
||||
if (dbState != Database.State.OPEN) {
|
||||
sender.sendMessage(locale.getString(CommandLang.FAIL_DATABASE_NOT_OPEN, dbState.name()));
|
||||
return;
|
||||
}
|
||||
|
||||
processing.submitNonCritical(() -> testServers(sender));
|
||||
}
|
||||
|
||||
private void testServers(Sender sender) {
|
||||
Map<UUID, Server> servers = dbSystem.getDatabase().query(ServerQueries.fetchPlanServerInformation());
|
||||
|
||||
if (servers.isEmpty()) {
|
||||
sender.sendMessage(locale.getString(ManageLang.CON_NO_SERVERS));
|
||||
}
|
||||
|
||||
UUID thisServer = serverInfo.getServerUUID();
|
||||
for (Server server : servers.values()) {
|
||||
if (thisServer.equals(server.getUuid())) {
|
||||
continue;
|
||||
}
|
||||
testServer(sender, server, locale);
|
||||
}
|
||||
}
|
||||
|
||||
private String getMsgFor(String address, boolean usingHttps, boolean local, boolean successTo, boolean successFrom) {
|
||||
String tCol = colorScheme.getTertiaryColor();
|
||||
String sCol = colorScheme.getSecondaryColor();
|
||||
return tCol + address + sCol + ": "
|
||||
+ (usingHttps ? "HTTPS" : "HTTP") + " : "
|
||||
+ (local ? "Local" : "External") + " : "
|
||||
+ "To:" + (successTo ? "§aOK" : "§cFail") + sCol + " : "
|
||||
+ "From:" + (successFrom ? "§aOK" : "§cFail");
|
||||
}
|
||||
}
|
@ -1,157 +0,0 @@
|
||||
/*
|
||||
* 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.command.commands.manage;
|
||||
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.access.queries.objects.UserIdentifierQueries;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.export.HtmlExport;
|
||||
import com.djrapitops.plan.system.export.JSONExport;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.ManageLang;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.ExportSettings;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* This manage SubCommand is used to import data from 3rd party plugins.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Singleton
|
||||
public class ManageExportCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final ColorScheme colorScheme;
|
||||
private final PlanConfig config;
|
||||
private final DBSystem dbSystem;
|
||||
private final ServerInfo serverInfo;
|
||||
private final HtmlExport htmlExport;
|
||||
private final JSONExport jsonExport;
|
||||
private final Processing processing;
|
||||
|
||||
@Inject
|
||||
public ManageExportCommand(
|
||||
Locale locale,
|
||||
ColorScheme colorScheme,
|
||||
PlanConfig config,
|
||||
DBSystem dbSystem,
|
||||
ServerInfo serverInfo,
|
||||
Processing processing,
|
||||
HtmlExport htmlExport,
|
||||
JSONExport jsonExport
|
||||
) {
|
||||
super("export", Permissions.MANAGE.getPermission(), CommandType.CONSOLE);
|
||||
|
||||
this.locale = locale;
|
||||
this.colorScheme = colorScheme;
|
||||
this.config = config;
|
||||
this.dbSystem = dbSystem;
|
||||
this.serverInfo = serverInfo;
|
||||
this.htmlExport = htmlExport;
|
||||
this.jsonExport = jsonExport;
|
||||
this.processing = processing;
|
||||
|
||||
setArguments("<export_kind>/list");
|
||||
setShortHelp(locale.getString(CmdHelpLang.MANAGE_EXPORT));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.MANAGE_EXPORT));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
Verify.isTrue(args.length >= 1,
|
||||
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ARGS, "1+", Arrays.toString(this.getArguments()))));
|
||||
|
||||
String exportArg = args[0];
|
||||
|
||||
if ("list".equals(exportArg)) {
|
||||
sender.sendMessage("> " + colorScheme.getMainColor() + "players, server_json");
|
||||
return;
|
||||
}
|
||||
|
||||
Database.State dbState = dbSystem.getDatabase().getState();
|
||||
if (dbState != Database.State.OPEN) {
|
||||
sender.sendMessage(locale.getString(CommandLang.FAIL_DATABASE_NOT_OPEN, dbState.name()));
|
||||
return;
|
||||
}
|
||||
|
||||
getExportFunction(exportArg).accept(sender);
|
||||
}
|
||||
|
||||
private Consumer<Sender> getExportFunction(String exportArg) {
|
||||
switch (exportArg) {
|
||||
case "players":
|
||||
return this::exportPlayers;
|
||||
case "server_json":
|
||||
return this::exportServerJSON;
|
||||
default:
|
||||
return sender -> sender.sendMessage(locale.getString(ManageLang.FAIL_EXPORTER_NOT_FOUND, exportArg));
|
||||
}
|
||||
}
|
||||
|
||||
private void exportServerJSON(Sender sender) {
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
|
||||
processing.submitNonCritical(() -> {
|
||||
jsonExport.exportServerJSON(serverInfo.getServerUUID());
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
|
||||
});
|
||||
}
|
||||
|
||||
private void exportPlayers(Sender sender) {
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
|
||||
if (config.get(ExportSettings.PLAYERS_PAGE)) {
|
||||
processing.submitNonCritical(htmlExport::exportPlayersPage);
|
||||
}
|
||||
Boolean exportPlayerJSON = config.get(ExportSettings.PLAYER_JSON);
|
||||
Boolean exportPlayerHTML = config.get(ExportSettings.PLAYER_PAGES);
|
||||
processing.submitNonCritical(() -> {
|
||||
Map<UUID, String> players = dbSystem.getDatabase().query(UserIdentifierQueries.fetchAllPlayerNames());
|
||||
int size = players.size();
|
||||
int i = 1;
|
||||
for (Map.Entry<UUID, String> entry : players.entrySet()) {
|
||||
if (exportPlayerJSON) {
|
||||
jsonExport.exportPlayerJSON(entry.getKey());
|
||||
}
|
||||
if (exportPlayerHTML) {
|
||||
htmlExport.exportPlayerPage(entry.getKey(), entry.getValue());
|
||||
}
|
||||
i++;
|
||||
if (i % 1000 == 0) {
|
||||
sender.sendMessage(i + " / " + size + " processed..");
|
||||
}
|
||||
}
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
|
||||
});
|
||||
}
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
/*
|
||||
* 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.command.commands.manage;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.connection.*;
|
||||
import com.djrapitops.plan.system.info.InfoSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.PluginSettings;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* This manage SubCommand is used to request settings from Bungee so that connection can be established.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Singleton
|
||||
public class ManageSetupCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final PlanConfig config;
|
||||
private final Processing processing;
|
||||
private final InfoSystem infoSystem;
|
||||
private final WebServer webServer;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
public ManageSetupCommand(
|
||||
Locale locale,
|
||||
PlanConfig config,
|
||||
Processing processing,
|
||||
InfoSystem infoSystem,
|
||||
WebServer webServer,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super("setup", Permissions.MANAGE.getPermission(), CommandType.PLAYER_OR_ARGS);
|
||||
|
||||
this.locale = locale;
|
||||
this.config = config;
|
||||
this.processing = processing;
|
||||
this.infoSystem = infoSystem;
|
||||
this.webServer = webServer;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setArguments("<BungeeAddress>");
|
||||
setShortHelp(locale.getString(CmdHelpLang.MANAGE_SETUP));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.MANAGE_SETUP));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
Verify.isTrue(args.length >= 1,
|
||||
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
|
||||
|
||||
if (!webServer.isEnabled()) {
|
||||
sender.sendMessage(locale.getString(CommandLang.CONNECT_WEBSERVER_NOT_ENABLED));
|
||||
return;
|
||||
}
|
||||
String address = args[0].toLowerCase();
|
||||
if (!address.startsWith("http") || address.endsWith("://")) {
|
||||
sender.sendMessage(locale.getString(CommandLang.CONNECT_URL_MISTAKE));
|
||||
return;
|
||||
}
|
||||
if (address.endsWith("/")) {
|
||||
address = address.substring(0, address.length() - 1);
|
||||
}
|
||||
|
||||
requestSetup(sender, address);
|
||||
}
|
||||
|
||||
private void requestSetup(Sender sender, String address) {
|
||||
processing.submitNonCritical(() -> {
|
||||
try {
|
||||
config.set(PluginSettings.BUNGEE_COPY_CONFIG, true);
|
||||
|
||||
infoSystem.requestSetUp(address);
|
||||
|
||||
sender.sendMessage(locale.getString(CommandLang.CONNECT_SUCCESS));
|
||||
} catch (ForbiddenException e) {
|
||||
sender.sendMessage(locale.getString(CommandLang.CONNECT_FORBIDDEN));
|
||||
} catch (BadRequestException e) {
|
||||
sender.sendMessage(locale.getString(CommandLang.CONNECT_BAD_REQUEST));
|
||||
} catch (UnauthorizedServerException e) {
|
||||
sender.sendMessage(locale.getString(CommandLang.CONNECT_UNAUTHORIZED));
|
||||
} catch (ConnectionFailException e) {
|
||||
sender.sendMessage(locale.getString(CommandLang.CONNECT_FAIL, e.getMessage()));
|
||||
} catch (InternalErrorException e) {
|
||||
sender.sendMessage(locale.getString(CommandLang.CONNECT_INTERNAL_ERROR, e.getMessage()));
|
||||
} catch (GatewayException e) {
|
||||
sender.sendMessage(locale.getString(CommandLang.CONNECT_GATEWAY));
|
||||
} catch (WebException e) {
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
sender.sendMessage(locale.getString(CommandLang.CONNECT_FAIL, e.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -14,14 +14,14 @@
|
||||
* 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.command;
|
||||
package com.djrapitops.plan.commands;
|
||||
|
||||
import com.djrapitops.plan.command.commands.*;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.PluginSettings;
|
||||
import com.djrapitops.plan.commands.subcommands.*;
|
||||
import com.djrapitops.plan.settings.Permissions;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.PluginSettings;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
@ -14,15 +14,14 @@
|
||||
* 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.command;
|
||||
package com.djrapitops.plan.commands;
|
||||
|
||||
import com.djrapitops.plan.command.commands.*;
|
||||
import com.djrapitops.plan.command.commands.manage.ManageConDebugCommand;
|
||||
import com.djrapitops.plan.command.commands.manage.ManageRawDataCommand;
|
||||
import com.djrapitops.plan.command.commands.manage.ManageUninstalledCommand;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.commands.subcommands.*;
|
||||
import com.djrapitops.plan.commands.subcommands.manage.ManageRawDataCommand;
|
||||
import com.djrapitops.plan.commands.subcommands.manage.ManageUninstalledCommand;
|
||||
import com.djrapitops.plan.settings.Permissions;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
@ -48,9 +47,7 @@ public class PlanProxyCommand extends TreeCmdNode {
|
||||
private final ListPlayersCommand listPlayersCommand;
|
||||
private final RegisterCommand registerCommand;
|
||||
private final Lazy<WebUserCommand> webUserCommand;
|
||||
private final ManageConDebugCommand conDebugCommand;
|
||||
private final ManageRawDataCommand rawDataCommand;
|
||||
private final BungeeSetupToggleCommand setupToggleCommand;
|
||||
private final ReloadCommand reloadCommand;
|
||||
private final DisableCommand disableCommand;
|
||||
private final ManageUninstalledCommand uninstalledCommand;
|
||||
@ -70,9 +67,7 @@ public class PlanProxyCommand extends TreeCmdNode {
|
||||
RegisterCommand registerCommand,
|
||||
Lazy<WebUserCommand> webUserCommand,
|
||||
// Group 3
|
||||
ManageConDebugCommand conDebugCommand,
|
||||
ManageRawDataCommand rawDataCommand,
|
||||
BungeeSetupToggleCommand setupToggleCommand,
|
||||
ManageUninstalledCommand uninstalledCommand,
|
||||
ReloadCommand reloadCommand,
|
||||
DisableCommand disableCommand
|
||||
@ -87,9 +82,7 @@ public class PlanProxyCommand extends TreeCmdNode {
|
||||
this.listPlayersCommand = listPlayersCommand;
|
||||
this.registerCommand = registerCommand;
|
||||
this.webUserCommand = webUserCommand;
|
||||
this.conDebugCommand = conDebugCommand;
|
||||
this.rawDataCommand = rawDataCommand;
|
||||
this.setupToggleCommand = setupToggleCommand;
|
||||
this.reloadCommand = reloadCommand;
|
||||
this.disableCommand = disableCommand;
|
||||
|
||||
@ -113,9 +106,7 @@ public class PlanProxyCommand extends TreeCmdNode {
|
||||
webUserCommand.get()
|
||||
};
|
||||
CommandNode[] manageGroup = {
|
||||
conDebugCommand,
|
||||
rawDataCommand,
|
||||
setupToggleCommand,
|
||||
uninstalledCommand,
|
||||
reloadCommand,
|
||||
disableCommand
|
@ -14,26 +14,26 @@
|
||||
* 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.command.commands;
|
||||
package com.djrapitops.plan.commands.subcommands;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.access.queries.objects.ServerQueries;
|
||||
import com.djrapitops.plan.db.access.queries.objects.WebUserQueries;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.InfoSystem;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.ManageLang;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
import com.djrapitops.plan.PlanSystem;
|
||||
import com.djrapitops.plan.delivery.export.Exporter;
|
||||
import com.djrapitops.plan.delivery.rendering.html.Html;
|
||||
import com.djrapitops.plan.delivery.webserver.WebServer;
|
||||
import com.djrapitops.plan.exceptions.ExportException;
|
||||
import com.djrapitops.plan.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.identification.Server;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.processing.Processing;
|
||||
import com.djrapitops.plan.settings.Permissions;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.settings.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.settings.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.ServerQueries;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.WebUserQueries;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.CommandUtils;
|
||||
@ -44,7 +44,6 @@ import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* This SubCommand is used to run the analysis and access the /server link.
|
||||
@ -56,18 +55,17 @@ public class AnalyzeCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final Processing processing;
|
||||
private final InfoSystem infoSystem;
|
||||
private final Exporter exporter;
|
||||
private final ServerInfo serverInfo;
|
||||
private final WebServer webServer;
|
||||
private final DBSystem dbSystem;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
public AnalyzeCommand(
|
||||
Locale locale,
|
||||
Processing processing,
|
||||
InfoSystem infoSystem,
|
||||
Exporter exporter,
|
||||
ServerInfo serverInfo,
|
||||
WebServer webServer,
|
||||
DBSystem dbSystem,
|
||||
@ -77,8 +75,7 @@ public class AnalyzeCommand extends CommandNode {
|
||||
|
||||
this.locale = locale;
|
||||
this.processing = processing;
|
||||
this.infoSystem = infoSystem;
|
||||
connectionSystem = infoSystem.getConnectionSystem();
|
||||
this.exporter = exporter;
|
||||
this.serverInfo = serverInfo;
|
||||
this.webServer = webServer;
|
||||
this.dbSystem = dbSystem;
|
||||
@ -91,23 +88,20 @@ public class AnalyzeCommand extends CommandNode {
|
||||
|
||||
@Override
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
Database.State dbState = dbSystem.getDatabase().getState();
|
||||
Database database = dbSystem.getDatabase();
|
||||
Database.State dbState = database.getState();
|
||||
if (dbState != Database.State.OPEN) {
|
||||
sender.sendMessage(locale.getString(CommandLang.FAIL_DATABASE_NOT_OPEN, dbState.name()));
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
|
||||
|
||||
processing.submitNonCritical(() -> {
|
||||
try {
|
||||
Server server = getServer(args).orElseGet(serverInfo::getServer);
|
||||
UUID serverUUID = server.getUuid();
|
||||
|
||||
infoSystem.generateAnalysisPage(serverUUID);
|
||||
Server server = getServer(args);
|
||||
sendWebUserNotificationIfNecessary(sender);
|
||||
exporter.exportServerPage(server);
|
||||
sendLink(server, sender);
|
||||
} catch (DBOpException | WebException e) {
|
||||
} catch (DBOpException | ExportException e) {
|
||||
sender.sendMessage("§cError occurred: " + e.toString());
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
}
|
||||
@ -115,8 +109,9 @@ public class AnalyzeCommand extends CommandNode {
|
||||
}
|
||||
|
||||
private void sendLink(Server server, Sender sender) {
|
||||
String target = "/server/" + server.getName();
|
||||
String url = connectionSystem.getMainAddress() + target;
|
||||
String target = "/server/" + Html.encodeToURL(server.getName());
|
||||
String address = PlanSystem.getMainAddress(webServer, dbSystem);
|
||||
String url = address + target;
|
||||
String linkPrefix = locale.getString(CommandLang.LINK_PREFIX);
|
||||
sender.sendMessage(locale.getString(CommandLang.HEADER_ANALYSIS));
|
||||
// Link
|
||||
@ -138,22 +133,24 @@ public class AnalyzeCommand extends CommandNode {
|
||||
}
|
||||
}
|
||||
|
||||
private Optional<Server> getServer(String[] args) {
|
||||
if (args.length >= 1 && connectionSystem.isServerAvailable()) {
|
||||
String serverIdentifier = getGivenIdentifier(args);
|
||||
return dbSystem.getDatabase().query(ServerQueries.fetchServerMatchingIdentifier(serverIdentifier))
|
||||
.filter(server -> !server.isProxy());
|
||||
}
|
||||
return Optional.empty();
|
||||
private Server getServer(String[] args) {
|
||||
return getGivenIdentifier(args)
|
||||
.flatMap(serverIdentifier -> dbSystem.getDatabase()
|
||||
.query(ServerQueries.fetchServerMatchingIdentifier(serverIdentifier))
|
||||
).filter(server -> !server.isProxy())
|
||||
.orElseGet(serverInfo::getServer);
|
||||
}
|
||||
|
||||
private String getGivenIdentifier(String[] args) {
|
||||
private Optional<String> getGivenIdentifier(String[] args) {
|
||||
if (args.length < 1) {
|
||||
return Optional.empty();
|
||||
}
|
||||
StringBuilder idBuilder = new StringBuilder(args[0]);
|
||||
if (args.length > 1) {
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
idBuilder.append(" ").append(args[i]);
|
||||
}
|
||||
}
|
||||
return idBuilder.toString();
|
||||
return Optional.of(idBuilder.toString());
|
||||
}
|
||||
}
|
@ -14,11 +14,11 @@
|
||||
* 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.command.commands;
|
||||
package com.djrapitops.plan.commands.subcommands;
|
||||
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.settings.locale.lang.CommandLang;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.Sender;
|
@ -14,13 +14,13 @@
|
||||
* 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.command.commands;
|
||||
package com.djrapitops.plan.commands.subcommands;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.settings.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.settings.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.Sender;
|
@ -14,18 +14,18 @@
|
||||
* 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.command.commands;
|
||||
package com.djrapitops.plan.commands.subcommands;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.GenericLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.update.VersionCheckSystem;
|
||||
import com.djrapitops.plan.settings.Permissions;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.settings.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.settings.locale.lang.GenericLang;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.ServerQueries;
|
||||
import com.djrapitops.plan.version.VersionCheckSystem;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
@ -42,7 +42,6 @@ public class InfoCommand extends CommandNode {
|
||||
private final PlanPlugin plugin;
|
||||
private final Locale locale;
|
||||
private final DBSystem dbSystem;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
private final VersionCheckSystem versionCheckSystem;
|
||||
|
||||
@Inject
|
||||
@ -50,7 +49,6 @@ public class InfoCommand extends CommandNode {
|
||||
PlanPlugin plugin,
|
||||
Locale locale,
|
||||
DBSystem dbSystem,
|
||||
ConnectionSystem connectionSystem,
|
||||
VersionCheckSystem versionCheckSystem
|
||||
) {
|
||||
super("info", Permissions.INFO.getPermission(), CommandType.CONSOLE);
|
||||
@ -58,7 +56,6 @@ public class InfoCommand extends CommandNode {
|
||||
this.plugin = plugin;
|
||||
this.locale = locale;
|
||||
this.dbSystem = dbSystem;
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.versionCheckSystem = versionCheckSystem;
|
||||
|
||||
setShortHelp(locale.get(CmdHelpLang.INFO).toString());
|
||||
@ -69,18 +66,19 @@ public class InfoCommand extends CommandNode {
|
||||
String yes = locale.getString(GenericLang.YES);
|
||||
String no = locale.getString(GenericLang.NO);
|
||||
|
||||
String updateAvailable = versionCheckSystem.isNewVersionAvailable() ? yes : no;
|
||||
String connectedToBungee = connectionSystem.isServerAvailable() ? yes : no;
|
||||
|
||||
Database database = dbSystem.getDatabase();
|
||||
|
||||
String updateAvailable = versionCheckSystem.isNewVersionAvailable() ? yes : no;
|
||||
String proxyAvailable = database.query(ServerQueries.fetchProxyServerInformation()).isPresent() ? yes : no;
|
||||
|
||||
|
||||
String[] messages = {
|
||||
locale.getString(CommandLang.HEADER_INFO),
|
||||
"",
|
||||
locale.getString(CommandLang.INFO_VERSION, plugin.getVersion()),
|
||||
locale.getString(CommandLang.INFO_UPDATE, updateAvailable),
|
||||
locale.getString(CommandLang.INFO_DATABASE, database.getType().getName() + " (" + database.getState().name() + ")"),
|
||||
locale.getString(CommandLang.INFO_PROXY_CONNECTION, connectedToBungee),
|
||||
locale.getString(CommandLang.INFO_PROXY_CONNECTION, proxyAvailable),
|
||||
"",
|
||||
">"
|
||||
};
|
@ -14,24 +14,24 @@
|
||||
* 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.command.commands;
|
||||
package com.djrapitops.plan.commands.subcommands;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.access.queries.PlayerFetchQueries;
|
||||
import com.djrapitops.plan.db.access.queries.objects.WebUserQueries;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.processing.processors.info.InfoProcessors;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
import com.djrapitops.plan.PlanSystem;
|
||||
import com.djrapitops.plan.delivery.rendering.html.Html;
|
||||
import com.djrapitops.plan.delivery.webserver.WebServer;
|
||||
import com.djrapitops.plan.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.identification.UUIDUtility;
|
||||
import com.djrapitops.plan.processing.Processing;
|
||||
import com.djrapitops.plan.settings.Permissions;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.settings.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.settings.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.queries.PlayerFetchQueries;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.WebUserQueries;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.CommandUtils;
|
||||
@ -52,27 +52,21 @@ public class InspectCommand extends CommandNode {
|
||||
private final Locale locale;
|
||||
private final DBSystem dbSystem;
|
||||
private final WebServer webServer;
|
||||
private final InfoProcessors processorFactory;
|
||||
private final Processing processing;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
private final UUIDUtility uuidUtility;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
public InspectCommand(
|
||||
Locale locale,
|
||||
InfoProcessors processorFactory,
|
||||
Processing processing,
|
||||
DBSystem dbSystem,
|
||||
WebServer webServer,
|
||||
ConnectionSystem connectionSystem,
|
||||
UUIDUtility uuidUtility,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super("inspect", Permissions.INSPECT.getPermission(), CommandType.PLAYER_OR_ARGS);
|
||||
this.processorFactory = processorFactory;
|
||||
this.processing = processing;
|
||||
this.connectionSystem = connectionSystem;
|
||||
setArguments("<player>");
|
||||
|
||||
this.locale = locale;
|
||||
@ -117,7 +111,7 @@ public class InspectCommand extends CommandNode {
|
||||
}
|
||||
|
||||
checkWebUserAndNotify(sender);
|
||||
processing.submit(processorFactory.inspectCacheRequestProcessor(playerUUID, sender, playerName, this::sendInspectMsg));
|
||||
this.sendInspectMsg(sender, playerName);
|
||||
} catch (DBOpException e) {
|
||||
sender.sendMessage("§eDatabase exception occurred: " + e.getMessage());
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
@ -138,7 +132,8 @@ public class InspectCommand extends CommandNode {
|
||||
private void sendInspectMsg(Sender sender, String playerName) {
|
||||
sender.sendMessage(locale.getString(CommandLang.HEADER_INSPECT, playerName));
|
||||
|
||||
String url = connectionSystem.getMainAddress() + "/player/" + playerName;
|
||||
String address = PlanSystem.getMainAddress(webServer, dbSystem);
|
||||
String url = address + "/player/" + Html.encodeToURL(playerName);
|
||||
String linkPrefix = locale.getString(CommandLang.LINK_PREFIX);
|
||||
|
||||
boolean console = !CommandUtils.isPlayer(sender);
|
@ -14,14 +14,16 @@
|
||||
* 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.command.commands;
|
||||
package com.djrapitops.plan.commands.subcommands;
|
||||
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.PlanSystem;
|
||||
import com.djrapitops.plan.delivery.webserver.WebServer;
|
||||
import com.djrapitops.plan.settings.Permissions;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.settings.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.settings.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.CommandUtils;
|
||||
@ -37,14 +39,20 @@ import javax.inject.Inject;
|
||||
public class ListPlayersCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
private final DBSystem dbSystem;
|
||||
private final WebServer webServer;
|
||||
|
||||
@Inject
|
||||
public ListPlayersCommand(Locale locale, ConnectionSystem connectionSystem) {
|
||||
public ListPlayersCommand(
|
||||
Locale locale,
|
||||
DBSystem dbSystem,
|
||||
WebServer webServer
|
||||
) {
|
||||
super("players|pl|playerlist|list", Permissions.INSPECT_OTHER.getPermission(), CommandType.CONSOLE);
|
||||
|
||||
this.locale = locale;
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.dbSystem = dbSystem;
|
||||
this.webServer = webServer;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.PLAYERS));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.PLAYERS));
|
||||
@ -59,7 +67,8 @@ public class ListPlayersCommand extends CommandNode {
|
||||
sender.sendMessage(locale.getString(CommandLang.HEADER_PLAYERS));
|
||||
|
||||
// Link
|
||||
String url = connectionSystem.getMainAddress() + "/players/";
|
||||
String address = PlanSystem.getMainAddress(webServer, dbSystem);
|
||||
String url = address + "/players/";
|
||||
String linkPrefix = locale.getString(CommandLang.LINK_PREFIX);
|
||||
boolean console = !CommandUtils.isPlayer(sender);
|
||||
if (console) {
|
@ -14,19 +14,19 @@
|
||||
* 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.command.commands;
|
||||
package com.djrapitops.plan.commands.subcommands;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.access.queries.objects.ServerQueries;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatter;
|
||||
import com.djrapitops.plan.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.identification.Server;
|
||||
import com.djrapitops.plan.settings.Permissions;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.settings.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.settings.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.ServerQueries;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
@ -14,13 +14,13 @@
|
||||
* 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.command.commands;
|
||||
package com.djrapitops.plan.commands.subcommands;
|
||||
|
||||
import com.djrapitops.plan.command.commands.manage.*;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.commands.subcommands.manage.*;
|
||||
import com.djrapitops.plan.settings.Permissions;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.settings.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
@ -48,8 +48,6 @@ public class ManageCommand extends TreeCmdNode {
|
||||
ManageHotSwapCommand hotSwapCommand,
|
||||
ManageClearCommand clearCommand,
|
||||
// Group 2
|
||||
ManageSetupCommand setupCommand,
|
||||
ManageConDebugCommand conDebugCommand,
|
||||
ManageImportCommand importCommand,
|
||||
ManageExportCommand exportCommand,
|
||||
ManageDisableCommand disableCommand,
|
||||
@ -70,8 +68,6 @@ public class ManageCommand extends TreeCmdNode {
|
||||
clearCommand,
|
||||
};
|
||||
CommandNode[] pluginGroup = {
|
||||
setupCommand,
|
||||
conDebugCommand,
|
||||
importCommand,
|
||||
exportCommand,
|
||||
disableCommand,
|
@ -14,14 +14,16 @@
|
||||
* 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.command.commands;
|
||||
package com.djrapitops.plan.commands.subcommands;
|
||||
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.PlanSystem;
|
||||
import com.djrapitops.plan.delivery.webserver.WebServer;
|
||||
import com.djrapitops.plan.settings.Permissions;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.settings.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.settings.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.CommandUtils;
|
||||
@ -37,14 +39,20 @@ import javax.inject.Inject;
|
||||
public class NetworkCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
private final DBSystem dbSystem;
|
||||
private final WebServer webServer;
|
||||
|
||||
@Inject
|
||||
public NetworkCommand(Locale locale, ConnectionSystem connectionSystem) {
|
||||
public NetworkCommand(
|
||||
Locale locale,
|
||||
DBSystem dbSystem,
|
||||
WebServer webServer
|
||||
) {
|
||||
super("network|n|netw", Permissions.ANALYZE.getPermission(), CommandType.CONSOLE);
|
||||
|
||||
this.locale = locale;
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.dbSystem = dbSystem;
|
||||
this.webServer = webServer;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.NETWORK));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.NETWORK));
|
||||
@ -59,7 +67,8 @@ public class NetworkCommand extends CommandNode {
|
||||
sender.sendMessage(locale.getString(CommandLang.HEADER_NETWORK));
|
||||
|
||||
// Link
|
||||
String url = connectionSystem.getMainAddress() + "/network/";
|
||||
String address = PlanSystem.getMainAddress(webServer, dbSystem);
|
||||
String url = address + "/network/";
|
||||
String linkPrefix = locale.getString(CommandLang.LINK_PREFIX);
|
||||
boolean console = !CommandUtils.isPlayer(sender);
|
||||
if (console) {
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user