F map autoupdate during flying fixed.

This commit is contained in:
ProSavage
2018-07-12 11:11:07 -05:00
parent 2426142664
commit 143daad9e6
74 changed files with 3460 additions and 3659 deletions

View File

@@ -23,6 +23,7 @@ import java.util.logging.Level;
public class Econ {
private static final DecimalFormat format = new DecimalFormat(TL.ECON_FORMAT.toString());
private static Economy econ = null;
public static void setup() {
@@ -61,7 +62,6 @@ public class Econ {
return econ != null;
}
public static void modifyUniverseMoney(double delta) {
if (!shouldBeUsed()) {
return;
@@ -369,16 +369,16 @@ public class Econ {
return amount;
}
// calculate refund amount for all owned land
public static double calculateTotalLandRefund(int ownedLand) {
return calculateTotalLandValue(ownedLand) * Conf.econClaimRefundMultiplier;
}
// -------------------------------------------- //
// Standard account management methods
// -------------------------------------------- //
// calculate refund amount for all owned land
public static double calculateTotalLandRefund(int ownedLand) {
return calculateTotalLandValue(ownedLand) * Conf.econClaimRefundMultiplier;
}
public static boolean hasAccount(String name) {
return econ.hasAccount(name);
}
@@ -387,8 +387,6 @@ public class Econ {
return econ.getBalance(account);
}
private static final DecimalFormat format = new DecimalFormat(TL.ECON_FORMAT.toString());
public static String getFriendlyBalance(UUID uuid) {
OfflinePlayer offline = Bukkit.getOfflinePlayer(uuid);
if (offline.getName() == null) {

View File

@@ -8,89 +8,16 @@ public class DynmapStyle {
// -------------------------------------------- //
public String lineColor = null;
public int getLineColor() {
return getColor(coalesce(this.lineColor, Conf.dynmapDefaultStyle.lineColor, Conf.DYNMAP_STYLE_LINE_COLOR));
}
public DynmapStyle setStrokeColor(String strokeColor) {
this.lineColor = strokeColor;
return this;
}
public Double lineOpacity = null;
public double getLineOpacity() {
return coalesce(this.lineOpacity, Conf.dynmapDefaultStyle.lineOpacity, Conf.DYNMAP_STYLE_LINE_OPACITY);
}
public DynmapStyle setLineOpacity(Double strokeOpacity) {
this.lineOpacity = strokeOpacity;
return this;
}
public Integer lineWeight = null;
public int getLineWeight() {
return coalesce(this.lineWeight, Conf.dynmapDefaultStyle.lineWeight, Conf.DYNMAP_STYLE_LINE_WEIGHT);
}
public DynmapStyle setLineWeight(Integer strokeWeight) {
this.lineWeight = strokeWeight;
return this;
}
public String fillColor = null;
public int getFillColor() {
return getColor(coalesce(this.fillColor, Conf.dynmapDefaultStyle.fillColor, Conf.DYNMAP_STYLE_FILL_COLOR));
}
public DynmapStyle setFillColor(String fillColor) {
this.fillColor = fillColor;
return this;
}
public Double fillOpacity = null;
public double getFillOpacity() {
return coalesce(this.fillOpacity, Conf.dynmapDefaultStyle.fillOpacity, Conf.DYNMAP_STYLE_FILL_OPACITY);
}
public DynmapStyle setFillOpacity(Double fillOpacity) {
this.fillOpacity = fillOpacity;
return this;
}
// NOTE: We just return the string here. We do not return the resolved Dynmap MarkerIcon object.
// The reason is we use this class in the MConf. For serialization to work Dynmap would have to be loaded and we can't require that.
// Using dynmap is optional.
public String homeMarker = null;
public String getHomeMarker() {
return coalesce(this.homeMarker, Conf.dynmapDefaultStyle.homeMarker, Conf.DYNMAP_STYLE_HOME_MARKER);
}
public DynmapStyle setHomeMarker(String homeMarker) {
this.homeMarker = homeMarker;
return this;
}
public Boolean boost = null;
public boolean getBoost() {
return coalesce(this.boost, Conf.dynmapDefaultStyle.boost, Conf.DYNMAP_STYLE_BOOST);
}
public DynmapStyle setBoost(Boolean boost) {
this.boost = boost;
return this;
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
@SafeVarargs
public static <T> T coalesce(T... items) {
for (T item : items) {
@@ -110,4 +37,71 @@ public class DynmapStyle {
return ret;
}
public int getLineColor() {
return getColor(coalesce(this.lineColor, Conf.dynmapDefaultStyle.lineColor, Conf.DYNMAP_STYLE_LINE_COLOR));
}
public DynmapStyle setStrokeColor(String strokeColor) {
this.lineColor = strokeColor;
return this;
}
public double getLineOpacity() {
return coalesce(this.lineOpacity, Conf.dynmapDefaultStyle.lineOpacity, Conf.DYNMAP_STYLE_LINE_OPACITY);
}
public DynmapStyle setLineOpacity(Double strokeOpacity) {
this.lineOpacity = strokeOpacity;
return this;
}
public int getLineWeight() {
return coalesce(this.lineWeight, Conf.dynmapDefaultStyle.lineWeight, Conf.DYNMAP_STYLE_LINE_WEIGHT);
}
public DynmapStyle setLineWeight(Integer strokeWeight) {
this.lineWeight = strokeWeight;
return this;
}
public int getFillColor() {
return getColor(coalesce(this.fillColor, Conf.dynmapDefaultStyle.fillColor, Conf.DYNMAP_STYLE_FILL_COLOR));
}
public DynmapStyle setFillColor(String fillColor) {
this.fillColor = fillColor;
return this;
}
public double getFillOpacity() {
return coalesce(this.fillOpacity, Conf.dynmapDefaultStyle.fillOpacity, Conf.DYNMAP_STYLE_FILL_OPACITY);
}
public DynmapStyle setFillOpacity(Double fillOpacity) {
this.fillOpacity = fillOpacity;
return this;
}
public String getHomeMarker() {
return coalesce(this.homeMarker, Conf.dynmapDefaultStyle.homeMarker, Conf.DYNMAP_STYLE_HOME_MARKER);
}
public DynmapStyle setHomeMarker(String homeMarker) {
this.homeMarker = homeMarker;
return this;
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
public boolean getBoost() {
return coalesce(this.boost, Conf.dynmapDefaultStyle.boost, Conf.DYNMAP_STYLE_BOOST);
}
public DynmapStyle setBoost(Boolean boost) {
this.boost = boost;
return this;
}
}

View File

@@ -41,17 +41,64 @@ public class EngineDynmap {
// -------------------------------------------- //
private static EngineDynmap i = new EngineDynmap();
public DynmapAPI dynmapApi;
public MarkerAPI markerApi;
public MarkerSet markerset;
private EngineDynmap() {
}
public static EngineDynmap getInstance() {
return i;
}
private EngineDynmap() {
public static String getHtmlPlayerString(Collection<FPlayer> playersOfficersList) {
StringBuilder ret = new StringBuilder();
for (FPlayer fplayer : playersOfficersList) {
if (ret.length() > 0) {
ret.append(", ");
}
ret.append(getHtmlPlayerName(fplayer));
}
return ret.toString();
}
public DynmapAPI dynmapApi;
public MarkerAPI markerApi;
public MarkerSet markerset;
public static String getHtmlPlayerName(FPlayer fplayer) {
if (fplayer == null) {
return "none";
}
return escapeHtml(fplayer.getName());
}
public static String escapeHtml(String string) {
StringBuilder out = new StringBuilder(Math.max(16, string.length()));
for (int i = 0; i < string.length(); i++) {
char c = string.charAt(i);
if (c > 127 || c == '"' || c == '<' || c == '>' || c == '&') {
out.append("&#");
out.append((int) c);
out.append(';');
} else {
out.append(c);
}
}
return out.toString();
}
// Thread Safe / Asynchronous: Yes
public static void info(String msg) {
String message = DYNMAP_INTEGRATION + msg;
System.out.println(message);
}
// -------------------------------------------- //
// UPDATE: HOMES
// -------------------------------------------- //
// Thread Safe / Asynchronous: Yes
public static void severe(String msg) {
String message = DYNMAP_INTEGRATION + ChatColor.RED.toString() + msg;
System.out.println(message);
}
public void init() {
Plugin dynmap = Bukkit.getServer().getPluginManager().getPlugin("dynmap");
@@ -94,6 +141,10 @@ public class EngineDynmap {
}, 100L, 100L);
}
// -------------------------------------------- //
// UPDATE: AREAS
// -------------------------------------------- //
// Thread Safe / Asynchronous: No
public boolean updateCore() {
// Get DynmapAPI
@@ -138,10 +189,6 @@ public class EngineDynmap {
return true;
}
// -------------------------------------------- //
// UPDATE: HOMES
// -------------------------------------------- //
// Thread Safe / Asynchronous: Yes
public Map<String, TempMarker> createHomes() {
Map<String, TempMarker> ret = new HashMap<>();
@@ -208,7 +255,7 @@ public class EngineDynmap {
}
// -------------------------------------------- //
// UPDATE: AREAS
// UPDATE: PLAYERSET
// -------------------------------------------- //
// Thread Safe: YES
@@ -449,6 +496,10 @@ public class EngineDynmap {
return ret;
}
// -------------------------------------------- //
// UTIL & SHARED
// -------------------------------------------- //
// Thread Safe: NO
public void updateAreas(Map<String, TempAreaMarker> areas) {
// Map Current
@@ -482,10 +533,6 @@ public class EngineDynmap {
}
}
// -------------------------------------------- //
// UPDATE: PLAYERSET
// -------------------------------------------- //
// Thread Safe / Asynchronous: Yes
public String createPlayersetId(Faction faction) {
if (faction == null) {
@@ -589,10 +636,6 @@ public class EngineDynmap {
}
}
// -------------------------------------------- //
// UTIL & SHARED
// -------------------------------------------- //
// Thread Safe / Asynchronous: Yes
private String getDescription(Faction faction) {
String ret = "<div class=\"regioninfo\">" + Conf.dynmapDescription + "</div>";
@@ -653,39 +696,6 @@ public class EngineDynmap {
return ret;
}
public static String getHtmlPlayerString(Collection<FPlayer> playersOfficersList) {
StringBuilder ret = new StringBuilder();
for (FPlayer fplayer : playersOfficersList) {
if (ret.length() > 0) {
ret.append(", ");
}
ret.append(getHtmlPlayerName(fplayer));
}
return ret.toString();
}
public static String getHtmlPlayerName(FPlayer fplayer) {
if (fplayer == null) {
return "none";
}
return escapeHtml(fplayer.getName());
}
public static String escapeHtml(String string) {
StringBuilder out = new StringBuilder(Math.max(16, string.length()));
for (int i = 0; i < string.length(); i++) {
char c = string.charAt(i);
if (c > 127 || c == '"' || c == '<' || c == '>' || c == '&') {
out.append("&#");
out.append((int) c);
out.append(';');
} else {
out.append(c);
}
}
return out.toString();
}
// Thread Safe / Asynchronous: Yes
private boolean isVisible(Faction faction, String world) {
if (faction == null) {
@@ -727,22 +737,6 @@ public class EngineDynmap {
return Conf.dynmapDefaultStyle;
}
// Thread Safe / Asynchronous: Yes
public static void info(String msg) {
String message = DYNMAP_INTEGRATION + msg;
System.out.println(message);
}
// Thread Safe / Asynchronous: Yes
public static void severe(String msg) {
String message = DYNMAP_INTEGRATION + ChatColor.RED.toString() + msg;
System.out.println(message);
}
enum Direction {
XPLUS, ZPLUS, XMINUS, ZMINUS
}
// Find all contiguous blocks, set in target and clear in source
private int floodFillTarget(TileFlags source, TileFlags destination, int x, int y) {
int cnt = 0;
@@ -773,4 +767,8 @@ public class EngineDynmap {
}
return cnt;
}
enum Direction {
XPLUS, ZPLUS, XMINUS, ZMINUS
}
}

View File

@@ -27,6 +27,32 @@ public class TempAreaMarker {
// CREATE
// -------------------------------------------- //
public static boolean equals(AreaMarker marker, double x[], double z[]) {
int length = marker.getCornerCount();
if (x.length != length) {
return false;
}
if (z.length != length) {
return false;
}
for (int i = 0; i < length; i++) {
if (marker.getCornerX(i) != x[i]) {
return false;
}
if (marker.getCornerZ(i) != z[i]) {
return false;
}
}
return true;
}
// -------------------------------------------- //
// UPDATE
// -------------------------------------------- //
public AreaMarker create(MarkerSet markerset, String markerId) {
AreaMarker ret = markerset.createAreaMarker(markerId, this.label, false, this.world, this.x, this.z, false // not persistent
);
@@ -51,7 +77,7 @@ public class TempAreaMarker {
}
// -------------------------------------------- //
// UPDATE
// UTIL
// -------------------------------------------- //
public void update(AreaMarker marker) {
@@ -87,30 +113,4 @@ public class TempAreaMarker {
}
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
public static boolean equals(AreaMarker marker, double x[], double z[]) {
int length = marker.getCornerCount();
if (x.length != length) {
return false;
}
if (z.length != length) {
return false;
}
for (int i = 0; i < length; i++) {
if (marker.getCornerX(i) != x[i]) {
return false;
}
if (marker.getCornerZ(i) != z[i]) {
return false;
}
}
return true;
}
}

View File

@@ -23,6 +23,18 @@ public class TempMarker {
// CREATE
// -------------------------------------------- //
public static MarkerIcon getMarkerIcon(MarkerAPI markerApi, String name) {
MarkerIcon ret = markerApi.getMarkerIcon(name);
if (ret == null) {
ret = markerApi.getMarkerIcon(Conf.DYNMAP_STYLE_HOME_MARKER);
}
return ret;
}
// -------------------------------------------- //
// UPDATE
// -------------------------------------------- //
public Marker create(MarkerAPI markerApi, MarkerSet markerset, String markerId) {
Marker ret = markerset.createMarker(markerId, this.label, this.world, this.x, this.y, this.z, getMarkerIcon(markerApi, this.iconName), false // not persistent
);
@@ -37,7 +49,7 @@ public class TempMarker {
}
// -------------------------------------------- //
// UPDATE
// UTIL
// -------------------------------------------- //
public void update(MarkerAPI markerApi, Marker marker) {
@@ -59,16 +71,4 @@ public class TempMarker {
}
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
public static MarkerIcon getMarkerIcon(MarkerAPI markerApi, String name) {
MarkerIcon ret = markerApi.getMarkerIcon(name);
if (ret == null) {
ret = markerApi.getMarkerIcon(Conf.DYNMAP_STYLE_HOME_MARKER);
}
return ret;
}
}