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,9 +1,17 @@
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.MarkerSet;
import org.dynmap.markers.PolyLineMarker;
public class TempAreaMarker {
import com.massivecraft.factions.FactionsPlugin;
public class TempAreaMarker
{
/**
* @author FactionsUUID Team
@ -17,6 +25,9 @@ public class TempAreaMarker {
public String world;
public double[] x;
public double[] z;
private List<List<Point>> polyLine = new ArrayList<List<Point>>();
public String description;
public int lineColor;
@ -32,21 +43,27 @@ public class TempAreaMarker {
// CREATE
// -------------------------------------------- //
public static boolean equals(AreaMarker marker, double[] x, double[] z) {
public static boolean equals(AreaMarker marker, double[] x, double[] z)
{
int length = marker.getCornerCount();
if (x.length != length) {
if (x.length != length)
{
return false;
}
if (z.length != length) {
if (z.length != length)
{
return false;
}
for (int i = 0; i < length; i++) {
if (marker.getCornerX(i) != x[i]) {
for (int i = 0; i < length; i++)
{
if (marker.getCornerX(i) != x[i])
{
return false;
}
if (marker.getCornerZ(i) != z[i]) {
if (marker.getCornerZ(i) != z[i])
{
return false;
}
}
@ -54,23 +71,55 @@ public class TempAreaMarker {
return true;
}
public void setPolyLine(List<List<Point>> points)
{
polyLine.clear();
polyLine.addAll(points);
}
// -------------------------------------------- //
// UPDATE
// -------------------------------------------- //
public AreaMarker create(MarkerSet markerset, String markerId) {
public AreaMarker create(MarkerSet markerset, String markerId)
{
AreaMarker ret = markerset.createAreaMarker(markerId, this.label, false, this.world, this.x, this.z, false // not persistent
);
if (ret == null) {
if (ret == null)
{
return null;
}
int counter = 0;
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");
}
// Description
ret.setDescription(this.description);
// Line Style
ret.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
ret.setLineStyle(0, 0, 0);
// Fill Style
ret.setFillStyle(this.fillOpacity, this.fillColor);
@ -85,35 +134,87 @@ public class TempAreaMarker {
// UTIL
// -------------------------------------------- //
public void update(AreaMarker marker) {
public void update(AreaMarker marker)
{
// Corner Locations
if (!equals(marker, this.x, this.z)) {
if (!equals(marker, this.x, this.z))
{
marker.setCornerLocations(this.x, this.z);
}
// Label
if (!marker.getLabel().equals(this.label)) {
if (!marker.getLabel().equals(this.label))
{
marker.setLabel(this.label);
}
// Description
if (!marker.getDescription().equals(this.description)) {
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);
// // 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)) {
if ((marker.getFillOpacity() != this.fillOpacity) || (marker.getFillColor() != this.fillColor))
{
marker.setFillStyle(this.fillOpacity, this.fillColor);
}
// Boost Flag
if (marker.getBoostFlag() != this.boost) {
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();
}
}