This commit is contained in:
Juniormunk 2020-05-22 02:24:57 -04:00
parent 71a099beeb
commit 4fe6484db9
3 changed files with 1347 additions and 841 deletions

View File

@ -1,121 +1,222 @@
package com.massivecraft.factions.integration.dynmap; package com.massivecraft.factions.integration.dynmap;
import java.awt.Point;
import java.util.ArrayList;
import java.util.List;
import org.dynmap.markers.AreaMarker; import org.dynmap.markers.AreaMarker;
import org.dynmap.markers.MarkerSet; import org.dynmap.markers.MarkerSet;
import org.dynmap.markers.PolyLineMarker;
public class TempAreaMarker { import com.massivecraft.factions.FactionsPlugin;
/** public class TempAreaMarker
* @author FactionsUUID Team {
*/
// -------------------------------------------- // /**
// FIELDS * @author FactionsUUID Team
// -------------------------------------------- // */
public String label; // -------------------------------------------- //
public String world; // FIELDS
public double[] x; // -------------------------------------------- //
public double[] z;
public String description;
public int lineColor; public String label;
public double lineOpacity; public String world;
public int lineWeight; public double[] x;
public double[] z;
public int fillColor; private List<List<Point>> polyLine = new ArrayList<List<Point>>();
public double fillOpacity;
public boolean boost; public String description;
// -------------------------------------------- // public int lineColor;
// CREATE public double lineOpacity;
// -------------------------------------------- // public int lineWeight;
public static boolean equals(AreaMarker marker, double[] x, double[] z) { public int fillColor;
int length = marker.getCornerCount(); public double fillOpacity;
if (x.length != length) { public boolean boost;
return false;
}
if (z.length != length) {
return false;
}
for (int i = 0; i < length; i++) { // -------------------------------------------- //
if (marker.getCornerX(i) != x[i]) { // CREATE
return false; // -------------------------------------------- //
}
if (marker.getCornerZ(i) != z[i]) {
return false;
}
}
return true; public static boolean equals(AreaMarker marker, double[] x, double[] z)
} {
int length = marker.getCornerCount();
// -------------------------------------------- // if (x.length != length)
// UPDATE {
// -------------------------------------------- // return false;
}
if (z.length != length)
{
return false;
}
public AreaMarker create(MarkerSet markerset, String markerId) { for (int i = 0; i < length; i++)
AreaMarker ret = markerset.createAreaMarker(markerId, this.label, false, this.world, this.x, this.z, false // not persistent {
); if (marker.getCornerX(i) != x[i])
{
return false;
}
if (marker.getCornerZ(i) != z[i])
{
return false;
}
}
if (ret == null) { return true;
return null; }
}
// Description public void setPolyLine(List<List<Point>> points)
ret.setDescription(this.description); {
polyLine.clear();
polyLine.addAll(points);
}
// Line Style // -------------------------------------------- //
ret.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor); // UPDATE
// -------------------------------------------- //
// Fill Style public AreaMarker create(MarkerSet markerset, String markerId)
ret.setFillStyle(this.fillOpacity, this.fillColor); {
AreaMarker ret = markerset.createAreaMarker(markerId, this.label, false, this.world, this.x, this.z, false // not persistent
);
if (ret == null)
{
return null;
}
// Boost Flag int counter = 0;
ret.setBoostFlag(this.boost); for (List<Point> polyPoints : polyLine)
{
counter++;
double[] polyX = new double[polyPoints.size()];
double[] polyY = new double[polyPoints.size()];
double[] polyZ = new double[polyPoints.size()];
for (int i = 0; i < polyPoints.size(); i++)
{
Point p = polyPoints.get(i);
polyX[i] = p.getX();
polyY[i] = 64;
polyZ[i] = p.getY();
}
PolyLineMarker poly = markerset.createPolyLineMarker("poly_" + counter + "_" + markerId, "", false, this.world, polyX, polyY, polyZ, false);
// Poly Line Style
if (poly != null)
{
poly.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
}
else
FactionsPlugin.getInstance().getLogger().info("null");
return ret; }
}
// -------------------------------------------- // // Description
// UTIL ret.setDescription(this.description);
// -------------------------------------------- //
public void update(AreaMarker marker) { // Line Style
// Corner Locations ret.setLineStyle(0, 0, 0);
if (!equals(marker, this.x, this.z)) {
marker.setCornerLocations(this.x, this.z);
}
// Label // Fill Style
if (!marker.getLabel().equals(this.label)) { ret.setFillStyle(this.fillOpacity, this.fillColor);
marker.setLabel(this.label);
}
// Description // Boost Flag
if (!marker.getDescription().equals(this.description)) { ret.setBoostFlag(this.boost);
marker.setDescription(this.description);
}
// Line Style return ret;
if (marker.getLineWeight() != this.lineWeight || }
marker.getLineOpacity() != this.lineOpacity ||
marker.getLineColor() != this.lineColor) {
marker.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
}
// Fill Style // -------------------------------------------- //
if ((marker.getFillOpacity() != this.fillOpacity) || (marker.getFillColor() != this.fillColor)) { // UTIL
marker.setFillStyle(this.fillOpacity, this.fillColor); // -------------------------------------------- //
}
// Boost Flag public void update(AreaMarker marker)
if (marker.getBoostFlag() != this.boost) { {
marker.setBoostFlag(this.boost); // Corner Locations
} if (!equals(marker, this.x, this.z))
} {
marker.setCornerLocations(this.x, this.z);
}
// Label
if (!marker.getLabel().equals(this.label))
{
marker.setLabel(this.label);
}
if (!marker.getDescription().equals(this.description))
{
marker.setDescription(this.description);
}
// // Line Style
// if (marker.getLineWeight() != this.lineWeight || marker.getLineOpacity() != this.lineOpacity || marker.getLineColor() != this.lineColor)
// {
// marker.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
// }
MarkerSet markerset = marker.getMarkerSet();
int counter = 0;
String markerId = marker.getMarkerID();
for (List<Point> polyPoints : polyLine)
{
counter++;
PolyLineMarker exists = markerset.findPolyLineMarker("poly_" + counter + "_" + markerId);
if (exists != null)
{
double[] polyX = new double[polyPoints.size()];
double[] polyY = new double[polyPoints.size()];
double[] polyZ = new double[polyPoints.size()];
for (int i = 0; i < polyPoints.size(); i++)
{
Point p = polyPoints.get(i);
polyX[i] = p.getX();
polyY[i] = 64;
polyZ[i] = p.getY();
}
exists.setCornerLocations(polyX, polyY, polyZ);
exists.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
// exists.deleteMarker();
}
else
{
double[] polyX = new double[polyPoints.size()];
double[] polyY = new double[polyPoints.size()];
double[] polyZ = new double[polyPoints.size()];
for (int i = 0; i < polyPoints.size(); i++)
{
Point p = polyPoints.get(i);
polyX[i] = p.getX();
polyY[i] = 64;
polyZ[i] = p.getY();
}
PolyLineMarker poly = markerset.createPolyLineMarker("poly_" + counter + "_" + markerId, "", false, this.world, polyX, polyY, polyZ, false);
// Poly Line Style
if (poly != null)
{
poly.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
}
else
FactionsPlugin.getInstance().getLogger().info("null");
}
}
// Fill Style
if ((marker.getFillOpacity() != this.fillOpacity) || (marker.getFillColor() != this.fillColor))
{
marker.setFillStyle(this.fillOpacity, this.fillColor);
}
// Boost Flag
if (marker.getBoostFlag() != this.boost)
{
marker.setBoostFlag(this.boost);
}
}
} }

View File

@ -0,0 +1,62 @@
package com.massivecraft.factions.integration.dynmap;
import java.awt.Point;
import java.util.ArrayList;
import java.util.List;
public class TempLine
{
private Point p1;
private Point p2;
private List<TempLine> connectedLines = new ArrayList<TempLine>();
TempLine(Point p1, Point p2)
{
this.p1 = p1;
this.p2 = p2;
}
public Point getP1()
{
return p1;
}
public Point getP2()
{
return p2;
}
public void addAdditionLines(List<TempLine> connectedLines)
{
this.connectedLines = connectedLines;
}
public List<TempLine> getConnectedLines()
{
return connectedLines;
}
@Override
public boolean equals(Object o)
{
TempLine line = (TempLine) o;
if (line.p1.x == this.p1.x && line.p2.x == this.p2.x && line.p1.y == this.p1.y && line.p2.y == this.p2.y)
{
return true;
}
if (line.p1.x == this.p2.x && line.p2.x == this.p1.x && line.p1.y == this.p2.y && line.p2.y == this.p1.y)
{
return true;
}
return false;
}
@Override
public int hashCode()
{
String test = "" + (p1.x + p2.x);
test += " " + (p1.y + p2.y);
return test.hashCode();
}
}