11package com .plotsquared .plot2dynmap ;
22
33import com .plotsquared .core .PlotSquared ;
4+ import com .plotsquared .core .configuration .Settings ;
45import com .plotsquared .core .plot .Plot ;
56import com .plotsquared .core .plot .flag .PlotFlag ;
67import com .plotsquared .core .plot .world .PlotAreaManager ;
2021import org .dynmap .markers .MarkerAPI ;
2122import org .dynmap .markers .MarkerSet ;
2223
24+ import java .math .BigDecimal ;
25+ import java .math .RoundingMode ;
26+ import java .text .SimpleDateFormat ;
2327import java .util .HashMap ;
2428import java .util .Iterator ;
2529import java .util .Map ;
2630import java .util .Set ;
31+ import java .util .TimeZone ;
2732import java .util .UUID ;
2833
2934/**
@@ -34,8 +39,8 @@ public class Plot2DynmapPlugin extends JavaPlugin implements Listener, Runnable
3439
3540 private static final String DEF_INFO_ELEMENT = "%key% <span style=\" font-weight:bold;\" >%values%</span><br>" ;
3641 private static final String DEF_INFO_WINDOW =
37- "<div class=\" infowindow\" >" + "<span style=\" font-size:120%;\" >%id%</span><br>" + "%alias %" + "%owner%"
38- + "%members%" + "%trusted%" + "%denied%" + "%flags%" + "</div>" ;
42+ "<div class=\" infowindow\" >" + "<span style=\" font-size:120%;\" >%id%</span><br>" + "%creationdate %" +
43+ "%alias%" + "%owner%" + "% members%" + "%trusted%" + "%rating %" + "%denied%" + "%flags%" + "</div>" ;
3944
4045 private static MarkerSet markerSet ;
4146 private long updatePeriod ;
@@ -65,6 +70,8 @@ private String formatInfoWindow(final PlotWrapper plot) {
6570 this .infoElement .replace ("%values%" , StringEscapeUtils .escapeHtml (plot .flags ())).replace ("%key%" , "Flags" )
6671 );
6772 v = v .replace ("%owner%" , plot .owner ());
73+ v = v .replace ("%creationdate%" , this .infoElement .replace ("%values%" , plot .creationDate ()).replace ("%key%" ,"Creation Date" ));
74+ v = v .replace ("%rating%" , this .infoElement .replace ("%values%" , plot .rating ()).replace ("%key%" , "Rating" ));
6875 return v ;
6976 }
7077
@@ -231,8 +238,24 @@ public void run() {
231238 String flags = flagBuilder .toString ();
232239 flags = flags .isEmpty () ? "None" : flags ;
233240
241+ final long creationDate = Long .parseLong (String .valueOf (plot .getTimestamp ()));
242+ SimpleDateFormat sdf = new SimpleDateFormat (Settings .Timeformat .DATE_FORMAT );
243+ sdf .setTimeZone (TimeZone .getTimeZone (Settings .Timeformat .TIME_ZONE ));
244+ String newDate = sdf .format (creationDate );
245+
246+ final String rating ;
247+ if (Double .isNaN (plot .getAverageRating ())) {
248+ rating = "NaN" ;
249+ } else if (!Settings .General .SCIENTIFIC ) {
250+ BigDecimal roundRating = BigDecimal .valueOf (plot .getAverageRating ()).setScale (2 , RoundingMode .HALF_UP );
251+ rating = String .valueOf (roundRating );
252+ } else {
253+ rating = Double .toString (plot .getAverageRating ());
254+ }
255+
234256 final PlotWrapper plotWrapper =
235- new PlotWrapper (owner , helpers , trusted , denied , plot .getId (), alias , flags , plot .getArea ());
257+ new PlotWrapper (owner , helpers , trusted , denied , plot .getId (), alias , flags , plot .getArea (),
258+ newDate , rating );
236259 handlePlot (world , plotWrapper , newMap );
237260 }
238261 }
0 commit comments