Initial. perhaps broken update attempt

This commit is contained in:
Kristian Knarvik 2024-05-14 02:17:29 +02:00
parent 6fb1174adf
commit ef3cf02a23
16 changed files with 673 additions and 610 deletions

2
.gitignore vendored
View File

@ -23,3 +23,5 @@
# Mac filesystem dust
/.DS_Store
*.iml

Binary file not shown.

Binary file not shown.

51
pom.xml
View File

@ -1,8 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.dynmap</groupId>
<artifactId>Dynmap-Factions</artifactId>
<version>0.91</version>
<version>0.92</version>
<properties>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyyMMddHHmm</maven.build.timestamp.format>
@ -34,57 +35,49 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<version>3.8.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>16</source>
<target>16</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<releases>
</releases>
<snapshots>
</snapshots>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/repositories/releases/</url>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<releases>
</releases>
<snapshots>
</snapshots>
<id>dynmap-repo</id>
<url>http://repo.mikeprimm.com/</url>
<id>dynmap</id>
<url>https://repo.mikeprimm.com/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.dynmap</groupId>
<groupId>us.dynmap</groupId>
<artifactId>dynmap-api</artifactId>
<version>1.9</version>
<version>3.6-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.7.10-R0.1-SNAPSHOT</version>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.6-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.massivecraft</groupId>
<artifactId>Factions</artifactId>
<version>2.7.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/Factions-2.7.1.jar</systemPath>
<version>3.3.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.massivecraft</groupId>
<groupId>com.massivecraft.massivecore</groupId>
<artifactId>MassiveCore</artifactId>
<version>2.7.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/MassiveCore-2.7.1.jar</systemPath>
<version>3.3.3</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,16 +0,0 @@
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>bin</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>zip</format>
</formats>
<fileSets>
</fileSets>
<files>
<file>
<source>${project.build.directory}/${artifactId}-${version}.jar</source>
<outputDirectory>/</outputDirectory>
<destName>${artifactId}.jar</destName>
</file>
</files>
</assembly>

View File

@ -0,0 +1,51 @@
package org.dynmap.factions;
import org.bukkit.configuration.file.FileConfiguration;
import org.dynmap.markers.MarkerIcon;
class AreaStyle {
final String strokecolor;
final double strokeopacity;
final int strokeweight;
final String fillcolor;
final double fillopacity;
final String homemarker;
MarkerIcon homeicon;
final boolean boost;
AreaStyle(DynmapFactionsPlugin dynmapFactionsPlugin, FileConfiguration cfg, String path, AreaStyle def) {
strokecolor = cfg.getString(path + ".strokeColor", def.strokecolor);
strokeopacity = cfg.getDouble(path + ".strokeOpacity", def.strokeopacity);
strokeweight = cfg.getInt(path + ".strokeWeight", def.strokeweight);
fillcolor = cfg.getString(path + ".fillColor", def.fillcolor);
fillopacity = cfg.getDouble(path + ".fillOpacity", def.fillopacity);
homemarker = cfg.getString(path + ".homeicon", def.homemarker);
if (homemarker != null) {
homeicon = dynmapFactionsPlugin.markerapi.getMarkerIcon(homemarker);
if (homeicon == null) {
DynmapFactionsPlugin.severe("Invalid homeicon: " + homemarker);
homeicon = dynmapFactionsPlugin.markerapi.getMarkerIcon("blueicon");
}
}
boost = cfg.getBoolean(path + ".boost", def.boost);
}
AreaStyle(DynmapFactionsPlugin dynmapFactionsPlugin, FileConfiguration cfg, String path) {
strokecolor = cfg.getString(path + ".strokeColor", "#FF0000");
strokeopacity = cfg.getDouble(path + ".strokeOpacity", 0.8);
strokeweight = cfg.getInt(path + ".strokeWeight", 3);
fillcolor = cfg.getString(path + ".fillColor", "#FF0000");
fillopacity = cfg.getDouble(path + ".fillOpacity", 0.35);
homemarker = cfg.getString(path + ".homeicon", null);
if (homemarker != null) {
homeicon = dynmapFactionsPlugin.markerapi.getMarkerIcon(homemarker);
if (homeicon == null) {
DynmapFactionsPlugin.severe("Invalid homeicon: " + homemarker);
homeicon = dynmapFactionsPlugin.markerapi.getMarkerIcon("blueicon");
}
}
boost = cfg.getBoolean(path + ".boost", false);
}
}

View File

@ -0,0 +1,10 @@
package org.dynmap.factions;
public enum Direction {
XPLUS,
ZPLUS,
XMINUS,
ZMINUS
}

View File

