Fixes some smaller details

Adds some README info
Replaces the default dynmap info popup
Removes the first line break when printing flags
This commit is contained in:
Kristian Knarvik 2024-05-14 15:14:45 +02:00
parent 7c8429a65c
commit 0bcecba156
4 changed files with 21 additions and 14 deletions

0
README
View File

4
README.md Normal file
View File

@ -0,0 +1,4 @@
# Dynmap Factions
This plugin adds customizable area markers for factions, in addition to faction home markers. While faction does have
built-in faction markers, those only cover a single chunk, not the entire faction.

View File

@ -35,7 +35,9 @@ import java.util.Set;
public class FactionsUpdate implements Runnable {
private static final String DEF_INFO_WINDOW = "<div class=\"infoWindow\"><span style=\"font-size:120%;\">" +
"%regionName%</span><br />Flags<br /><span style=\"font-weight:bold;\">%flags%</span></div>";
"%regionName%</span><br/>Description: <span style=\"font-weight:bold;\">%description%</span><br/>Leader: " +
"<span style=\"font-weight:bold;\">%playerOwners%</span><br/>Members: <span style=\"font-weight:bold;\">" +
"%playerMembers%</span><br />Flags<br /><span style=\"font-weight:bold;\">%flags%</span></div>";
private final String infoWindow;
private final DynmapFactionsPlugin dynmapFactionsPlugin;
public boolean runonce;
@ -375,11 +377,11 @@ public class FactionsUpdate implements Runnable {
}
private String formatInfoWindow(Faction fact) {
String v = "<div class=\"regionInfo\">" + infoWindow + "</div>";
v = v.replace("%regionName%", ChatColor.stripColor(fact.getName()));
v = v.replace("%description%", ChatColor.stripColor(fact.getDescription()));
String output = "<div class=\"regionInfo\">" + infoWindow + "</div>";
output = output.replace("%regionName%", ChatColor.stripColor(fact.getName()));
output = output.replace("%description%", ChatColor.stripColor(fact.getDescription() != null ? fact.getDescription() : ""));
MPlayer adm = fact.getLeader();
v = v.replace("%playerOwners%", (adm != null) ? adm.getName() : "");
output = output.replace("%playerOwners%", (adm != null) ? adm.getName() : "");
StringBuilder res = new StringBuilder();
for (MPlayer r : fact.getMPlayers()) {
if (!res.isEmpty()) {
@ -387,17 +389,18 @@ public class FactionsUpdate implements Runnable {
}
res.append(r.getName());
}
v = v.replace("%playerMembers%", res.toString());
output = output.replace("%playerMembers%", res.toString());
v = v.replace("%nation%", ChatColor.stripColor(fact.getName()));
// nation is an alias for regionName
output = output.replace("%nation%", ChatColor.stripColor(fact.getName()));
/* Build flags */
StringBuilder flags = new StringBuilder();
for (MFlag ff : MFlagColl.get().getAll()) {
flags.append("<br/>").append(ff.getName()).append(": ").append(fact.getFlag(ff));
v = v.replace("%flag." + ff.getName() + "%", fact.getFlag(ff) ? "true" : "false");
flags.append(ff.getName()).append(": ").append(fact.getFlag(ff)).append("<br/>");
output = output.replace("%flag." + ff.getName() + "%", fact.getFlag(ff) ? "true" : "false");
}
v = v.replace("%flags%", flags.toString());
return v;
output = output.replace("%flags%", flags.toString());
return output;
}
}

View File

@ -6,15 +6,15 @@ update:
layer:
name: "Factions"
# Make mobs layer hidden by default
# Make factions layer hidden by default
hideByDefault: false
# ordering priority in layer menu (low goes before high - default is 0)
# Ordering priority in layer menu (low goes before high - default is 0)
layerPriority: 2
# (optional) set minimum zoom level before layer is visible (0 = default, always visible)
minZoom: 0
# Format for popup - substitute values for macros
infoWindow: '<div class="infoWindow"><span style="font-size:120%;">%regionName%</span><br />Flags<br /><span style="font-weight:bold;">%flags%</span></div>'
infoWindow: '<div class="infoWindow"><span style="font-size:120%;">%regionName%</span><br/>Description: <span style="font-weight:bold;">%description%</span><br/>Leader: <span style="font-weight:bold;">%playerOwners%</span><br/>Members: <span style="font-weight:bold;">%playerMembers%</span><br />Flags<br /><span style="font-weight:bold;">%flags%</span></div>'
# Allow players in faction to see one another on dynmap (only relevant if dynmap has 'player-info-protected' enabled)
visibilityByFaction: true