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;
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;
/**
* @author FactionsUUID Team
*/
public class TempAreaMarker
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
/**
* @author FactionsUUID Team
*/
public String label;
public String world;
public double[] x;
public double[] z;
public String description;
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
public int lineColor;
public double lineOpacity;
public int lineWeight;
public String label;
public String world;
public double[] x;
public double[] z;
public int fillColor;
public double fillOpacity;
private List<List<Point>> polyLine = new ArrayList<List<Point>>();
public boolean boost;
public String description;
// -------------------------------------------- //
// CREATE
// -------------------------------------------- //
public int lineColor;
public double lineOpacity;
public int lineWeight;
public static boolean equals(AreaMarker marker, double[] x, double[] z) {
int length = marker.getCornerCount();
public int fillColor;
public double fillOpacity;
if (x.length != length) {
return false;
}
if (z.length != length) {
return false;
}
public boolean boost;
for (int i = 0; i < length; i++) {
if (marker.getCornerX(i) != x[i]) {
return false;
}
if (marker.getCornerZ(i) != z[i]) {
return false;
}
}
// -------------------------------------------- //
// CREATE
// -------------------------------------------- //
return true;
}
public static boolean equals(AreaMarker marker, double[] x, double[] z)
{
int length = marker.getCornerCount();
// -------------------------------------------- //
// UPDATE
// -------------------------------------------- //
if (x.length != length)
{
return false;
}
if (z.length != length)
{
return false;
}
public AreaMarker create(MarkerSet markerset, String markerId) {
AreaMarker ret = markerset.createAreaMarker(markerId, this.label, false, this.world, this.x, this.z, false // not persistent
);
for (int i = 0; i < length; i++)
{
if (marker.getCornerX(i) != x[i])
{
return false;
}
if (marker.getCornerZ(i) != z[i])
{
return false;
}
}
if (ret == null) {
return null;
}
return true;
}
// Description
ret.setDescription(this.description);
public void setPolyLine(List<List<Point>> points)
{
polyLine.clear();
polyLine.addAll(points);
}
// Line Style
ret.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
// -------------------------------------------- //
// UPDATE
// -------------------------------------------- //
// Fill Style
ret.setFillStyle(this.fillOpacity, this.fillColor);
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)
{
return null;
}
// Boost Flag
ret.setBoostFlag(this.boost);
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");
return ret;
}
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
// Description
ret.setDescription(this.description);
public void update(AreaMarker marker) {
// Corner Locations
if (!equals(marker, this.x, this.z)) {
marker.setCornerLocations(this.x, this.z);
}
// Line Style
ret.setLineStyle(0, 0, 0);
// Label
if (!marker.getLabel().equals(this.label)) {
marker.setLabel(this.label);
}
// Fill Style
ret.setFillStyle(this.fillOpacity, this.fillColor);
// Description
if (!marker.getDescription().equals(this.description)) {
marker.setDescription(this.description);
}
// Boost Flag
ret.setBoostFlag(this.boost);
// Line Style
if (marker.getLineWeight() != this.lineWeight ||
marker.getLineOpacity() != this.lineOpacity ||
marker.getLineColor() != this.lineColor) {
marker.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
}
return ret;
}
// 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);
}
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
public void update(AreaMarker marker)
{
// 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();
}
}