@ -1,5 +1,29 @@
package org.dynmap.factions;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.MFlag;
import com.massivecraft.factions.entity.MFlagColl;
import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.Warp;
import com.massivecraft.massivecore.ps.PS;
import com.massivecraft.massivecore.store.EntityInternalMap;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.dynmap.DynmapAPI;
import org.dynmap.markers.AreaMarker;
import org.dynmap.markers.Marker;
import org.dynmap.markers.MarkerAPI;
import org.dynmap.markers.MarkerIcon;
import org.dynmap.markers.MarkerSet;
import org.dynmap.markers.PlayerSet;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
@ -13,40 +37,8 @@ import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.dynmap.DynmapAPI;
import org.dynmap.markers.AreaMarker;
import org.dynmap.markers.Marker;
import org.dynmap.markers.MarkerAPI;
import org.dynmap.markers.MarkerIcon;
import org.dynmap.markers.MarkerSet;
import org.dynmap.markers.PlayerSet;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.MFlag;
import com.massivecraft.factions.entity.MFlagColl;
import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.event.EventFactionsChunksChange;
import com.massivecraft.factions.event.EventFactionsCreate;
import com.massivecraft.factions.event.EventFactionsDisband;
import com.massivecraft.factions.event.EventFactionsHomeChange;
import com.massivecraft.factions.event.EventFactionsMembershipChange;
import com.massivecraft.factions.event.EventFactionsNameChange;
import com.massivecraft.massivecore.ps.PS;
public class DynmapFactionsPlugin extends JavaPlugin {
private static Logger log;
private static final String DEF_INFOWINDOW = "<div class=\"infowindow\"><span style=\"font-size:120%;\">%regionname%</span><br />Flags<br /><span style=\"font-weight:bold;\">%flags%</span></div>";
Plugin dynmap;
@ -58,7 +50,6 @@ public class DynmapFactionsPlugin extends JavaPlugin {
int blocksize;
FileConfiguration cfg;
MarkerSet set;
long updperiod;
boolean use3d;
@ -68,179 +59,103 @@ public class DynmapFactionsPlugin extends JavaPlugin {
Set<String> visible;
Set<String> hidden;
boolean stop;
static DynmapFactionsPlugin instance;
@Override
public void onLoad() {
log = this.getLogger();
}
private class AreaStyle {
String strokecolor;
double strokeopacity;
int strokeweight;
String fillcolor;
double fillopacity;
String homemarker;
MarkerIcon homeicon;
boolean boost;
AreaStyle(FileConfiguration cfg, String path, AreaStyle def) {
strokecolor = cfg.getString(path+".strokeColor", def.strokecolor);
strokeopacity = cfg.getDouble(path+".strokeOpacity", def.strokeopacity);
strokeweight = cfg.getInt(path+".strokeWeight", def.strokeweight);
fillcolor = cfg.getString(path+".fillColor", def.fillcolor);
fillopacity = cfg.getDouble(path+".fillOpacity", def.fillopacity);
homemarker = cfg.getString(path+".homeicon", def.homemarker);
if(homemarker != null) {
homeicon = markerapi.getMarkerIcon(homemarker);
if(homeicon == null) {
severe("Invalid homeicon: " + homemarker);
homeicon = markerapi.getMarkerIcon("blueicon");
}
}
boost = cfg.getBoolean(path+".boost", def.boost);
}
AreaStyle(FileConfiguration cfg, String path) {
strokecolor = cfg.getString(path+".strokeColor", "#FF0000");
strokeopacity = cfg.getDouble(path+".strokeOpacity", 0.8);
strokeweight = cfg.getInt(path+".strokeWeight", 3);
fillcolor = cfg.getString(path+".fillColor", "#FF0000");
fillopacity = cfg.getDouble(path+".fillOpacity", 0.35);
homemarker = cfg.getString(path+".homeicon", null);
if(homemarker != null) {
homeicon = markerapi.getMarkerIcon(homemarker);
if(homeicon == null) {
severe("Invalid homeicon: " + homemarker);
homeicon = markerapi.getMarkerIcon("blueicon");
}
}
boost = cfg.getBoolean(path+".boost", false);
}
}
public static void info(String msg) {
log.log(Level.INFO, msg);
}
public static void severe(String msg) {
log.log(Level.SEVERE, msg);
}
private class FactionsUpdate implements Runnable {
public boolean runonce;
public void run() {
if(!stop) {
updateFactions();
if(!runonce) {
getServer().getScheduler().scheduleSyncDelayedTask(DynmapFactionsPlugin.this, this, updperiod);
}
else if(pending == this) {
pending = null;
}
}
void requestUpdatePlayerSet(String factid) {
if (playersets) {
getServer().getScheduler().scheduleSyncDelayedTask(this, new PlayerSetUpdate(this, factid));
}
}
private class PlayerSetUpdate implements Runnable {
public String faction;
public PlayerSetUpdate(String fid) {
faction = fid;
}
public void run() {
if(!stop)
updatePlayerSet(faction);
}
}
FactionsUpdate pending = null;
private void requestUpdatePlayerSet(String factid) {
if(playersets)
getServer().getScheduler().scheduleSyncDelayedTask(this, new PlayerSetUpdate(factid));
}
private FactionsUpdate pending = null;
private void requestUpdateFactions() {
if(pending == null) {
FactionsUpdate upd = new FactionsUpdate();
upd.runonce = true;
pending = upd;
getServer().getScheduler().scheduleSyncDelayedTask(this, upd, 20);
}
}
private void updatePlayerSet(String factid) {
void updatePlayerSet(String factid) {
/* If Wilderness or other unassociated factions (guid-style ID), skip */
if(factid.indexOf('-') >= 0) {
if (factid.indexOf('-') >= 0) {
return;
}
Set<String> plids = new HashSet<String>();
Set<String> plids = new HashSet<>();
FactionColl fc = FactionColl.get();
Faction f = fc.getByName(factid); /* Get faction */
if(f != null) {
if (f != null) {
List<MPlayer> ps = f.getMPlayers();
for(MPlayer fp : ps) {
for (MPlayer fp : ps) {
plids.add(fp.getId());
}
factid = f.getId();
}
String setid = "factions." + factid;
PlayerSet set = markerapi.getPlayerSet(setid); /* See if set exists */
if((set == null) && (f != null)) {
if ((set == null) && (f != null)) {
set = markerapi.createPlayerSet(setid, true, plids, false);
info("Added player visibility set '" + setid + "' for faction " + factid);
}
else if(f != null) {
if (f != null) {
set.setPlayers(plids);
}
else {
} else if (set != null) {
set.deleteSet();
}
}
private Map<String, AreaMarker> resareas = new HashMap<String, AreaMarker>();
private Map<String, Marker> resmark = new HashMap<String, Marker>();
private Map<String, AreaMarker> resareas = new HashMap<>();
private Map<String, Marker> resmark = new HashMap<>();
private String formatInfoWindow(Faction fact) {
String v = "<div class=\"regioninfo\">"+infowindow+"</div>";
String v = "<div class=\"regioninfo\">" + infowindow + "</div>";
v = v.replace("%regionname%", ChatColor.stripColor(fact.getName()));
v = v.replace("%description%", ChatColor.stripColor(fact.getDescription()));
MPlayer adm = fact.getLeader();
v = v.replace("%playerowners%", (adm!=null)?adm.getName():"");
String res = "";
for(MPlayer r : fact.getMPlayers()) {
if(res.length()>0) res += ", ";
res += r.getName();
v = v.replace("%playerowners%", (adm != null) ? adm.getName() : "");
StringBuilder res = new StringBuilder();
for (MPlayer r : fact.getMPlayers()) {
if (!res.isEmpty()) {
res.append(", ");
}
v = v.replace("%playermembers%", res);
res.append(r.getName());
}
v = v.replace("%playermembers%", res.toString());
v = v.replace("%nation%", ChatColor.stripColor(fact.getName()));
/* Build flags */
String flgs = "";
for(MFlag ff : MFlagColl.get().getAll()) {
flgs += "<br/>" + ff.getName() + ": " + fact.getFlag(ff);
v = v.replace("%flag." + ff.getName() + "%", fact.getFlag(ff)?"true":"false");
StringBuilder flgs = new StringBuilder();
for (MFlag ff : MFlagColl.get().getAll()) {
flgs.append("<br/>").append(ff.getName()).append(": ").append(fact.getFlag(ff));
v = v.replace("%flag." + ff.getName() + "%", fact.getFlag(ff) ? "true" : "false");
}
v = v.replace("%flags%", flgs);
v = v.replace("%flags%", flgs.toString());
return v;
}
private boolean isVisible(String id, String worldname) {
if((visible != null) && (visible.size() > 0)) {
if((visible.contains(id) == false) && (visible.contains("world:" + worldname) == false)) {
if ((visible != null) && (!visible.isEmpty())) {
if ((!visible.contains(id)) && (!visible.contains("world:" + worldname))) {
return false;
}
}
if((hidden != null) && (hidden.size() > 0)) {
if(hidden.contains(id) || hidden.contains("world:" + worldname))
return false;
if ((hidden != null) && (!hidden.isEmpty())) {
return !hidden.contains(id) && !hidden.contains("world:" + worldname);
}
return true;
}
private void addStyle(String resid, AreaMarker m) {
AreaStyle as = cusstyle.get(resid);
if(as == null) {
if (as == null) {
as = defstyle;
}
int sc = 0xFF0000;
@ -248,7 +163,7 @@ public class DynmapFactionsPlugin extends JavaPlugin {
try {
sc = Integer.parseInt(as.strokecolor.substring(1), 16);
fc = Integer.parseInt(as.fillcolor.substring(1), 16);
} catch (NumberFormatException nfx) {
} catch (NumberFormatException ignored) {
}
m.setLineStyle(as.strokeweight, as.strokeopacity, sc);
m.setFillStyle(as.fillopacity, fc);
@ -257,170 +172,161 @@ public class DynmapFactionsPlugin extends JavaPlugin {
private MarkerIcon getMarkerIcon(String factname, Faction fact) {
AreaStyle as = cusstyle.get(factname);
if(as == null) {
if (as == null) {
as = defstyle;
}
return as.homeicon;
}
enum direction { XPLUS, ZPLUS, XMINUS, ZMINUS };
/**
* Find all contiguous blocks, set in target and clear in source
*/
private int floodFillTarget(TileFlags src, TileFlags dest, int x, int y) {
int cnt = 0;
ArrayDeque<int[]> stack = new ArrayDeque<int[]>();
stack.push(new int[] { x, y });
ArrayDeque<int[]> stack = new ArrayDeque<>();
stack.push(new int[]{x, y});
while(stack.isEmpty() == false) {
while (!stack.isEmpty()) {
int[] nxt = stack.pop();
x = nxt[0];
y = nxt[1];
if(src.getFlag(x, y)) { /* Set in src */
if (src.getFlag(x, y)) { /* Set in src */
src.setFlag(x, y, false); /* Clear source */
dest.setFlag(x, y, true); /* Set in destination */
cnt++;
if(src.getFlag(x+1, y))
stack.push(new int[] { x+1, y });
if(src.getFlag(x-1, y))
stack.push(new int[] { x-1, y });
if(src.getFlag(x, y+1))
stack.push(new int[] { x, y+1 });
if(src.getFlag(x, y-1))
stack.push(new int[] { x, y-1 });
if (src.getFlag(x + 1, y)) {
stack.push(new int[]{x + 1, y});
}
if (src.getFlag(x - 1, y)) {
stack.push(new int[]{x - 1, y});
}
if (src.getFlag(x, y + 1)) {
stack.push(new int[]{x, y + 1});
}
if (src.getFlag(x, y - 1)) {
stack.push(new int[]{x, y - 1});
}
}
}
return cnt;
}
private static class FactionBlock {
int x, z;
}
private static class FactionBlocks {
Map<String, LinkedList<FactionBlock>> blocks = new HashMap<String, LinkedList<FactionBlock>>();
}
/* Handle specific faction on specific world */
private void handleFactionOnWorld(String factname, Faction fact, String world, LinkedList<FactionBlock> blocks, Map<String, AreaMarker> newmap, Map<String, Marker> newmark) {
double[] x = null;
double[] z = null;
double[] x;
double[] z;
int poly_index = 0; /* Index of polygon for given faction */
/* Build popup */
String desc = formatInfoWindow(fact);
/* Handle areas */
if(isVisible(factname, world)) {
if(blocks.isEmpty())
if (isVisible(factname, world)) {
if (blocks.isEmpty()) {
return;
LinkedList<FactionBlock> nodevals = new LinkedList<FactionBlock>();
}
LinkedList<FactionBlock> nodevals = new LinkedList<>();
TileFlags curblks = new TileFlags();
/* Loop through blocks: set flags on blockmaps */
for(FactionBlock b : blocks) {
curblks.setFlag(b.x, b.z, true); /* Set flag for block */
for (FactionBlock b : blocks) {
curblks.setFlag(b.x(), b.z(), true); /* Set flag for block */
nodevals.addLast(b);
}
/* Loop through until we don't find more areas */
while(nodevals != null) {
while (nodevals != null) {
LinkedList<FactionBlock> ournodes = null;
LinkedList<FactionBlock> newlist = null;
TileFlags ourblks = null;
int minx = Integer.MAX_VALUE;
int minz = Integer.MAX_VALUE;
for(FactionBlock node : nodevals) {
int nodex = node.x;
int nodez = node.z;
for (FactionBlock node : nodevals) {
int nodex = node.x();
int nodez = node.z();
/* If we need to start shape, and this block is not part of one yet */
if((ourblks == null) && curblks.getFlag(nodex, nodez)) {
if ((ourblks == null) && curblks.getFlag(nodex, nodez)) {
ourblks = new TileFlags(); /* Create map for shape */
ournodes = new LinkedList<FactionBlock>();
ournodes = new LinkedList<>();
floodFillTarget(curblks, ourblks, nodex, nodez); /* Copy shape */
ournodes.add(node); /* Add it to our node list */
minx = nodex; minz = nodez;
}
/* If shape found, and we're in it, add to our node list */
else if((ourblks != null) && ourblks.getFlag(nodex, nodez)) {
ournodes.add(node);
if(nodex < minx) {
minx = nodex; minz = nodez;
}
else if((nodex == minx) && (nodez < minz)) {
minx = nodex;
minz = nodez;
}
/* If shape found, and we're in it, add to our node list */
else if ((ourblks != null) && ourblks.getFlag(nodex, nodez)) {
ournodes.add(node);
if (nodex < minx) {
minx = nodex;
minz = nodez;
} else if ((nodex == minx) && (nodez < minz)) {
minz = nodez;
}
} else { /* Else, keep it in the list for the next polygon */
if (newlist == null) {
newlist = new LinkedList<>();
}
else { /* Else, keep it in the list for the next polygon */
if(newlist == null) newlist = new LinkedList<FactionBlock>();
newlist.add(node);
}
}
nodevals = newlist; /* Replace list (null if no more to process) */
if(ourblks != null) {
if (ourblks != null) {
/* Trace outline of blocks - start from minx, minz going to x+ */
int init_x = minx;
int init_z = minz;
int cur_x = minx;
int cur_z = minz;
direction dir = direction.XPLUS;
ArrayList<int[]> linelist = new ArrayList<int[]>();
linelist.add(new int[] { init_x, init_z } ); // Add start point
while((cur_x != init_x) || (cur_z != init_z) || (dir != direction.ZMINUS)) {
switch(dir) {
Direction dir = Direction.XPLUS;
ArrayList<int[]> linelist = new ArrayList<>();
linelist.add(new int[]{minx, minz}); // Add start point
while ((cur_x != minx) || (cur_z != minz) || (dir != Direction.ZMINUS)) {
switch (dir) {
case XPLUS: /* Segment in X+ direction */
if(!ourblks.getFlag(cur_x+1, cur_z)) { /* Right turn? */
linelist.add(new int[] { cur_x+1, cur_z }); /* Finish line */
dir = direction.ZPLUS; /* Change direction */
}
else if(!ourblks.getFlag(cur_x+1, cur_z-1)) { /* Straight? */
if (!ourblks.getFlag(cur_x + 1, cur_z)) { /* Right turn? */
linelist.add(new int[]{cur_x + 1, cur_z}); /* Finish line */
dir = Direction.ZPLUS; /* Change direction */
} else if (!ourblks.getFlag(cur_x + 1, cur_z - 1)) { /* Straight? */
cur_x++;
}
else { /* Left turn */
linelist.add(new int[] { cur_x+1, cur_z }); /* Finish line */
dir = direction.ZMINUS;
cur_x++; cur_z--;
} else { /* Left turn */
linelist.add(new int[]{cur_x + 1, cur_z}); /* Finish line */
dir = Direction.ZMINUS;
cur_x++;
cur_z--;
}
break;
case ZPLUS: /* Segment in Z+ direction */
if(!ourblks.getFlag(cur_x, cur_z+1)) { /* Right turn? */
linelist.add(new int[] { cur_x+1, cur_z+1 }); /* Finish line */
dir = direction.XMINUS; /* Change direction */
}
else if(!ourblks.getFlag(cur_x+1, cur_z+1)) { /* Straight? */
if (!ourblks.getFlag(cur_x, cur_z + 1)) { /* Right turn? */
linelist.add(new int[]{cur_x + 1, cur_z + 1}); /* Finish line */
dir = Direction.XMINUS; /* Change direction */
} else if (!ourblks.getFlag(cur_x + 1, cur_z + 1)) { /* Straight? */
cur_z++;
} else { /* Left turn */
linelist.add(new int[]{cur_x + 1, cur_z + 1}); /* Finish line */
dir = Direction.XPLUS;
cur_x++;
cur_z++;
}
else { /* Left turn */
linelist.add(new int[] { cur_x+1, cur_z+1 }); /* Finish line */
dir = direction.XPLUS;
cur_x++; cur_z++;
}
break;
case XMINUS: /* Segment in X- direction */
if(!ourblks.getFlag(cur_x-1, cur_z)) { /* Right turn? */
linelist.add(new int[] { cur_x, cur_z+1 }); /* Finish line */
dir = direction.ZMINUS; /* Change direction */
}
else if(!ourblks.getFlag(cur_x-1, cur_z+1)) { /* Straight? */
if (!ourblks.getFlag(cur_x - 1, cur_z)) { /* Right turn? */
linelist.add(new int[]{cur_x, cur_z + 1}); /* Finish line */
dir = Direction.ZMINUS; /* Change direction */
} else if (!ourblks.getFlag(cur_x - 1, cur_z + 1)) { /* Straight? */
cur_x--;
}
else { /* Left turn */
linelist.add(new int[] { cur_x, cur_z+1 }); /* Finish line */
dir = direction.ZPLUS;
cur_x--; cur_z++;
} else { /* Left turn */
linelist.add(new int[]{cur_x, cur_z + 1}); /* Finish line */
dir = Direction.ZPLUS;
cur_x--;
cur_z++;
}
break;
case ZMINUS: /* Segment in Z- direction */
if(!ourblks.getFlag(cur_x, cur_z-1)) { /* Right turn? */
linelist.add(new int[] { cur_x, cur_z }); /* Finish line */
dir = direction.XPLUS; /* Change direction */
}
else if(!ourblks.getFlag(cur_x-1, cur_z-1)) { /* Straight? */
if (!ourblks.getFlag(cur_x, cur_z - 1)) { /* Right turn? */
linelist.add(new int[]{cur_x, cur_z}); /* Finish line */
dir = Direction.XPLUS; /* Change direction */
} else if (!ourblks.getFlag(cur_x - 1, cur_z - 1)) { /* Straight? */
cur_z--;
} else { /* Left turn */
linelist.add(new int[]{cur_x, cur_z}); /* Finish line */
dir = Direction.XMINUS;
cur_x--;
cur_z--;
}
else { /* Left turn */
linelist.add(new int[] { cur_x, cur_z }); /* Finish line */
dir = direction.XMINUS;
cur_x--; cur_z--;
}
break;
}
@ -430,21 +336,20 @@ public class DynmapFactionsPlugin extends JavaPlugin {
int sz = linelist.size();
x = new double[sz];
z = new double[sz];
for(int i = 0; i < sz; i++) {
for (int i = 0; i < sz; i++) {
int[] line = linelist.get(i);
x[i] = (double)line[0] * (double)blocksize;
z[i] = (double)line[1] * (double)blocksize;
x[i] = (double) line[0] * (double) blocksize;
z[i] = (double) line[1] * (double) blocksize;
}
/* Find existing one */
AreaMarker m = resareas.remove(polyid); /* Existing area? */
if(m == null) {
if (m == null) {
m = set.createAreaMarker(polyid, factname, false, world, x, z, false);
if(m == null) {
if (m == null) {
info("error adding area marker " + polyid);
return;
}
}
else {
} else {
m.setCornerLocations(x, z); /* Replace corner locations */
m.setLabel(factname); /* Update label */
}
@ -462,12 +367,12 @@ public class DynmapFactionsPlugin extends JavaPlugin {
}
/* Update Factions information */
private void updateFactions() {
Map<String,AreaMarker> newmap = new HashMap<String,AreaMarker>(); /* Build new map */
Map<String,Marker> newmark = new HashMap<String,Marker>(); /* Build new map */
void updateFactions() {
Map<String, AreaMarker> newmap = new HashMap<>(); /* Build new map */
Map<String, Marker> newmark = new HashMap<>(); /* Build new map */
/* Parse into faction centric mapping, split by world */
Map<String, FactionBlocks> blocks_by_faction = new HashMap<String, FactionBlocks>();
Map<String, FactionBlocks> blocks_by_faction = new HashMap<>();
FactionColl fc = FactionColl.get();
Collection<Faction> facts = fc.getAll();
@ -475,7 +380,7 @@ public class DynmapFactionsPlugin extends JavaPlugin {
Set<PS> chunks = BoardColl.get().getChunks(fact);
String fid = fc.getUniverse() + "_" + fact.getId();
FactionBlocks factblocks = blocks_by_faction.get(fid); /* Look up faction */
if(factblocks == null) { /* Create faction block if first time */
if (factblocks == null) { /* Create faction block if first time */
factblocks = new FactionBlocks();
blocks_by_faction.put(fid, factblocks);
}
@ -484,50 +389,55 @@ public class DynmapFactionsPlugin extends JavaPlugin {
String world = cc.getWorld();
/* Get block set for given world */
LinkedList<FactionBlock> blocks = factblocks.blocks.get(world);
if(blocks == null) {
blocks = new LinkedList<FactionBlock>();
factblocks.blocks.put(world, blocks);
}
FactionBlock fb = new FactionBlock();
fb.x = cc.getChunkX();
fb.z = cc.getChunkZ();
LinkedList<FactionBlock> blocks = factblocks.blocks.computeIfAbsent(world, k -> new LinkedList<>());
FactionBlock fb = new FactionBlock(cc.getChunkX(), cc.getChunkZ());
blocks.add(fb); /* Add to list */
}
}
/* Loop through factions */
for(Faction fact : facts) {
for (Faction fact : facts) {
String factname = ChatColor.stripColor(fact.getName());
String fid = fc.getUniverse() + "_" + fact.getId();
FactionBlocks factblocks = blocks_by_faction.get(fid); /* Look up faction */
if (factblocks == null) continue;
if (factblocks == null) {
continue;
}
/* Loop through each world that faction has blocks on */
for(Map.Entry<String, LinkedList<FactionBlock>> worldblocks : factblocks.blocks.entrySet()) {
for (Map.Entry<String, LinkedList<FactionBlock>> worldblocks : factblocks.blocks.entrySet()) {
handleFactionOnWorld(factname, fact, worldblocks.getKey(), worldblocks.getValue(), newmap, newmark);
}
factblocks.blocks.clear();
/* Now, add marker for home location */
PS homeloc = fact.getHome();
if(homeloc != null) {
EntityInternalMap<Warp> warps = fact.getWarps();
Warp home = null;
for (String warp : warps.keySet()) {
if (warp.equalsIgnoreCase("home")) {
home = warps.get(warp);
}
}
if (home == null) {
continue;
}
PS homeloc = home.getLocation();
if (homeloc != null) {
String markid = fc.getUniverse() + "_" + factname + "__home";
MarkerIcon ico = getMarkerIcon(factname, fact);
if(ico != null) {
Marker home = resmark.remove(markid);
if (ico != null) {
Marker homeMarker = resmark.remove(markid);
String lbl = factname + " [home]";
if(home == null) {
home = set.createMarker(markid, lbl, homeloc.getWorld(),
if (homeMarker == null) {
homeMarker = set.createMarker(markid, lbl, homeloc.getWorld(),
homeloc.getLocationX(), homeloc.getLocationY(), homeloc.getLocationZ(), ico, false);
} else {
homeMarker.setLocation(homeloc.getWorld(), homeloc.getLocationX(), homeloc.getLocationY(), homeloc.getLocationZ());
homeMarker.setLabel(lbl); /* Update label */
homeMarker.setMarkerIcon(ico);
}
else {
home.setLocation(homeloc.getWorld(), homeloc.getLocationX(), homeloc.getLocationY(), homeloc.getLocationZ());
home.setLabel(lbl); /* Update label */
home.setMarkerIcon(ico);
}
if (home != null) {
home.setDescription(formatInfoWindow(fact)); /* Set popup */
newmark.put(markid, home);
if (homeMarker != null) {
homeMarker.setDescription(formatInfoWindow(fact)); /* Set popup */
newmark.put(markid, homeMarker);
}
}
}
@ -535,10 +445,10 @@ public class DynmapFactionsPlugin extends JavaPlugin {
blocks_by_faction.clear();
/* Now, review old map - anything left is gone */
for(AreaMarker oldm : resareas.values()) {
for (AreaMarker oldm : resareas.values()) {
oldm.deleteMarker();
}
for(Marker oldm : resmark.values()) {
for (Marker oldm : resmark.values()) {
oldm.deleteMarker();
}
/* And replace with new map */
@ -548,9 +458,9 @@ public class DynmapFactionsPlugin extends JavaPlugin {
}
private void updatePlayerSets() {
if(playersets) {
if (playersets) {
FactionColl fc = FactionColl.get();
for(Faction f : fc.getAll()) {
for (Faction f : fc.getAll()) {
if ((f == fc.getNone()) || (f == fc.getWarzone()) || (f == fc.getSafezone())) {
continue;
}
@ -559,97 +469,42 @@ public class DynmapFactionsPlugin extends JavaPlugin {
}
}
private class OurServerListener implements Listener {
@EventHandler
public void onPluginEnable(PluginEnableEvent event) {
Plugin p = event.getPlugin();
String name = p.getDescription().getName();
if(name.equals("dynmap") || name.equals("Factions")) {
if(dynmap.isEnabled() && factions.isEnabled())
activate();
}
}
@EventHandler(priority=EventPriority.MONITOR)
public void onFPlayerJoin(EventFactionsMembershipChange event) {
if(event.isCancelled())
return;
if(playersets) {
Faction f = event.getNewFaction();
requestUpdatePlayerSet(f.getId());
}
}
@EventHandler(priority=EventPriority.MONITOR)
public void onFactionCreate(EventFactionsCreate event) {
if(event.isCancelled())
return;
if(playersets)
requestUpdatePlayerSet(event.getFactionId());
requestUpdateFactions();
}
@EventHandler(priority=EventPriority.MONITOR)
public void onFactionDisband(EventFactionsDisband event) {
if(event.isCancelled())
return;
if(playersets) {
Faction f = event.getFaction();
requestUpdatePlayerSet(f.getId());
}
requestUpdateFactions();
}
@EventHandler(priority=EventPriority.MONITOR)
public void onFactionRename(EventFactionsNameChange event) {
if(event.isCancelled())
return;
requestUpdateFactions();
}
@EventHandler(priority=EventPriority.MONITOR)
public void onFactionRename(EventFactionsHomeChange event) {
if(event.isCancelled())
return;
requestUpdateFactions();
}
@EventHandler(priority=EventPriority.MONITOR)
public void onFactionRename(EventFactionsChunksChange event) {
if(event.isCancelled())
return;
requestUpdateFactions();
}
}
public void onEnable() {
instance = this;
info("initializing");
PluginManager pm = getServer().getPluginManager();
/* Get dynmap */
dynmap = pm.getPlugin("dynmap");
if(dynmap == null) {
if (dynmap == null) {
severe("Cannot find dynmap!");
return;
}
api = (DynmapAPI)dynmap; /* Get API */
api = (DynmapAPI) dynmap; /* Get API */
/* Get Factions */
Plugin p = pm.getPlugin("Factions");
if(p == null) {
if (p == null) {
severe("Cannot find Factions!");
return;
}
factions = p;
/* If both enabled, activate */
if(dynmap.isEnabled() && factions.isEnabled())
if (dynmap.isEnabled() && factions.isEnabled()) {
activate();
}
try {
MetricsLite ml = new MetricsLite(this);
ml.start();
} catch (IOException iox) {
} catch (IOException ignored) {
}
}
private boolean reload = false;
private void activate() {
void activate() {
markerapi = api.getMarkerAPI();
if(markerapi == null) {
if (markerapi == null) {
severe("Error loading dynmap marker API!");
return;
}
@ -659,14 +514,13 @@ public class DynmapFactionsPlugin extends JavaPlugin {
blocksize = 16; /* Fixed at 16 */
/* Load configuration */
if(reload) {
if (reload) {
this.reloadConfig();
if(set != null) {
if (set != null) {
set.deleteMarkerSet();
set = null;
}
}
else {
} else {
reload = true;
}
FileConfiguration cfg = getConfig();
@ -675,11 +529,12 @@ public class DynmapFactionsPlugin extends JavaPlugin {
/* Now, add marker set for mobs (make it transient) */
set = markerapi.getMarkerSet("factions.markerset");
if(set == null)
if (set == null) {
set = markerapi.createMarkerSet("factions.markerset", cfg.getString("layer.name", "Factions"), null, false);
else
} else {
set.setMarkerSetLabel(cfg.getString("layer.name", "Factions"));
if(set == null) {
}
if (set == null) {
severe("Error creating marker set");
return;
}
@ -688,37 +543,38 @@ public class DynmapFactionsPlugin extends JavaPlugin {
resmark.clear();
int minzoom = cfg.getInt("layer.minzoom", 0);
if(minzoom > 0)
if (minzoom > 0) {
set.setMinZoom(minzoom);
}
set.setLayerPriority(cfg.getInt("layer.layerprio", 10));
set.setHideByDefault(cfg.getBoolean("layer.hidebydefault", false));
use3d = cfg.getBoolean("use3dregions", false);
infowindow = cfg.getString("infowindow", DEF_INFOWINDOW);
/* Get style information */
defstyle = new AreaStyle(cfg, "regionstyle");
cusstyle = new HashMap<String, AreaStyle>();
defstyle = new AreaStyle(this, cfg, "regionstyle");
cusstyle = new HashMap<>();
ConfigurationSection sect = cfg.getConfigurationSection("custstyle");
if(sect != null) {
if (sect != null) {
Set<String> ids = sect.getKeys(false);
for(String id : ids) {
cusstyle.put(id, new AreaStyle(cfg, "custstyle." + id, defstyle));
for (String id : ids) {
cusstyle.put(id, new AreaStyle(this, cfg, "custstyle." + id, defstyle));
}
}
List<String> vis = cfg.getStringList("visibleregions");
if(vis != null) {
visible = new HashSet<String>(vis);
if (vis != null) {
visible = new HashSet<>(vis);
}
List<String> hid = cfg.getStringList("hiddenregions");
if(hid != null) {
hidden = new HashSet<String>(hid);
if (hid != null) {
hidden = new HashSet<>(hid);
}
/* Chec if player sets enabled */
playersets = cfg.getBoolean("visibility-by-faction", false);
if(playersets) {
if (playersets) {
try {
if(!api.testIfPlayerInfoProtected()) {
if (!api.testIfPlayerInfoProtected()) {
playersets = false;
info("Dynmap does not have player-info-protected enabled - visibility-by-faction will have no effect");
}
@ -731,18 +587,20 @@ public class DynmapFactionsPlugin extends JavaPlugin {
/* Set up update job - based on periond */
int per = cfg.getInt("update.period", 300);
if(per < 15) per = 15;
updperiod = (per*20);
if (per < 15) {
per = 15;
}
updperiod = (per * 20L);
stop = false;
getServer().getScheduler().scheduleSyncDelayedTask(this, new FactionsUpdate(), 40); /* First time is 2 seconds */
getServer().getPluginManager().registerEvents(new OurServerListener(), this);
getServer().getScheduler().scheduleSyncDelayedTask(this, new FactionsUpdate(this), 40); /* First time is 2 seconds */
getServer().getPluginManager().registerEvents(new OurServerListener(this), this);
info("version " + this.getDescription().getVersion() + " is activated");
}
public void onDisable() {
if(set != null) {
if (set != null) {
set.deleteMarkerSet();
set = null;
}

View File

@ -0,0 +1,4 @@
package org.dynmap.factions;
public record FactionBlock(int x, int z) {
}

View File

@ -0,0 +1,11 @@
package org.dynmap.factions;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
public class FactionBlocks {
final Map<String, LinkedList<FactionBlock>> blocks = new HashMap<>();
}

View File

@ -0,0 +1,26 @@
package org.dynmap.factions;
public class FactionsUpdate implements Runnable {
private final DynmapFactionsPlugin dynmapFactionsPlugin;
public boolean runonce;
public FactionsUpdate(DynmapFactionsPlugin dynmapFactionsPlugin) {
this.dynmapFactionsPlugin = dynmapFactionsPlugin;
}
public void run() {
if (dynmapFactionsPlugin.stop) {
return;
}
dynmapFactionsPlugin.updateFactions();
if (!runonce) {
dynmapFactionsPlugin.getServer().getScheduler().scheduleSyncDelayedTask(dynmapFactionsPlugin,
this, dynmapFactionsPlugin.updperiod);
} else if (dynmapFactionsPlugin.pending == this) {
dynmapFactionsPlugin.pending = null;
}
}
}

View File

@ -45,6 +45,7 @@ import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.UUID;
import java.util.logging.Level;
@ -193,16 +194,11 @@ public class MetricsLite {
* @return true if metrics should be opted out of it
*/
public boolean isOptOut() {
synchronized(optOutLock) {
synchronized (optOutLock) {
try {
// Reload the metrics file
configuration.load(getConfigFile());
} catch (IOException ex) {
if (debug) {
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
}
return true;
} catch (InvalidConfigurationException ex) {
} catch (IOException | InvalidConfigurationException ex) {
if (debug) {
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
}
@ -381,7 +377,7 @@ public class MetricsLite {
* @param key the key value
* @param value the value
*/
private static void encodeDataPair(final StringBuilder buffer, final String key, final String value) throws UnsupportedEncodingException {
private static void encodeDataPair(final StringBuilder buffer, final String key, final String value) {
buffer.append('&').append(encode(key)).append('=').append(encode(value));
}
@ -391,8 +387,8 @@ public class MetricsLite {
* @param text the text to encode
* @return the encoded text, as UTF-8
*/
private static String encode(final String text) throws UnsupportedEncodingException {
return URLEncoder.encode(text, "UTF-8");
private static String encode(final String text) {
return URLEncoder.encode(text, StandardCharsets.UTF_8);
}
}

View File

@ -0,0 +1,111 @@
package org.dynmap.factions;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.event.EventFactionsChunksChange;
import com.massivecraft.factions.event.EventFactionsCreate;
import com.massivecraft.factions.event.EventFactionsDisband;
import com.massivecraft.factions.event.EventFactionsMembershipChange;
import com.massivecraft.factions.event.EventFactionsNameChange;
import com.massivecraft.factions.event.EventFactionsWarpAdd;
import com.massivecraft.factions.event.EventFactionsWarpRemove;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
class OurServerListener implements Listener {
private final DynmapFactionsPlugin dynmapFactionsPlugin;
public OurServerListener(DynmapFactionsPlugin dynmapFactionsPlugin) {
this.dynmapFactionsPlugin = dynmapFactionsPlugin;
}
@EventHandler
public void onPluginEnable(PluginEnableEvent event) {
Plugin p = event.getPlugin();
String name = p.getDescription().getName();
if (name.equals("dynmap") || name.equals("Factions")) {
if (dynmapFactionsPlugin.dynmap.isEnabled() && dynmapFactionsPlugin.factions.isEnabled()) {
dynmapFactionsPlugin.activate();
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onFPlayerJoin(EventFactionsMembershipChange event) {
if (event.isCancelled()) {
return;
}
if (dynmapFactionsPlugin.playersets) {
Faction f = event.getNewFaction();
dynmapFactionsPlugin.requestUpdatePlayerSet(f.getId());
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onFactionCreate(EventFactionsCreate event) {
if (event.isCancelled()) {
return;
}
if (dynmapFactionsPlugin.playersets) {
dynmapFactionsPlugin.requestUpdatePlayerSet(event.getFactionId());
}
requestUpdateFactions();
}
@EventHandler(priority = EventPriority.MONITOR)
public void onFactionDisband(EventFactionsDisband event) {
if (event.isCancelled()) {
return;
}
if (dynmapFactionsPlugin.playersets) {
Faction f = event.getFaction();
dynmapFactionsPlugin.requestUpdatePlayerSet(f.getId());
}
requestUpdateFactions();
}
@EventHandler(priority = EventPriority.MONITOR)
public void onFactionRename(EventFactionsNameChange event) {
if (event.isCancelled()) {
return;
}
requestUpdateFactions();
}
@EventHandler(priority = EventPriority.MONITOR)
public void onFactionRename(EventFactionsWarpAdd event) {
if (event.isCancelled()) {
return;
}
requestUpdateFactions();
}
@EventHandler(priority = EventPriority.MONITOR)
public void onFactionRename(EventFactionsWarpRemove event) {
if (event.isCancelled()) {
return;
}
requestUpdateFactions();
}
@EventHandler(priority = EventPriority.MONITOR)
public void onFactionRename(EventFactionsChunksChange event) {
if (event.isCancelled()) {
return;
}
requestUpdateFactions();
}
private void requestUpdateFactions() {
if (DynmapFactionsPlugin.instance.pending == null) {
FactionsUpdate upd = new FactionsUpdate(DynmapFactionsPlugin.instance);
upd.runonce = true;
DynmapFactionsPlugin.instance.pending = upd;
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(DynmapFactionsPlugin.instance, upd, 20);
}
}
}

View File

@ -0,0 +1,17 @@
package org.dynmap.factions;
class PlayerSetUpdate implements Runnable {
private final DynmapFactionsPlugin dynmapFactionsPlugin;
public final String faction;
public PlayerSetUpdate(DynmapFactionsPlugin dynmapFactionsPlugin, String fid) {
this.dynmapFactionsPlugin = dynmapFactionsPlugin;
faction = fid;
}
public void run() {
if (!dynmapFactionsPlugin.stop) {
dynmapFactionsPlugin.updatePlayerSet(faction);
}
}
}

View File

@ -1,17 +1,17 @@
package org.dynmap.factions;
import java.util.HashMap;
import java.util.Map;
/**
* scalable flags primitive - used for keeping track of potentially huge number of tiles
*
* <p>
* Represents a flag for each tile, with 2D coordinates based on 0,0 origin. Flags are grouped
* 64 x 64, represented by an array of 64 longs. Each set is stored in a hashmap, keyed by a long
* computed by ((x/64)<<32)+(y/64).
*
*/
public class TileFlags {
private HashMap<Long, long[]> chunkmap = new HashMap<Long, long[]>();
private final Map<Long, long[]> chunkMap = new HashMap<>();
private long last_key = Long.MAX_VALUE;
private long[] last_row;
@ -19,48 +19,48 @@ public class TileFlags {
}
public boolean getFlag(int x, int y) {
long k = (((long)(x >> 6)) << 32) | (0xFFFFFFFFL & (long)(y >> 6));
long k = (((long) (x >> 6)) << 32) | (0xFFFFFFFFL & (long) (y >> 6));
long[] row;
if(k == last_key) {
if (k == last_key) {
row = last_row;
}
else {
row = chunkmap.get(k);
} else {
row = chunkMap.get(k);
last_key = k;
last_row = row;
}
if(row == null)
if (row == null) {
return false;
else
} else {
return (row[y & 0x3F] & (1L << (x & 0x3F))) != 0;
}
}
public void setFlag(int x, int y, boolean f) {
long k = (((long)(x >> 6)) << 32) | (0xFFFFFFFFL & (long)(y >> 6));
long k = (((long) (x >> 6)) << 32) | (0xFFFFFFFFL & (long) (y >> 6));
long[] row;
if(k == last_key) {
if (k == last_key) {
row = last_row;
}
else {
row = chunkmap.get(k);
} else {
row = chunkMap.get(k);
last_key = k;
last_row = row;
}
if(f) {
if(row == null) {
if (f) {
if (row == null) {
row = new long[64];
chunkmap.put(k, row);
chunkMap.put(k, row);
last_row = row;
}
row[y & 0x3F] |= (1L << (x & 0x3F));
}
else {
if(row != null)
} else {
if (row != null) {
row[y & 0x3F] &= ~(1L << (x & 0x3F));
}
}
}
public void clear() {
chunkmap.clear();
chunkMap.clear();
last_row = null;
last_key = Long.MAX_VALUE;
}