mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-12 15:56:00 +08:00
Merge branch '4.0.0-BungeeCord-Support' of https://github.com/Rsl1122/Plan-PlayerAnalytics
This commit is contained in:
commit
21aec1fb6d
@ -265,7 +265,7 @@ public class Plan extends BukkitPlugin<Plan> {
|
||||
|
||||
getPluginLogger().endAllDebugs();
|
||||
Log.info(Locale.get(Msg.DISABLED).toString());
|
||||
Locale.unload();
|
||||
// Locale.unload();
|
||||
}
|
||||
|
||||
private void registerListeners() {
|
||||
|
@ -36,6 +36,8 @@ public enum Settings {
|
||||
PROCESS_GET_LIMIT("Settings.Cache.Processing.GetLimit"),
|
||||
PROCESS_SAVE_LIMIT("Settings.Cache.Processing.SaveLimit"),
|
||||
PROCESS_CLEAR_LIMIT("Settings.Cache.Processing.ClearLimit"),
|
||||
TPS_GRAPH_HIGH("Customization.Colors.HTML.TPSGraph.TPSHigh"),
|
||||
TPS_GRAPH_MED("Customization.Colors.HTML.TPSGraph.TPSMedium"),
|
||||
// String
|
||||
DEBUG("Settings.Debug"),
|
||||
ALTERNATIVE_IP("Settings.WebServer.AlternativeIP"),
|
||||
@ -73,6 +75,9 @@ public enum Settings {
|
||||
HCOLOR_SEC("Customization.Colors.HTML.UI.Secondary"),
|
||||
HCOLOR_TER("Customization.Colors.HTML.UI.Tertiary"),
|
||||
HCOLOR_TER_DARK("Customization.Colors.HTML.UI.TertiaryDark"),
|
||||
HCOLOR_TPS_HIGH("Customization.Colors.HTML.TPSGraph.TPSHighCol"),
|
||||
HCOLOR_TPS_MED("Customization.Colors.HTML.TPSGraph.TPSMediumCol"),
|
||||
HCOLOR_TPS_LOW("Customization.Colors.HTML.TPSGraph.TPSLowCol"),
|
||||
HCOLOR_ACT_ONL("Customization.Colors.HTML.ActivityGraph.OnlinePlayers"),
|
||||
HCOLOR_ACTP_ACT("Customization.Colors.HTML.ActivityPie.Active"),
|
||||
HCOLOR_ACTP_BAN("Customization.Colors.HTML.ActivityPie.Banned"),
|
||||
|
@ -79,18 +79,20 @@ public class AnalyzeCommand extends SubCommand {
|
||||
}
|
||||
}).runTaskAsynchronously();
|
||||
}
|
||||
updateCache();
|
||||
runMessageSenderTask(sender);
|
||||
updateCache(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updateCache() {
|
||||
private void updateCache(ISender sender) {
|
||||
if (!analysisCache.isCached() || MiscUtils.getTime() - analysisCache.getData().getRefreshDate() > TimeAmount.MINUTE.ms()) {
|
||||
int bootAnID = plugin.getBootAnalysisTaskID();
|
||||
if (bootAnID != -1) {
|
||||
plugin.getServer().getScheduler().cancelTask(bootAnID);
|
||||
}
|
||||
analysisCache.addNotification(sender);
|
||||
analysisCache.updateCache();
|
||||
} else {
|
||||
analysisCache.sendAnalysisMessage(sender);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package main.java.com.djrapitops.plan.data.analysis;
|
||||
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.data.TPS;
|
||||
import main.java.com.djrapitops.plan.ui.html.graphs.CPUGraphCreator;
|
||||
import main.java.com.djrapitops.plan.ui.html.graphs.RamGraphCreator;
|
||||
@ -40,6 +41,11 @@ public class TPSPart extends RawData {
|
||||
List<TPS> week = TPSGraphCreator.filterTPS(tpsData, now - TimeAmount.WEEK.ms());
|
||||
List<TPS> day = TPSGraphCreator.filterTPS(tpsData, now - TimeAmount.DAY.ms());
|
||||
|
||||
addValue("tpshighcol", "#"+ Settings.HCOLOR_TPS_HIGH);
|
||||
addValue("tpsmediumcol", "#"+ Settings.HCOLOR_TPS_MED);
|
||||
addValue("tpslowcol", "#"+ Settings.HCOLOR_TPS_LOW);
|
||||
addValue("tpsmedium", Settings.TPS_GRAPH_MED.getNumber());
|
||||
addValue("tpshigh", Settings.TPS_GRAPH_HIGH.getNumber());
|
||||
|
||||
addValue("tpsseries", TPSGraphCreator.buildSeriesDataString(tpsData));
|
||||
addValue("cpuseries", CPUGraphCreator.buildSeriesDataString(tpsData));
|
||||
|
@ -1,8 +1,22 @@
|
||||
package main.java.com.djrapitops.plan.data.cache;
|
||||
|
||||
import com.djrapitops.plugin.command.CommandUtils;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.utilities.player.IPlayer;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.data.AnalysisData;
|
||||
import main.java.com.djrapitops.plan.locale.Locale;
|
||||
import main.java.com.djrapitops.plan.locale.Msg;
|
||||
import main.java.com.djrapitops.plan.ui.text.TextUI;
|
||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.Analysis;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* This class is used to store the most recent AnalysisData object and to run
|
||||
@ -13,10 +27,13 @@ import main.java.com.djrapitops.plan.utilities.analysis.Analysis;
|
||||
*/
|
||||
public class AnalysisCacheHandler {
|
||||
|
||||
private final Plan plugin;
|
||||
private final Analysis analysis;
|
||||
private AnalysisData cache;
|
||||
private boolean analysisEnabled;
|
||||
|
||||
private Set<UUID> notifyWhenCached;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
* <p>
|
||||
@ -25,8 +42,10 @@ public class AnalysisCacheHandler {
|
||||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public AnalysisCacheHandler(Plan plugin) {
|
||||
this.plugin = plugin;
|
||||
analysis = new Analysis(plugin);
|
||||
analysisEnabled = true;
|
||||
notifyWhenCached = new HashSet<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -43,6 +62,33 @@ public class AnalysisCacheHandler {
|
||||
*/
|
||||
public void cache(AnalysisData data) {
|
||||
cache = data;
|
||||
for (UUID uuid : notifyWhenCached) {
|
||||
Optional<IPlayer> player = plugin.fetch().getPlayer(uuid);
|
||||
if (player.isPresent()) {
|
||||
sendAnalysisMessage(player.get());
|
||||
}
|
||||
}
|
||||
notifyWhenCached.clear();
|
||||
}
|
||||
|
||||
public void sendAnalysisMessage(ISender sender) {
|
||||
boolean textUI = Settings.USE_ALTERNATIVE_UI.isTrue();
|
||||
sender.sendMessage(Locale.get(Msg.CMD_HEADER_ANALYZE).toString());
|
||||
if (textUI) {
|
||||
sender.sendMessage(TextUI.getAnalysisMessages());
|
||||
} else {
|
||||
// Link
|
||||
String url = HtmlUtils.getServerAnalysisUrlWithProtocol();
|
||||
String message = Locale.get(Msg.CMD_INFO_LINK).toString();
|
||||
boolean console = !CommandUtils.isPlayer(sender);
|
||||
if (console) {
|
||||
sender.sendMessage(message + url);
|
||||
} else {
|
||||
sender.sendMessage(message);
|
||||
sender.sendLink(" ", Locale.get(Msg.CMD_INFO_CLICK_ME).toString(), url);
|
||||
}
|
||||
}
|
||||
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,4 +129,10 @@ public class AnalysisCacheHandler {
|
||||
analysis.setTaskId(-1);
|
||||
analysisEnabled = true;
|
||||
}
|
||||
|
||||
public void addNotification(ISender sender) {
|
||||
if (CommandUtils.isPlayer(sender)) {
|
||||
notifyWhenCached.add(((Player) sender.getSender()).getUniqueId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,8 +47,12 @@ public class PunchCardGraphCreator {
|
||||
if (value == 0) {
|
||||
continue;
|
||||
}
|
||||
arrayBuilder.append("{x:").append(j * 3600000)
|
||||
.append(", y:").append(i)
|
||||
if (j == 0) {
|
||||
arrayBuilder.append("{x:").append(24 * 3600000);
|
||||
} else {
|
||||
arrayBuilder.append("{x:").append(j * 3600000);
|
||||
}
|
||||
arrayBuilder.append(", y:").append(i)
|
||||
.append(", z:").append(value).
|
||||
append(", marker: { radius:").append(value)
|
||||
.append("}}");
|
||||
|
@ -229,7 +229,7 @@ public class Analysis {
|
||||
if (analysisTypes.contains(boolTot)) {
|
||||
replaceMap.put(source.getPlaceholder(boolTot.getPlaceholderModifier()), AnalysisUtils.getBooleanTotal(boolTot, source, uuids));
|
||||
}
|
||||
} catch (Exception | NoClassDefFoundError | NoSuchFieldError e) {
|
||||
} catch (Exception | NoClassDefFoundError | NoSuchFieldError | NoSuchMethodError e) {
|
||||
Log.error("A PluginData-source caused an exception: " + source.getPlaceholder("").replace("%", ""));
|
||||
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
|
@ -691,18 +691,27 @@
|
||||
}
|
||||
};
|
||||
var tpsSeries = {
|
||||
name: 'TPS',
|
||||
data: %tpsseries%,
|
||||
name: 'TPS',
|
||||
data: %tpsseries%,
|
||||
type: 'spline',
|
||||
color: '#b74343',
|
||||
zones: [{
|
||||
value: %tpsmedium%,
|
||||
color: '%tpslowcol%'
|
||||
}, {
|
||||
value: %tpshigh%,
|
||||
color: '%tpsmediumcol%'
|
||||
}, {
|
||||
value: 30,
|
||||
color: '%tpshighcol%'
|
||||
}],
|
||||
tooltip: {
|
||||
valueDecimals: 2
|
||||
},
|
||||
valueDecimals: 2
|
||||
},
|
||||
yAxis: 1
|
||||
};
|
||||
var cpuSeries = {
|
||||
name: 'CPU Usage',
|
||||
data: %cpuseries%,
|
||||
name: 'CPU Usage',
|
||||
data: %cpuseries%,
|
||||
type: 'areaspline',
|
||||
color: '#e0d264',
|
||||
tooltip: {
|
||||
@ -710,8 +719,8 @@
|
||||
}
|
||||
};
|
||||
var ramSeries = {
|
||||
name: 'RAM Usage',
|
||||
data: %ramseries%,
|
||||
name: 'RAM Usage',
|
||||
data: %ramseries%,
|
||||
type: 'areaspline',
|
||||
color: '#7dcc24',
|
||||
tooltip: {
|
||||
@ -720,8 +729,8 @@
|
||||
yAxis: 1
|
||||
};
|
||||
var entitySeries = {
|
||||
name: 'Loaded Entities',
|
||||
data: %entityseries%,
|
||||
name: 'Loaded Entities',
|
||||
data: %entityseries%,
|
||||
type: 'areaspline',
|
||||
color: '#ac69ef',
|
||||
tooltip: {
|
||||
@ -730,8 +739,8 @@
|
||||
yAxis: 1
|
||||
};
|
||||
var chunkSeries = {
|
||||
name: 'Loaded Chunks',
|
||||
data: %chunkseries%,
|
||||
name: 'Loaded Chunks',
|
||||
data: %chunkseries%,
|
||||
type: 'areaspline',
|
||||
color: '#b58310',
|
||||
tooltip: {
|
||||
@ -744,18 +753,18 @@
|
||||
data: [{
|
||||
name: 'Active',
|
||||
y: %active%
|
||||
}, {
|
||||
name: 'Inactive',
|
||||
y: %inactive%,
|
||||
sliced: true,
|
||||
selected: true
|
||||
}, {
|
||||
name: 'Single Join',
|
||||
y: %joinleaver%
|
||||
}, {
|
||||
name: 'Banned',
|
||||
y: %banned%
|
||||
}]
|
||||
}, {
|
||||
name: 'Inactive',
|
||||
y: %inactive%,
|
||||
sliced: true,
|
||||
selected: true
|
||||
}, {
|
||||
name: 'Single Join',
|
||||
y: %joinleaver%
|
||||
}, {
|
||||
name: 'Banned',
|
||||
y: %banned%
|
||||
}]
|
||||
};
|
||||
var gmData = %gmdata%;
|
||||
var gmSeries = {
|
||||
|
@ -70,6 +70,12 @@ Customization:
|
||||
Secondary: 5cb239
|
||||
Tertiary: 89c471
|
||||
TertiaryDark: 5da341
|
||||
TPSGraph:
|
||||
TPSHigh: 18
|
||||
TPSMedium: 10
|
||||
TPSHighCol: 267F00
|
||||
TPSMediumCol: e5cc12
|
||||
TPSLowCol: b74343
|
||||
ActivityGraph:
|
||||
OnlinePlayers: '1E90FF'
|
||||
NewPlayers: '228B22'
|
||||
|
@ -1,7 +1,7 @@
|
||||
name: Plan
|
||||
author: Rsl1122
|
||||
main: main.java.com.djrapitops.plan.Plan
|
||||
version: 3.6.3
|
||||
version: 3.6.4
|
||||
softdepend:
|
||||
- OnTime
|
||||
- EssentialsX
|
||||
|
Loading…
Reference in New Issue
Block a user