mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-24 17:11:43 +01:00
Implemented velocity RedisBungee support
Added ProxioDev fork of RedisBungee as dependency to Velocity Affects issues: - Close #2620
This commit is contained in:
parent
0a14d17d7a
commit
011ce7751d
@ -79,6 +79,7 @@ subprojects {
|
||||
bungeeVersion = "1.16-R0.4"
|
||||
velocityVersion = "3.0.0-SNAPSHOT"
|
||||
redisBungeeVersion = "0.3.8-SNAPSHOT"
|
||||
redisBungeeProxioDevVersion = "0.7.3"
|
||||
|
||||
commonsTextVersion = "1.9"
|
||||
commonsCompressVersion = "1.21"
|
||||
@ -112,9 +113,10 @@ subprojects {
|
||||
maven { url = "https://papermc.io/repo/repository/maven-public/" } // Paper
|
||||
maven { url = "https://repo.spongepowered.org/repository/maven-public/" } // Sponge
|
||||
maven { url = "https://oss.sonatype.org/content/repositories/snapshots" } // BungeeCord
|
||||
maven { url = "https://repo.md-5.net/content/repositories/snapshots/" } // RedisBungee
|
||||
maven { url = "https://repo.velocitypowered.com/snapshots/" } // Velocity
|
||||
maven { url = "https://repo.playeranalytics.net/releases" } // Plan
|
||||
maven { url = "https://repo.md-5.net/content/repositories/snapshots/" } // RedisBungee
|
||||
maven { url = "https://jitpack.io" } // RedisBungee fork
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -16,8 +16,10 @@ dependencies {
|
||||
|
||||
compileOnly "com.velocitypowered:velocity-api:$velocityVersion"
|
||||
annotationProcessor "com.velocitypowered:velocity-api:$velocityVersion"
|
||||
compileOnly "com.github.ProxioDev.RedisBungee:RedisBungee-API:$redisBungeeProxioDevVersion"
|
||||
|
||||
testImplementation "com.velocitypowered:velocity-api:$velocityVersion"
|
||||
testImplementation "com.github.ProxioDev.RedisBungee:RedisBungee-API:$redisBungeeProxioDevVersion"
|
||||
testImplementation project(path: ":common", configuration: 'testArtifacts')
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,8 @@ import java.util.logging.Level;
|
||||
version = "@version@",
|
||||
description = "Player Analytics Plugin by AuroraLS3",
|
||||
dependencies = {
|
||||
@Dependency(id = "viaversion", optional = true)
|
||||
@Dependency(id = "viaversion", optional = true),
|
||||
@Dependency(id = "redisbungee", optional = true)
|
||||
},
|
||||
authors = {"AuroraLS3"}
|
||||
)
|
||||
|
@ -17,6 +17,8 @@
|
||||
package com.djrapitops.plan.gathering;
|
||||
|
||||
import com.djrapitops.plan.PlanVelocity;
|
||||
import com.djrapitops.plan.identification.properties.VelocityRedisCheck;
|
||||
import com.djrapitops.plan.identification.properties.VelocityRedisPlayersOnlineSupplier;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
@ -29,7 +31,9 @@ public class VelocitySensor implements ServerSensor<Object> {
|
||||
|
||||
@Inject
|
||||
public VelocitySensor(PlanVelocity plugin) {
|
||||
onlinePlayerCountSupplier = plugin.getProxy()::getPlayerCount;
|
||||
onlinePlayerCountSupplier = VelocityRedisCheck.isClassAvailable()
|
||||
? new VelocityRedisPlayersOnlineSupplier()
|
||||
: plugin.getProxy()::getPlayerCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.identification.properties;
|
||||
|
||||
/**
|
||||
* Utility class for checking if RedisBungee API is available.
|
||||
*
|
||||
* @author AuroraLS3
|
||||
*/
|
||||
public class VelocityRedisCheck {
|
||||
|
||||
private VelocityRedisCheck() {
|
||||
/* Static method class */
|
||||
}
|
||||
|
||||
public static boolean isClassAvailable() {
|
||||
try {
|
||||
Class.forName("com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI");
|
||||
return true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.identification.properties;
|
||||
|
||||
import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI;
|
||||
|
||||
import java.util.function.IntSupplier;
|
||||
|
||||
/**
|
||||
* Players online supplier when using RedisBungee.
|
||||
*
|
||||
* @author AuroraLS3
|
||||
*/
|
||||
public class VelocityRedisPlayersOnlineSupplier implements IntSupplier {
|
||||
|
||||
@Override
|
||||
public int getAsInt() {
|
||||
RedisBungeeAPI api = RedisBungeeAPI.getRedisBungeeApi();
|
||||
try {
|
||||
return api != null ? api.getPlayerCount() : -1;
|
||||
} catch (NullPointerException e) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user