mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-10 04:41:26 +01:00
Add PluginData#getPlaceholder (For placeholder getting without the modifier)
This commit is contained in:
parent
eb83601734
commit
2be6f7ff90
@ -87,9 +87,7 @@ public enum Settings {
|
||||
HIDE_TOWNS("Plugins.Towny.HideTowns"),
|
||||
//
|
||||
// Bungee
|
||||
BUNGEE_IP("Server.IP")
|
||||
;
|
||||
|
||||
BUNGEE_IP("Server.IP");
|
||||
|
||||
private final String configPath;
|
||||
private Boolean value;
|
||||
|
@ -53,7 +53,7 @@ public class HookHandler {
|
||||
configHandler.createSection(dataSource);
|
||||
}
|
||||
if (configHandler.isEnabled(dataSource)) {
|
||||
Log.debug("Registered a new datasource: " + StringUtils.remove(dataSource.getPlaceholder(""), '%'));
|
||||
Log.debug("Registered a new datasource: " + StringUtils.remove(dataSource.getPlaceholder(), '%'));
|
||||
additionalDataSources.add(dataSource);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@ -104,9 +104,9 @@ public class HookHandler {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
addReplace.put(source.getPlaceholder(""), source.getHtmlReplaceValue("", uuid));
|
||||
addReplace.put(source.getPlaceholder(), source.getHtmlReplaceValue("", uuid));
|
||||
} catch (Exception e) {
|
||||
addReplace.put(source.getPlaceholder(""), "Error occurred: " + e);
|
||||
addReplace.put(source.getPlaceholder(), "Error occurred: " + e);
|
||||
Log.error("PluginDataSource caused an exception: " + source.getSourcePlugin());
|
||||
Log.toLog("PluginDataSource " + source.getSourcePlugin(), e);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class PluginConfigSectionHandler {
|
||||
}
|
||||
|
||||
ConfigurationSection pluginSection = section.getConfigurationSection(pluginName);
|
||||
return pluginSection.contains(dataSource.getPlaceholder(""));
|
||||
return pluginSection.contains(dataSource.getPlaceholder());
|
||||
}
|
||||
|
||||
private ConfigurationSection getPluginsSection() {
|
||||
|
@ -150,13 +150,23 @@ public abstract class PluginData {
|
||||
*
|
||||
* @param modifier Modifier determined by AnalysisType's
|
||||
* placeholderModifier-variable.
|
||||
* @return for example "%StepCounter_stepsTaken_total%"
|
||||
* @return for example "${StepCounter_stepsTaken_total}"
|
||||
* @see AnalysisType
|
||||
*/
|
||||
public final String getPlaceholder(String modifier) {
|
||||
return "${" + sourcePlugin + "_" + placeholder + modifier + "}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the placeholder without the modifier.
|
||||
*
|
||||
* @return for example "${StepCounter_stepsTaken}"
|
||||
* @see #getPlaceholder(String)
|
||||
*/
|
||||
public final String getPlaceholder() {
|
||||
return "${" + sourcePlugin + "_" + placeholder + "}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the source plugin's name.
|
||||
*
|
||||
|
@ -192,7 +192,7 @@ public class Analysis {
|
||||
Log.debug("Analysis", "Additional Sources: " + sources.size());
|
||||
sources.parallelStream().filter(Verify::notNull).forEach(source -> {
|
||||
try {
|
||||
Benchmark.start("Source " + StringUtils.remove(source.getPlaceholder(""), '%'));
|
||||
Benchmark.start("Source " + StringUtils.remove(source.getPlaceholder(), '%'));
|
||||
final List<AnalysisType> analysisTypes = source.getAnalysisTypes();
|
||||
if (analysisTypes.isEmpty()) {
|
||||
return;
|
||||
@ -218,11 +218,11 @@ public class Analysis {
|
||||
replaceMap.put(source.getPlaceholder(boolTot.getPlaceholderModifier()), AnalysisUtils.getBooleanTotal(boolTot, source, uuids));
|
||||
}
|
||||
} 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(), '%'));
|
||||
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
} finally {
|
||||
Benchmark.stop("Analysis", "Source " + StringUtils.remove(source.getPlaceholder(""), '%'));
|
||||
Benchmark.stop("Analysis", "Source " + StringUtils.remove(source.getPlaceholder(), '%'));
|
||||
}
|
||||
});
|
||||
Benchmark.stop("Analysis", "3rd party");
|
||||
@ -303,7 +303,7 @@ public class Analysis {
|
||||
return value instanceof Boolean
|
||||
&& (boolean) value;
|
||||
} catch (Exception | NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {
|
||||
Log.toLog(pluginData.getSourcePlugin() + pluginData.getPlaceholder("") + " (Cause) ", e);
|
||||
Log.toLog(pluginData.getSourcePlugin() + pluginData.getPlaceholder() + " (Cause) ", e);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
@ -195,7 +195,7 @@ public class AnalysisUtils {
|
||||
}
|
||||
|
||||
private static String logPluginDataCausedError(PluginData source, Throwable e) {
|
||||
String placeholder = StringUtils.remove(source.getPlaceholder(""), '%');
|
||||
String placeholder = StringUtils.remove(source.getPlaceholder(), '%');
|
||||
|
||||
Log.error("A PluginData-source caused an exception: " + placeholder);
|
||||
Log.toLog("PluginData-source caused an exception: " + placeholder, e);
|
||||
|
@ -336,7 +336,7 @@ public class HtmlStructure {
|
||||
String pluginName = source.getSourcePlugin();
|
||||
List<String> pluginPlaceholderList = placeholders.getOrDefault(pluginName, new ArrayList<>());
|
||||
|
||||
pluginPlaceholderList.add(source.getPlaceholder(""));
|
||||
pluginPlaceholderList.add(source.getPlaceholder());
|
||||
|
||||
placeholders.put(pluginName, pluginPlaceholderList);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user