Skip to content

Instantly share code, notes, and snippets.

Created May 30, 2016 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2c3fb5c0daccec49cc07e8212649bd34 to your computer and use it in GitHub Desktop.
Save anonymous/2c3fb5c0daccec49cc07e8212649bd34 to your computer and use it in GitHub Desktop.
// Construct CoolDown object.
Optional<CoolDown> coolDown = Optional.empty();
if (plugin.getConfig().getBoolean("items." + str + ".cooldown.enabled")) {
coolDown = Optional.of(new CoolDown(plugin.getConfig().getDouble("items." + str + ".cooldown.duration"),
plugin.getConfig().getBoolean("items." + str + ".use-formatted-time"),
plugin.getConfig().getBoolean("items." + str + ".use-expired-message"),
t(plugin.getConfig().getStringList("items." + str + ".consume-message")),
t(plugin.getConfig().getStringList("items." + str + ".cooldown-message")),
t(plugin.getConfig().getStringList("items." + str + ".expired-message"))));
}
Optional<String> permissionNode = Optional.ofNullable(plugin.getConfig().getString("items." + str + ".permission"));
// Construct ConsumptionControl object.
Optional<ConsumptionControl> consumptionControl = Optional.empty();
if (plugin.getConfig().getBoolean("items." + str + ".consumption-control.enabled")) {
consumptionControl = Optional.of(new ConsumptionControl(plugin.getConfig().getInt("items." + str + ".consumption-control.food-level"),
Float.valueOf(plugin.getConfig().getString("items." + str + ".consumption-control.saturation")),
plugin.getConfig().getStringList("items." + str + ".consumption-control.effects")));
}
// Add the item to the set.
items.add(new Item(material, confData, permissionNode.orElseGet(null), coolDown.orElseGet(null), consumptionControl.orElseGet(null)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment