Implements custom configuration values for blacksmiths and sentinels

This commit is contained in:
Kristian Knarvik 2022-11-03 14:24:18 +01:00
parent 1906e593e3
commit be127d0733
5 changed files with 43 additions and 14 deletions

View File

@ -71,13 +71,16 @@ public class BlacksmithHandler extends AbstractTraitHandler {
*/
private String getDetailedBlacksmithInfo(NPC npc, NPCSettings npcSettings) {
String info = "<h2>" + npc.getName() + " the " +
npcSettings.getBlacksmithTitle() + "</h2><b>Fail chance:</b> " + npcSettings.getFailChance() +
"<br><b>Enchantment chance:</b> " + npcSettings.getExtraEnchantmentChance() + "<br><b>Delay:</b> " +
npcSettings.getMinReforgeDelay() + " to " + npcSettings.getMaxReforgeDelay() +
" seconds<br><b>Cool-down:</b> " + npcSettings.getReforgeCoolDown() + " seconds<br><b>Drop item:</b> " +
npcSettings.getDropItem() + "<br><b>Max enchantments:</b> " + npcSettings.getMaxEnchantments();
if (!npcSettings.getReforgeAbleItems().isEmpty()) {
info += "<br><b>Reforge-able items:</b> " + getReforgeAbleItemsString(npcSettings.getReforgeAbleItems());
npcSettings.getBlacksmithTitle() + "</h2>";
if (settings.displayBlacksmithSettings()) {
info += "<b>Fail chance:</b> " + npcSettings.getFailChance() +
"<br><b>Enchantment chance:</b> " + npcSettings.getExtraEnchantmentChance() + "<br><b>Delay:</b> " +
npcSettings.getMinReforgeDelay() + " to " + npcSettings.getMaxReforgeDelay() +
" seconds<br><b>Cool-down:</b> " + npcSettings.getReforgeCoolDown() + " seconds<br><b>Drop item:</b> " +
npcSettings.getDropItem() + "<br><b>Max enchantments:</b> " + npcSettings.getMaxEnchantments();
if (!npcSettings.getReforgeAbleItems().isEmpty()) {
info += "<br><b>Reforge-able items:</b> " + getReforgeAbleItemsString(npcSettings.getReforgeAbleItems());
}
}
return info;
}

View File

@ -46,12 +46,14 @@ public class SentinelHandler extends AbstractTraitHandler {
if (trait.squad != null) {
description += "<br><b>Squad:</b> " + trait.squad;
}
description += "<br><b>Invincible:</b> " + trait.invincible + "<br><b>Armor:</b> " +
trait.armor + "<br><b>Health:</b> " + trait.health + "<br><b>Accuracy:</b> " + trait.accuracy +
"<br><b>Damage:</b> " + trait.damage + "<br><b>Allow knockback:</b> " + trait.allowKnockback;
description += "<br><b>Range:</b> " + trait.range + "<br><b>Reach:</b> " + trait.reach;
description += "<br><b>Targets:</b> " + trait.allTargets.toAllInOneString() + "<br><b>Avoids:</b> " +
trait.allAvoids.toAllInOneString() + "<br><b>Ignores:</b> " + trait.allIgnores.toAllInOneString();
if (settings.displaySentinelStats()) {
description += "<br><b>Invincible:</b> " + trait.invincible + "<br><b>Armor:</b> " +
trait.armor + "<br><b>Health:</b> " + trait.health + "<br><b>Accuracy:</b> " + trait.accuracy +
"<br><b>Damage:</b> " + trait.damage + "<br><b>Allow knockback:</b> " + trait.allowKnockback;
description += "<br><b>Range:</b> " + trait.range + "<br><b>Reach:</b> " + trait.reach;
description += "<br><b>Targets:</b> " + trait.allTargets.toAllInOneString() + "<br><b>Avoids:</b> " +
trait.allAvoids.toAllInOneString() + "<br><b>Ignores:</b> " + trait.allIgnores.toAllInOneString();
}
addNPCMarker(npc.getUniqueId(), "Sentinel NPC: ", description,
DynmapCitizens.getInstance().getGlobalSettings().getMarkerIcons().get(Icon.SENTINEL), super.markerSet);
}

View File

@ -7,9 +7,12 @@ import org.bukkit.configuration.file.FileConfiguration;
*/
public class BlacksmithSettings extends AbstractTraitSettings {
private boolean displayBlacksmithSettings;
@Override
public void load(FileConfiguration configuration) {
super.load(configuration);
displayBlacksmithSettings = configuration.getBoolean(getTraitConfigRoot() + ".displayBlacksmithSettings", true);
}
@Override
@ -17,4 +20,13 @@ public class BlacksmithSettings extends AbstractTraitSettings {
return "traits.blacksmith";
}
/**
* Gets whether to display information about a blacksmith's settings, such as cool-down, in the marker description
*
* @return <p>True if blacksmith settings should be displayed</p>
*/
public boolean displayBlacksmithSettings() {
return displayBlacksmithSettings;
}
}

View File

@ -7,9 +7,12 @@ import org.bukkit.configuration.file.FileConfiguration;
*/
public class SentinelSettings extends AbstractTraitSettings {
private boolean displaySentinelStats;
@Override
public void load(FileConfiguration configuration) {
super.load(configuration);
displaySentinelStats = configuration.getBoolean(getTraitConfigRoot() + ".displaySentinelStats", true);
}
@Override
@ -17,4 +20,13 @@ public class SentinelSettings extends AbstractTraitSettings {
return "traits.sentinel";
}
/**
* Gets whether to display information about a sentinel such as health, attack and targets in marker descriptions
*
* @return <p>True if sentinel stats should be displayed</p>
*/
public boolean displaySentinelStats() {
return displaySentinelStats;
}
}

View File

@ -112,7 +112,7 @@ traits:
# Whether to hide the sentinel icon layer by default
markersHiddenByDefault: false
# Whether to display information about a sentinel's health, armor and damage in the marker description
displaySentinelStrength: true
displaySentinelStats: true
# Settings for the minstrel trait
minstrel:
enabled: true