Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BungeeCord IP forwarding as 3rd auth setting #83

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions bukkit/src/main/java/org/bstats/bukkit/Metrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ public Metrics(JavaPlugin plugin, int serviceId) {
public void addCustomChart(CustomChart chart) {
metricsBase.addCustomChart(chart);
}



private void appendPlatformData(JsonObjectBuilder builder) {
builder.appendField("playerAmount", getPlayerAmount());
builder.appendField("onlineMode", Bukkit.getOnlineMode() ? 1 : 0);
builder.appendField("onlineMode", getOnlineMode());
builder.appendField("bukkitVersion", Bukkit.getVersion());
builder.appendField("bukkitName", Bukkit.getName());

Expand All @@ -105,6 +107,16 @@ private void appendPlatformData(JsonObjectBuilder builder) {
private void appendServiceData(JsonObjectBuilder builder) {
builder.appendField("pluginVersion", plugin.getDescription().getVersion());
}

private Object getOnlineMode() {
boolean onlineMode = Bukkit.getOnlineMode();
try {
if (Class.forName("org.spigotmc.SpigotConfig").getField("bungee").getBoolean(null)) {
return "bungee";
}
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException ignored) { }
return onlineMode ? 1 : 0;
}

private int getPlayerAmount() {
try {
Expand All @@ -119,4 +131,4 @@ private int getPlayerAmount() {
}
}

}
}