mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-24 16:14:26 +08:00
Plugins Tab placeholders now replaced properly
This commit is contained in:
parent
7fd3386a47
commit
4a246d4c5c
@ -20,56 +20,56 @@ public enum AnalysisType {
|
|||||||
* <p>
|
* <p>
|
||||||
* -1 values will be disregarded from the calculation (size will not grow).
|
* -1 values will be disregarded from the calculation (size will not grow).
|
||||||
*/
|
*/
|
||||||
INT_AVG("avgInt_", "Average "),
|
INT_AVG("_avgInt", "Average "),
|
||||||
/**
|
/**
|
||||||
* Used when the getValue() method returns a long and average should be
|
* Used when the getValue() method returns a long and average should be
|
||||||
* calculated.
|
* calculated.
|
||||||
* <p>
|
* <p>
|
||||||
* -1 values will be disregarded from the calculation (size will not grow).
|
* -1 values will be disregarded from the calculation (size will not grow).
|
||||||
*/
|
*/
|
||||||
LONG_AVG("avgLong_", "Average "),
|
LONG_AVG("_avgLong", "Average "),
|
||||||
/**
|
/**
|
||||||
* Used when the getValue() method returns double and average should be
|
* Used when the getValue() method returns double and average should be
|
||||||
* calculated.
|
* calculated.
|
||||||
* <p>
|
* <p>
|
||||||
* -1 values will be disregarded from the calculation (size will not grow).
|
* -1 values will be disregarded from the calculation (size will not grow).
|
||||||
*/
|
*/
|
||||||
DOUBLE_AVG("avgDouble_", "Average "),
|
DOUBLE_AVG("_avgDouble", "Average "),
|
||||||
/**
|
/**
|
||||||
* Used when the getValue() method returns an integer and total should be
|
* Used when the getValue() method returns an integer and total should be
|
||||||
* calculated.
|
* calculated.
|
||||||
* <p>
|
* <p>
|
||||||
* -1 values will be disregarded from the calculation (size will not grow).
|
* -1 values will be disregarded from the calculation (size will not grow).
|
||||||
*/
|
*/
|
||||||
INT_TOTAL("totalInt_", "Total "),
|
INT_TOTAL("_totalInt", "Total "),
|
||||||
/**
|
/**
|
||||||
* Used when the getValue() method returns a long and total should be
|
* Used when the getValue() method returns a long and total should be
|
||||||
* calculated.
|
* calculated.
|
||||||
* <p>
|
* <p>
|
||||||
* -1 values will be disregarded from the calculation (size will not grow).
|
* -1 values will be disregarded from the calculation (size will not grow).
|
||||||
*/
|
*/
|
||||||
LONG_TOTAL("totalLong_", "Total "),
|
LONG_TOTAL("_totalLong", "Total "),
|
||||||
/**
|
/**
|
||||||
* Used when the getValue() method returns a double and total should be
|
* Used when the getValue() method returns a double and total should be
|
||||||
* calculated.
|
* calculated.
|
||||||
* <p>
|
* <p>
|
||||||
* -1 values will be disregarded from the calculation (size will not grow).
|
* -1 values will be disregarded from the calculation (size will not grow).
|
||||||
*/
|
*/
|
||||||
DOUBLE_TOTAL("totalDouble_", "Total "),
|
DOUBLE_TOTAL("_totalDouble", "Total "),
|
||||||
/**
|
/**
|
||||||
* Used when the getValue() method returns an amount of milliseconds as long
|
* Used when the getValue() method returns an amount of milliseconds as long
|
||||||
* and average should be calculated.
|
* and average should be calculated.
|
||||||
* <p>
|
* <p>
|
||||||
* -1 values will be disregarded from the calculation (size will not grow).
|
* -1 values will be disregarded from the calculation (size will not grow).
|
||||||
*/
|
*/
|
||||||
LONG_TIME_MS_AVG("avgTimeMs_", "Average "),
|
LONG_TIME_MS_AVG("_avgTimeMs", "Average "),
|
||||||
/**
|
/**
|
||||||
* Used when the getValue() method returns an amount of milliseconds as long
|
* Used when the getValue() method returns an amount of milliseconds as long
|
||||||
* and total should be calculated.
|
* and total should be calculated.
|
||||||
* <p>
|
* <p>
|
||||||
* -1 values will be disregarded from the calculation (size will not grow).
|
* -1 values will be disregarded from the calculation (size will not grow).
|
||||||
*/
|
*/
|
||||||
LONG_TIME_MS_TOTAL("totalTimeMs_"),
|
LONG_TIME_MS_TOTAL("_totalTimeMs"),
|
||||||
/**
|
/**
|
||||||
* Used when the getValue() method returns an Epoch Millisecond as long and
|
* Used when the getValue() method returns an Epoch Millisecond as long and
|
||||||
* average of differences between the millisecond and current millisecond
|
* average of differences between the millisecond and current millisecond
|
||||||
@ -81,18 +81,18 @@ public enum AnalysisType {
|
|||||||
* <p>
|
* <p>
|
||||||
* -1 values will be disregarded from the calculation (size will not grow).
|
* -1 values will be disregarded from the calculation (size will not grow).
|
||||||
*/
|
*/
|
||||||
LONG_EPOCH_MS_MINUS_NOW_AVG("avgEpochMsMinusNow_", "Average "),
|
LONG_EPOCH_MS_MINUS_NOW_AVG("_avgEpochMsMinusNow", "Average "),
|
||||||
/**
|
/**
|
||||||
* Used to calculate %-true for the returned boolean values of getValue().
|
* Used to calculate %-true for the returned boolean values of getValue().
|
||||||
*/
|
*/
|
||||||
BOOLEAN_PERCENTAGE("perchBool_", "Percentage "),
|
BOOLEAN_PERCENTAGE("_perchBool", "Percentage "),
|
||||||
/**
|
/**
|
||||||
* Used to calculate number of true values for the returned boolean values
|
* Used to calculate number of true values for the returned boolean values
|
||||||
* of getValue().
|
* of getValue().
|
||||||
* <p>
|
* <p>
|
||||||
* Will be presented as "n / total".
|
* Will be presented as "n / total".
|
||||||
*/
|
*/
|
||||||
BOOLEAN_TOTAL("totalBool_"),
|
BOOLEAN_TOTAL("_totalBool"),
|
||||||
/**
|
/**
|
||||||
* Used to add html tags to the plugins tab.
|
* Used to add html tags to the plugins tab.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -104,9 +104,9 @@ public class HookHandler {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
addReplace.put(source.getPlaceholder(), source.getHtmlReplaceValue("", uuid));
|
addReplace.put(source.getPlaceholderName(), source.getHtmlReplaceValue("", uuid));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
addReplace.put(source.getPlaceholder(), "Error occurred: " + e);
|
addReplace.put(source.getPlaceholderName(), "Error occurred: " + e);
|
||||||
Log.error("PluginDataSource caused an exception: " + source.getSourcePlugin());
|
Log.error("PluginDataSource caused an exception: " + source.getSourcePlugin());
|
||||||
Log.toLog("PluginDataSource " + source.getSourcePlugin(), e);
|
Log.toLog("PluginDataSource " + source.getSourcePlugin(), e);
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ public abstract class PluginData {
|
|||||||
* @see AnalysisType
|
* @see AnalysisType
|
||||||
*/
|
*/
|
||||||
public final String getPlaceholder(String modifier) {
|
public final String getPlaceholder(String modifier) {
|
||||||
return "${" + sourcePlugin + "_" + placeholder + modifier + "}";
|
return "${" + getPlaceholderName(modifier) + "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -166,7 +166,27 @@ public abstract class PluginData {
|
|||||||
* @see #getPlaceholder(String)
|
* @see #getPlaceholder(String)
|
||||||
*/
|
*/
|
||||||
public final String getPlaceholder() {
|
public final String getPlaceholder() {
|
||||||
return "${" + sourcePlugin + "_" + placeholder + "}";
|
return "${" + getPlaceholderName() + "}";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to get the placeholder name with modifier.
|
||||||
|
*
|
||||||
|
* @return for example "StepCounter_stepsTaken_modifier"
|
||||||
|
* @see #getPlaceholder(String)
|
||||||
|
*/
|
||||||
|
public final String getPlaceholderName(String modifier) {
|
||||||
|
return getPlaceholderName() + modifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to get the placeholder name.
|
||||||
|
*
|
||||||
|
* @return for example "StepCounter_stepsTaken"
|
||||||
|
* @see #getPlaceholder(String)
|
||||||
|
*/
|
||||||
|
public final String getPlaceholderName() {
|
||||||
|
return sourcePlugin + "_" + placeholder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -478,6 +478,7 @@ public class WebServer {
|
|||||||
return PageCache.loadPage("notFound: " + error, () -> new NotFoundResponse(error));
|
return PageCache.loadPage("notFound: " + error, () -> new NotFoundResponse(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugin.getInfoManager().cachePlayer(uuid);
|
||||||
return PageCache.loadPage("inspectPage: " + uuid, () -> new InspectPageResponse(infoManager, uuid));
|
return PageCache.loadPage("inspectPage: " + uuid, () -> new InspectPageResponse(infoManager, uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,24 +171,24 @@ public class Analysis {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (analysisTypes.contains(AnalysisType.HTML)) {
|
if (analysisTypes.contains(AnalysisType.HTML)) {
|
||||||
replaceMap.put(source.getPlaceholder(AnalysisType.HTML.getPlaceholderModifier()), source.getHtmlReplaceValue(AnalysisType.HTML.getModifier(), UUID.randomUUID()));
|
replaceMap.put(source.getPlaceholderName(AnalysisType.HTML.getPlaceholderModifier()), source.getHtmlReplaceValue(AnalysisType.HTML.getModifier(), UUID.randomUUID()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (AnalysisType type : totalTypes) {
|
for (AnalysisType type : totalTypes) {
|
||||||
if (analysisTypes.contains(type)) {
|
if (analysisTypes.contains(type)) {
|
||||||
replaceMap.put(source.getPlaceholder(type.getPlaceholderModifier()), AnalysisUtils.getTotal(type, source, uuids));
|
replaceMap.put(source.getPlaceholderName(type.getPlaceholderModifier()), AnalysisUtils.getTotal(type, source, uuids));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (AnalysisType type : avgTypes) {
|
for (AnalysisType type : avgTypes) {
|
||||||
if (analysisTypes.contains(type)) {
|
if (analysisTypes.contains(type)) {
|
||||||
replaceMap.put(source.getPlaceholder(type.getPlaceholderModifier()), AnalysisUtils.getAverage(type, source, uuids));
|
replaceMap.put(source.getPlaceholderName(type.getPlaceholderModifier()), AnalysisUtils.getAverage(type, source, uuids));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (analysisTypes.contains(bool)) {
|
if (analysisTypes.contains(bool)) {
|
||||||
replaceMap.put(source.getPlaceholder(bool.getPlaceholderModifier()), AnalysisUtils.getBooleanPercentage(bool, source, uuids));
|
replaceMap.put(source.getPlaceholderName(bool.getPlaceholderModifier()), AnalysisUtils.getBooleanPercentage(bool, source, uuids));
|
||||||
}
|
}
|
||||||
if (analysisTypes.contains(boolTot)) {
|
if (analysisTypes.contains(boolTot)) {
|
||||||
replaceMap.put(source.getPlaceholder(boolTot.getPlaceholderModifier()), AnalysisUtils.getBooleanTotal(boolTot, source, uuids));
|
replaceMap.put(source.getPlaceholderName(boolTot.getPlaceholderModifier()), AnalysisUtils.getBooleanTotal(boolTot, source, uuids));
|
||||||
}
|
}
|
||||||
} catch (Exception | NoClassDefFoundError | NoSuchFieldError | NoSuchMethodError e) {
|
} catch (Exception | NoClassDefFoundError | NoSuchFieldError | NoSuchMethodError e) {
|
||||||
Log.error("A PluginData-source caused an exception: " + StringUtils.remove(source.getPlaceholder(), '%'));
|
Log.error("A PluginData-source caused an exception: " + StringUtils.remove(source.getPlaceholder(), '%'));
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
<i style="padding: 0; color: #348e0f; font-size: 95px;" class="fa fa-square fa-stack-1x"></i>
|
<i style="padding: 0; color: #348e0f; font-size: 95px;" class="fa fa-square fa-stack-1x"></i>
|
||||||
<i style="padding: 0; color: #fff; font-size: 60px;" class="fa fa-circle fa-stack-1x"></i>
|
<i style="padding: 0; color: #fff; font-size: 60px;" class="fa fa-circle fa-stack-1x"></i>
|
||||||
<div style="margin: 0px; padding: 0px; width: 100%; height: 100%; position: relative; overflow: hidden; top: -6px;">
|
<div style="margin: 0px; padding: 0px; width: 100%; height: 100%; position: relative; overflow: hidden; top: -6px;">
|
||||||
<i style="position: absolute; left: -4px; top: 8px; color: #348e0f; font-size: 40px;" class="fa fa-bar-chart fa-stack-1x"></i>
|
<i style="position: absolute; left: -4px; top: 8px; color: #348e0f; font-size: 40px;"
|
||||||
|
class="fa fa-bar-chart fa-stack-1x"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p class="right">Player Analytics v.${version}</p>
|
<p class="right">Player Analytics v.${version}</p>
|
||||||
@ -42,7 +43,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div id="limiter" class="main-limiter">
|
<div id="limiter" class="main-limiter">
|
||||||
<div id="main" class="main-wrapper" style="width: 400%;">
|
<div id="main" class="main-wrapper">
|
||||||
<div id="tab-information" class="tab">
|
<div id="tab-information" class="tab">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
@ -206,6 +207,7 @@
|
|||||||
color: '#222',
|
color: '#222',
|
||||||
data: ${punchCardSeries}
|
data: ${punchCardSeries}
|
||||||
};
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
var navButtons = document.getElementsByClassName("nav-button");
|
var navButtons = document.getElementsByClassName("nav-button");
|
||||||
@ -256,6 +258,7 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
Reference in New Issue
Block a user