Add PluginData#getPlaceholder (For placeholder getting without the modifier)

This commit is contained in:
Fuzzlemann 2017-09-01 12:14:36 +02:00
parent eb83601734
commit 2be6f7ff90
7 changed files with 22 additions and 14 deletions

View File

@ -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;

View File

@ -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);
}

View File

@ -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() {

View File

@ -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.
*

View File

@ -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;
}
});

View File

@ -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);

View File

@ -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);
}