Initial. perhaps broken update attempt
This commit is contained in:
parent
6fb1174adf
commit
ef3cf02a23
2
.gitignore
vendored
2
.gitignore
vendored
@ -23,3 +23,5 @@
|
|||||||
|
|
||||||
# Mac filesystem dust
|
# Mac filesystem dust
|
||||||
/.DS_Store
|
/.DS_Store
|
||||||
|
|
||||||
|
*.iml
|
Binary file not shown.
Binary file not shown.
51
pom.xml
51
pom.xml
@ -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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.dynmap</groupId>
|
<groupId>org.dynmap</groupId>
|
||||||
<artifactId>Dynmap-Factions</artifactId>
|
<artifactId>Dynmap-Factions</artifactId>
|
||||||
<version>0.91</version>
|
<version>0.92</version>
|
||||||
<properties>
|
<properties>
|
||||||
<timestamp>${maven.build.timestamp}</timestamp>
|
<timestamp>${maven.build.timestamp}</timestamp>
|
||||||
<maven.build.timestamp.format>yyyyMMddHHmm</maven.build.timestamp.format>
|
<maven.build.timestamp.format>yyyyMMddHHmm</maven.build.timestamp.format>
|
||||||
@ -34,57 +35,49 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>2.0.2</version>
|
<version>3.8.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.6</source>
|
<source>16</source>
|
||||||
<target>1.6</target>
|
<target>16</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<releases>
|
<id>spigotmc-repo</id>
|
||||||
</releases>
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
<snapshots>
|
|
||||||
</snapshots>
|
|
||||||
<id>bukkit-repo</id>
|
|
||||||
<url>http://repo.bukkit.org/content/repositories/releases/</url>
|
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<releases>
|
<id>dynmap</id>
|
||||||
</releases>
|
<url>https://repo.mikeprimm.com/</url>
|
||||||
<snapshots>
|
|
||||||
</snapshots>
|
|
||||||
<id>dynmap-repo</id>
|
|
||||||
<url>http://repo.mikeprimm.com/</url>
|
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.dynmap</groupId>
|
<groupId>us.dynmap</groupId>
|
||||||
<artifactId>dynmap-api</artifactId>
|
<artifactId>dynmap-api</artifactId>
|
||||||
<version>1.9</version>
|
<version>3.6-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.7.10-R0.1-SNAPSHOT</version>
|
<version>1.20.6-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.massivecraft</groupId>
|
<groupId>com.massivecraft</groupId>
|
||||||
<artifactId>Factions</artifactId>
|
<artifactId>Factions</artifactId>
|
||||||
<version>2.7.1</version>
|
<version>3.3.3</version>
|
||||||
<scope>system</scope>
|
<scope>provided</scope>
|
||||||
<systemPath>${project.basedir}/Factions-2.7.1.jar</systemPath>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.massivecraft</groupId>
|
<groupId>com.massivecraft.massivecore</groupId>
|
||||||
<artifactId>MassiveCore</artifactId>
|
<artifactId>MassiveCore</artifactId>
|
||||||
<version>2.7.1</version>
|
<version>3.3.3</version>
|
||||||
<scope>system</scope>
|
<scope>provided</scope>
|
||||||
<systemPath>${project.basedir}/MassiveCore-2.7.1.jar</systemPath>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -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>
|
|
51
src/main/java/org/dynmap/factions/AreaStyle.java
Normal file
51
src/main/java/org/dynmap/factions/AreaStyle.java
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
10
src/main/java/org/dynmap/factions/Direction.java
Normal file
10
src/main/java/org/dynmap/factions/Direction.java
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package org.dynmap.factions;
|
||||||
|
|
||||||
|
public enum Direction {
|
||||||
|
|
||||||
|
XPLUS,
|
||||||
|
ZPLUS,
|
||||||
|
XMINUS,
|
||||||
|
ZMINUS
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,29 @@
|
|||||||
package org.dynmap.factions;
|
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.io.IOException;
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -13,40 +37,8 @@ import java.util.Set;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
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 {
|
public class DynmapFactionsPlugin extends JavaPlugin {
|
||||||
|
|
||||||
private static Logger log;
|
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>";
|
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;
|
Plugin dynmap;
|
||||||
@ -58,7 +50,6 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
int blocksize;
|
int blocksize;
|
||||||
|
|
||||||
FileConfiguration cfg;
|
|
||||||
MarkerSet set;
|
MarkerSet set;
|
||||||
long updperiod;
|
long updperiod;
|
||||||
boolean use3d;
|
boolean use3d;
|
||||||
@ -68,112 +59,35 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
Set<String> visible;
|
Set<String> visible;
|
||||||
Set<String> hidden;
|
Set<String> hidden;
|
||||||
boolean stop;
|
boolean stop;
|
||||||
|
static DynmapFactionsPlugin instance;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
log = this.getLogger();
|
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) {
|
public static void info(String msg) {
|
||||||
log.log(Level.INFO, msg);
|
log.log(Level.INFO, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void severe(String msg) {
|
public static void severe(String msg) {
|
||||||
log.log(Level.SEVERE, msg);
|
log.log(Level.SEVERE, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class FactionsUpdate implements Runnable {
|
void requestUpdatePlayerSet(String factid) {
|
||||||
public boolean runonce;
|
if (playersets) {
|
||||||
public void run() {
|
getServer().getScheduler().scheduleSyncDelayedTask(this, new PlayerSetUpdate(this, factid));
|
||||||
if(!stop) {
|
|
||||||
updateFactions();
|
|
||||||
if(!runonce) {
|
|
||||||
getServer().getScheduler().scheduleSyncDelayedTask(DynmapFactionsPlugin.this, this, updperiod);
|
|
||||||
}
|
|
||||||
else if(pending == this) {
|
|
||||||
pending = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PlayerSetUpdate implements Runnable {
|
FactionsUpdate pending = null;
|
||||||
public String faction;
|
|
||||||
public PlayerSetUpdate(String fid) {
|
|
||||||
faction = fid;
|
|
||||||
}
|
|
||||||
public void run() {
|
|
||||||
if(!stop)
|
|
||||||
updatePlayerSet(faction);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void requestUpdatePlayerSet(String factid) {
|
void updatePlayerSet(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) {
|
|
||||||
/* If Wilderness or other unassociated factions (guid-style ID), skip */
|
/* If Wilderness or other unassociated factions (guid-style ID), skip */
|
||||||
if (factid.indexOf('-') >= 0) {
|
if (factid.indexOf('-') >= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Set<String> plids = new HashSet<String>();
|
Set<String> plids = new HashSet<>();
|
||||||
FactionColl fc = FactionColl.get();
|
FactionColl fc = FactionColl.get();
|
||||||
|
|
||||||
Faction f = fc.getByName(factid); /* Get faction */
|
Faction f = fc.getByName(factid); /* Get faction */
|
||||||
@ -190,16 +104,16 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
set = markerapi.createPlayerSet(setid, true, plids, false);
|
set = markerapi.createPlayerSet(setid, true, plids, false);
|
||||||
info("Added player visibility set '" + setid + "' for faction " + factid);
|
info("Added player visibility set '" + setid + "' for faction " + factid);
|
||||||
}
|
}
|
||||||
else if(f != null) {
|
|
||||||
|
if (f != null) {
|
||||||
set.setPlayers(plids);
|
set.setPlayers(plids);
|
||||||
}
|
} else if (set != null) {
|
||||||
else {
|
|
||||||
set.deleteSet();
|
set.deleteSet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, AreaMarker> resareas = new HashMap<String, AreaMarker>();
|
private Map<String, AreaMarker> resareas = new HashMap<>();
|
||||||
private Map<String, Marker> resmark = new HashMap<String, Marker>();
|
private Map<String, Marker> resmark = new HashMap<>();
|
||||||
|
|
||||||
private String formatInfoWindow(Faction fact) {
|
private String formatInfoWindow(Faction fact) {
|
||||||
String v = "<div class=\"regioninfo\">" + infowindow + "</div>";
|
String v = "<div class=\"regioninfo\">" + infowindow + "</div>";
|
||||||
@ -207,33 +121,34 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
v = v.replace("%description%", ChatColor.stripColor(fact.getDescription()));
|
v = v.replace("%description%", ChatColor.stripColor(fact.getDescription()));
|
||||||
MPlayer adm = fact.getLeader();
|
MPlayer adm = fact.getLeader();
|
||||||
v = v.replace("%playerowners%", (adm != null) ? adm.getName() : "");
|
v = v.replace("%playerowners%", (adm != null) ? adm.getName() : "");
|
||||||
String res = "";
|
StringBuilder res = new StringBuilder();
|
||||||
for (MPlayer r : fact.getMPlayers()) {
|
for (MPlayer r : fact.getMPlayers()) {
|
||||||
if(res.length()>0) res += ", ";
|
if (!res.isEmpty()) {
|
||||||
res += r.getName();
|
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()));
|
v = v.replace("%nation%", ChatColor.stripColor(fact.getName()));
|
||||||
/* Build flags */
|
/* Build flags */
|
||||||
String flgs = "";
|
StringBuilder flgs = new StringBuilder();
|
||||||
for (MFlag ff : MFlagColl.get().getAll()) {
|
for (MFlag ff : MFlagColl.get().getAll()) {
|
||||||
flgs += "<br/>" + ff.getName() + ": " + fact.getFlag(ff);
|
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("%flag." + ff.getName() + "%", fact.getFlag(ff) ? "true" : "false");
|
||||||
}
|
}
|
||||||
v = v.replace("%flags%", flgs);
|
v = v.replace("%flags%", flgs.toString());
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isVisible(String id, String worldname) {
|
private boolean isVisible(String id, String worldname) {
|
||||||
if((visible != null) && (visible.size() > 0)) {
|
if ((visible != null) && (!visible.isEmpty())) {
|
||||||
if((visible.contains(id) == false) && (visible.contains("world:" + worldname) == false)) {
|
if ((!visible.contains(id)) && (!visible.contains("world:" + worldname))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if((hidden != null) && (hidden.size() > 0)) {
|
if ((hidden != null) && (!hidden.isEmpty())) {
|
||||||
if(hidden.contains(id) || hidden.contains("world:" + worldname))
|
return !hidden.contains(id) && !hidden.contains("world:" + worldname);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -248,7 +163,7 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
try {
|
try {
|
||||||
sc = Integer.parseInt(as.strokecolor.substring(1), 16);
|
sc = Integer.parseInt(as.strokecolor.substring(1), 16);
|
||||||
fc = Integer.parseInt(as.fillcolor.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.setLineStyle(as.strokeweight, as.strokeopacity, sc);
|
||||||
m.setFillStyle(as.fillopacity, fc);
|
m.setFillStyle(as.fillopacity, fc);
|
||||||
@ -263,17 +178,15 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
return as.homeicon;
|
return as.homeicon;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum direction { XPLUS, ZPLUS, XMINUS, ZMINUS };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find all contiguous blocks, set in target and clear in source
|
* Find all contiguous blocks, set in target and clear in source
|
||||||
*/
|
*/
|
||||||
private int floodFillTarget(TileFlags src, TileFlags dest, int x, int y) {
|
private int floodFillTarget(TileFlags src, TileFlags dest, int x, int y) {
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
ArrayDeque<int[]> stack = new ArrayDeque<int[]>();
|
ArrayDeque<int[]> stack = new ArrayDeque<>();
|
||||||
stack.push(new int[]{x, y});
|
stack.push(new int[]{x, y});
|
||||||
|
|
||||||
while(stack.isEmpty() == false) {
|
while (!stack.isEmpty()) {
|
||||||
int[] nxt = stack.pop();
|
int[] nxt = stack.pop();
|
||||||
x = nxt[0];
|
x = nxt[0];
|
||||||
y = nxt[1];
|
y = nxt[1];
|
||||||
@ -281,31 +194,27 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
src.setFlag(x, y, false); /* Clear source */
|
src.setFlag(x, y, false); /* Clear source */
|
||||||
dest.setFlag(x, y, true); /* Set in destination */
|
dest.setFlag(x, y, true); /* Set in destination */
|
||||||
cnt++;
|
cnt++;
|
||||||
if(src.getFlag(x+1, y))
|
if (src.getFlag(x + 1, y)) {
|
||||||
stack.push(new int[]{x + 1, y});
|
stack.push(new int[]{x + 1, y});
|
||||||
if(src.getFlag(x-1, y))
|
}
|
||||||
|
if (src.getFlag(x - 1, y)) {
|
||||||
stack.push(new int[]{x - 1, y});
|
stack.push(new int[]{x - 1, y});
|
||||||
if(src.getFlag(x, y+1))
|
}
|
||||||
|
if (src.getFlag(x, y + 1)) {
|
||||||
stack.push(new int[]{x, y + 1});
|
stack.push(new int[]{x, y + 1});
|
||||||
if(src.getFlag(x, y-1))
|
}
|
||||||
|
if (src.getFlag(x, y - 1)) {
|
||||||
stack.push(new int[]{x, y - 1});
|
stack.push(new int[]{x, y - 1});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return cnt;
|
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 */
|
/* 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) {
|
private void handleFactionOnWorld(String factname, Faction fact, String world, LinkedList<FactionBlock> blocks, Map<String, AreaMarker> newmap, Map<String, Marker> newmark) {
|
||||||
double[] x = null;
|
double[] x;
|
||||||
double[] z = null;
|
double[] z;
|
||||||
int poly_index = 0; /* Index of polygon for given faction */
|
int poly_index = 0; /* Index of polygon for given faction */
|
||||||
|
|
||||||
/* Build popup */
|
/* Build popup */
|
||||||
@ -313,13 +222,14 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
/* Handle areas */
|
/* Handle areas */
|
||||||
if (isVisible(factname, world)) {
|
if (isVisible(factname, world)) {
|
||||||
if(blocks.isEmpty())
|
if (blocks.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
LinkedList<FactionBlock> nodevals = new LinkedList<FactionBlock>();
|
}
|
||||||
|
LinkedList<FactionBlock> nodevals = new LinkedList<>();
|
||||||
TileFlags curblks = new TileFlags();
|
TileFlags curblks = new TileFlags();
|
||||||
/* Loop through blocks: set flags on blockmaps */
|
/* Loop through blocks: set flags on blockmaps */
|
||||||
for (FactionBlock b : blocks) {
|
for (FactionBlock b : blocks) {
|
||||||
curblks.setFlag(b.x, b.z, true); /* Set flag for block */
|
curblks.setFlag(b.x(), b.z(), true); /* Set flag for block */
|
||||||
nodevals.addLast(b);
|
nodevals.addLast(b);
|
||||||
}
|
}
|
||||||
/* Loop through until we don't find more areas */
|
/* Loop through until we don't find more areas */
|
||||||
@ -330,97 +240,93 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
int minx = Integer.MAX_VALUE;
|
int minx = Integer.MAX_VALUE;
|
||||||
int minz = Integer.MAX_VALUE;
|
int minz = Integer.MAX_VALUE;
|
||||||
for (FactionBlock node : nodevals) {
|
for (FactionBlock node : nodevals) {
|
||||||
int nodex = node.x;
|
int nodex = node.x();
|
||||||
int nodez = node.z;
|
int nodez = node.z();
|
||||||
/* If we need to start shape, and this block is not part of one yet */
|
/* 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 */
|
ourblks = new TileFlags(); /* Create map for shape */
|
||||||
ournodes = new LinkedList<FactionBlock>();
|
ournodes = new LinkedList<>();
|
||||||
floodFillTarget(curblks, ourblks, nodex, nodez); /* Copy shape */
|
floodFillTarget(curblks, ourblks, nodex, nodez); /* Copy shape */
|
||||||
ournodes.add(node); /* Add it to our node list */
|
ournodes.add(node); /* Add it to our node list */
|
||||||
minx = nodex; minz = nodez;
|
minx = nodex;
|
||||||
|
minz = nodez;
|
||||||
}
|
}
|
||||||
/* If shape found, and we're in it, add to our node list */
|
/* If shape found, and we're in it, add to our node list */
|
||||||
else if ((ourblks != null) && ourblks.getFlag(nodex, nodez)) {
|
else if ((ourblks != null) && ourblks.getFlag(nodex, nodez)) {
|
||||||
ournodes.add(node);
|
ournodes.add(node);
|
||||||
if (nodex < minx) {
|
if (nodex < minx) {
|
||||||
minx = nodex; minz = nodez;
|
minx = nodex;
|
||||||
}
|
minz = nodez;
|
||||||
else if((nodex == minx) && (nodez < minz)) {
|
} else if ((nodex == minx) && (nodez < minz)) {
|
||||||
minz = nodez;
|
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);
|
newlist.add(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nodevals = newlist; /* Replace list (null if no more to process) */
|
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+ */
|
/* 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_x = minx;
|
||||||
int cur_z = minz;
|
int cur_z = minz;
|
||||||
direction dir = direction.XPLUS;
|
Direction dir = Direction.XPLUS;
|
||||||
ArrayList<int[]> linelist = new ArrayList<int[]>();
|
ArrayList<int[]> linelist = new ArrayList<>();
|
||||||
linelist.add(new int[] { init_x, init_z } ); // Add start point
|
linelist.add(new int[]{minx, minz}); // Add start point
|
||||||
while((cur_x != init_x) || (cur_z != init_z) || (dir != direction.ZMINUS)) {
|
while ((cur_x != minx) || (cur_z != minz) || (dir != Direction.ZMINUS)) {
|
||||||
switch (dir) {
|
switch (dir) {
|
||||||
case XPLUS: /* Segment in X+ direction */
|
case XPLUS: /* Segment in X+ direction */
|
||||||
if (!ourblks.getFlag(cur_x + 1, cur_z)) { /* Right turn? */
|
if (!ourblks.getFlag(cur_x + 1, cur_z)) { /* Right turn? */
|
||||||
linelist.add(new int[]{cur_x + 1, cur_z}); /* Finish line */
|
linelist.add(new int[]{cur_x + 1, cur_z}); /* Finish line */
|
||||||
dir = direction.ZPLUS; /* Change direction */
|
dir = Direction.ZPLUS; /* Change direction */
|
||||||
}
|
} else if (!ourblks.getFlag(cur_x + 1, cur_z - 1)) { /* Straight? */
|
||||||
else if(!ourblks.getFlag(cur_x+1, cur_z-1)) { /* Straight? */
|
|
||||||
cur_x++;
|
cur_x++;
|
||||||
}
|
} else { /* Left turn */
|
||||||
else { /* Left turn */
|
|
||||||
linelist.add(new int[]{cur_x + 1, cur_z}); /* Finish line */
|
linelist.add(new int[]{cur_x + 1, cur_z}); /* Finish line */
|
||||||
dir = direction.ZMINUS;
|
dir = Direction.ZMINUS;
|
||||||
cur_x++; cur_z--;
|
cur_x++;
|
||||||
|
cur_z--;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ZPLUS: /* Segment in Z+ direction */
|
case ZPLUS: /* Segment in Z+ direction */
|
||||||
if (!ourblks.getFlag(cur_x, cur_z + 1)) { /* Right turn? */
|
if (!ourblks.getFlag(cur_x, cur_z + 1)) { /* Right turn? */
|
||||||
linelist.add(new int[]{cur_x + 1, cur_z + 1}); /* Finish line */
|
linelist.add(new int[]{cur_x + 1, cur_z + 1}); /* Finish line */
|
||||||
dir = direction.XMINUS; /* Change direction */
|
dir = Direction.XMINUS; /* Change direction */
|
||||||
}
|
} else if (!ourblks.getFlag(cur_x + 1, cur_z + 1)) { /* Straight? */
|
||||||
else if(!ourblks.getFlag(cur_x+1, cur_z+1)) { /* Straight? */
|
|
||||||
cur_z++;
|
cur_z++;
|
||||||
}
|
} else { /* Left turn */
|
||||||
else { /* Left turn */
|
|
||||||
linelist.add(new int[]{cur_x + 1, cur_z + 1}); /* Finish line */
|
linelist.add(new int[]{cur_x + 1, cur_z + 1}); /* Finish line */
|
||||||
dir = direction.XPLUS;
|
dir = Direction.XPLUS;
|
||||||
cur_x++; cur_z++;
|
cur_x++;
|
||||||
|
cur_z++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case XMINUS: /* Segment in X- direction */
|
case XMINUS: /* Segment in X- direction */
|
||||||
if (!ourblks.getFlag(cur_x - 1, cur_z)) { /* Right turn? */
|
if (!ourblks.getFlag(cur_x - 1, cur_z)) { /* Right turn? */
|
||||||
linelist.add(new int[]{cur_x, cur_z + 1}); /* Finish line */
|
linelist.add(new int[]{cur_x, cur_z + 1}); /* Finish line */
|
||||||
dir = direction.ZMINUS; /* Change direction */
|
dir = Direction.ZMINUS; /* Change direction */
|
||||||
}
|
} else if (!ourblks.getFlag(cur_x - 1, cur_z + 1)) { /* Straight? */
|
||||||
else if(!ourblks.getFlag(cur_x-1, cur_z+1)) { /* Straight? */
|
|
||||||
cur_x--;
|
cur_x--;
|
||||||
}
|
} else { /* Left turn */
|
||||||
else { /* Left turn */
|
|
||||||
linelist.add(new int[]{cur_x, cur_z + 1}); /* Finish line */
|
linelist.add(new int[]{cur_x, cur_z + 1}); /* Finish line */
|
||||||
dir = direction.ZPLUS;
|
dir = Direction.ZPLUS;
|
||||||
cur_x--; cur_z++;
|
cur_x--;
|
||||||
|
cur_z++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ZMINUS: /* Segment in Z- direction */
|
case ZMINUS: /* Segment in Z- direction */
|
||||||
if (!ourblks.getFlag(cur_x, cur_z - 1)) { /* Right turn? */
|
if (!ourblks.getFlag(cur_x, cur_z - 1)) { /* Right turn? */
|
||||||
linelist.add(new int[]{cur_x, cur_z}); /* Finish line */
|
linelist.add(new int[]{cur_x, cur_z}); /* Finish line */
|
||||||
dir = direction.XPLUS; /* Change direction */
|
dir = Direction.XPLUS; /* Change direction */
|
||||||
}
|
} else if (!ourblks.getFlag(cur_x - 1, cur_z - 1)) { /* Straight? */
|
||||||
else if(!ourblks.getFlag(cur_x-1, cur_z-1)) { /* Straight? */
|
|
||||||
cur_z--;
|
cur_z--;
|
||||||
}
|
} else { /* Left turn */
|
||||||
else { /* Left turn */
|
|
||||||
linelist.add(new int[]{cur_x, cur_z}); /* Finish line */
|
linelist.add(new int[]{cur_x, cur_z}); /* Finish line */
|
||||||
dir = direction.XMINUS;
|
dir = Direction.XMINUS;
|
||||||
cur_x--; cur_z--;
|
cur_x--;
|
||||||
|
cur_z--;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -443,8 +349,7 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
info("error adding area marker " + polyid);
|
info("error adding area marker " + polyid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
m.setCornerLocations(x, z); /* Replace corner locations */
|
m.setCornerLocations(x, z); /* Replace corner locations */
|
||||||
m.setLabel(factname); /* Update label */
|
m.setLabel(factname); /* Update label */
|
||||||
}
|
}
|
||||||
@ -462,12 +367,12 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Update Factions information */
|
/* Update Factions information */
|
||||||
private void updateFactions() {
|
void updateFactions() {
|
||||||
Map<String,AreaMarker> newmap = new HashMap<String,AreaMarker>(); /* Build new map */
|
Map<String, AreaMarker> newmap = new HashMap<>(); /* Build new map */
|
||||||
Map<String,Marker> newmark = new HashMap<String,Marker>(); /* Build new map */
|
Map<String, Marker> newmark = new HashMap<>(); /* Build new map */
|
||||||
|
|
||||||
/* Parse into faction centric mapping, split by world */
|
/* 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();
|
FactionColl fc = FactionColl.get();
|
||||||
Collection<Faction> facts = fc.getAll();
|
Collection<Faction> facts = fc.getAll();
|
||||||
@ -484,14 +389,8 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
String world = cc.getWorld();
|
String world = cc.getWorld();
|
||||||
|
|
||||||
/* Get block set for given world */
|
/* Get block set for given world */
|
||||||
LinkedList<FactionBlock> blocks = factblocks.blocks.get(world);
|
LinkedList<FactionBlock> blocks = factblocks.blocks.computeIfAbsent(world, k -> new LinkedList<>());
|
||||||
if(blocks == null) {
|
FactionBlock fb = new FactionBlock(cc.getChunkX(), cc.getChunkZ());
|
||||||
blocks = new LinkedList<FactionBlock>();
|
|
||||||
factblocks.blocks.put(world, blocks);
|
|
||||||
}
|
|
||||||
FactionBlock fb = new FactionBlock();
|
|
||||||
fb.x = cc.getChunkX();
|
|
||||||
fb.z = cc.getChunkZ();
|
|
||||||
blocks.add(fb); /* Add to list */
|
blocks.add(fb); /* Add to list */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -500,7 +399,9 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
String factname = ChatColor.stripColor(fact.getName());
|
String factname = ChatColor.stripColor(fact.getName());
|
||||||
String fid = fc.getUniverse() + "_" + fact.getId();
|
String fid = fc.getUniverse() + "_" + fact.getId();
|
||||||
FactionBlocks factblocks = blocks_by_faction.get(fid); /* Look up faction */
|
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 */
|
/* 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()) {
|
||||||
@ -509,25 +410,34 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
factblocks.blocks.clear();
|
factblocks.blocks.clear();
|
||||||
|
|
||||||
/* Now, add marker for home location */
|
/* Now, add marker for home location */
|
||||||
PS homeloc = fact.getHome();
|
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) {
|
if (homeloc != null) {
|
||||||
String markid = fc.getUniverse() + "_" + factname + "__home";
|
String markid = fc.getUniverse() + "_" + factname + "__home";
|
||||||
MarkerIcon ico = getMarkerIcon(factname, fact);
|
MarkerIcon ico = getMarkerIcon(factname, fact);
|
||||||
if (ico != null) {
|
if (ico != null) {
|
||||||
Marker home = resmark.remove(markid);
|
Marker homeMarker = resmark.remove(markid);
|
||||||
String lbl = factname + " [home]";
|
String lbl = factname + " [home]";
|
||||||
if(home == null) {
|
if (homeMarker == null) {
|
||||||
home = set.createMarker(markid, lbl, homeloc.getWorld(),
|
homeMarker = set.createMarker(markid, lbl, homeloc.getWorld(),
|
||||||
homeloc.getLocationX(), homeloc.getLocationY(), homeloc.getLocationZ(), ico, false);
|
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 {
|
if (homeMarker != null) {
|
||||||
home.setLocation(homeloc.getWorld(), homeloc.getLocationX(), homeloc.getLocationY(), homeloc.getLocationZ());
|
homeMarker.setDescription(formatInfoWindow(fact)); /* Set popup */
|
||||||
home.setLabel(lbl); /* Update label */
|
newmark.put(markid, homeMarker);
|
||||||
home.setMarkerIcon(ico);
|
|
||||||
}
|
|
||||||
if (home != null) {
|
|
||||||
home.setDescription(formatInfoWindow(fact)); /* Set popup */
|
|
||||||
newmark.put(markid, home);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -559,64 +469,8 @@ 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() {
|
public void onEnable() {
|
||||||
|
instance = this;
|
||||||
info("initializing");
|
info("initializing");
|
||||||
PluginManager pm = getServer().getPluginManager();
|
PluginManager pm = getServer().getPluginManager();
|
||||||
/* Get dynmap */
|
/* Get dynmap */
|
||||||
@ -635,19 +489,20 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
factions = p;
|
factions = p;
|
||||||
|
|
||||||
/* If both enabled, activate */
|
/* If both enabled, activate */
|
||||||
if(dynmap.isEnabled() && factions.isEnabled())
|
if (dynmap.isEnabled() && factions.isEnabled()) {
|
||||||
activate();
|
activate();
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MetricsLite ml = new MetricsLite(this);
|
MetricsLite ml = new MetricsLite(this);
|
||||||
ml.start();
|
ml.start();
|
||||||
} catch (IOException iox) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean reload = false;
|
private boolean reload = false;
|
||||||
|
|
||||||
private void activate() {
|
void activate() {
|
||||||
markerapi = api.getMarkerAPI();
|
markerapi = api.getMarkerAPI();
|
||||||
if (markerapi == null) {
|
if (markerapi == null) {
|
||||||
severe("Error loading dynmap marker API!");
|
severe("Error loading dynmap marker API!");
|
||||||
@ -665,8 +520,7 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
set.deleteMarkerSet();
|
set.deleteMarkerSet();
|
||||||
set = null;
|
set = null;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
reload = true;
|
reload = true;
|
||||||
}
|
}
|
||||||
FileConfiguration cfg = getConfig();
|
FileConfiguration cfg = getConfig();
|
||||||
@ -675,10 +529,11 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
/* Now, add marker set for mobs (make it transient) */
|
/* Now, add marker set for mobs (make it transient) */
|
||||||
set = markerapi.getMarkerSet("factions.markerset");
|
set = markerapi.getMarkerSet("factions.markerset");
|
||||||
if(set == null)
|
if (set == null) {
|
||||||
set = markerapi.createMarkerSet("factions.markerset", cfg.getString("layer.name", "Factions"), null, false);
|
set = markerapi.createMarkerSet("factions.markerset", cfg.getString("layer.name", "Factions"), null, false);
|
||||||
else
|
} else {
|
||||||
set.setMarkerSetLabel(cfg.getString("layer.name", "Factions"));
|
set.setMarkerSetLabel(cfg.getString("layer.name", "Factions"));
|
||||||
|
}
|
||||||
if (set == null) {
|
if (set == null) {
|
||||||
severe("Error creating marker set");
|
severe("Error creating marker set");
|
||||||
return;
|
return;
|
||||||
@ -688,31 +543,32 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
resmark.clear();
|
resmark.clear();
|
||||||
|
|
||||||
int minzoom = cfg.getInt("layer.minzoom", 0);
|
int minzoom = cfg.getInt("layer.minzoom", 0);
|
||||||
if(minzoom > 0)
|
if (minzoom > 0) {
|
||||||
set.setMinZoom(minzoom);
|
set.setMinZoom(minzoom);
|
||||||
|
}
|
||||||
set.setLayerPriority(cfg.getInt("layer.layerprio", 10));
|
set.setLayerPriority(cfg.getInt("layer.layerprio", 10));
|
||||||
set.setHideByDefault(cfg.getBoolean("layer.hidebydefault", false));
|
set.setHideByDefault(cfg.getBoolean("layer.hidebydefault", false));
|
||||||
use3d = cfg.getBoolean("use3dregions", false);
|
use3d = cfg.getBoolean("use3dregions", false);
|
||||||
infowindow = cfg.getString("infowindow", DEF_INFOWINDOW);
|
infowindow = cfg.getString("infowindow", DEF_INFOWINDOW);
|
||||||
|
|
||||||
/* Get style information */
|
/* Get style information */
|
||||||
defstyle = new AreaStyle(cfg, "regionstyle");
|
defstyle = new AreaStyle(this, cfg, "regionstyle");
|
||||||
cusstyle = new HashMap<String, AreaStyle>();
|
cusstyle = new HashMap<>();
|
||||||
ConfigurationSection sect = cfg.getConfigurationSection("custstyle");
|
ConfigurationSection sect = cfg.getConfigurationSection("custstyle");
|
||||||
if (sect != null) {
|
if (sect != null) {
|
||||||
Set<String> ids = sect.getKeys(false);
|
Set<String> ids = sect.getKeys(false);
|
||||||
|
|
||||||
for (String id : ids) {
|
for (String id : ids) {
|
||||||
cusstyle.put(id, new AreaStyle(cfg, "custstyle." + id, defstyle));
|
cusstyle.put(id, new AreaStyle(this, cfg, "custstyle." + id, defstyle));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<String> vis = cfg.getStringList("visibleregions");
|
List<String> vis = cfg.getStringList("visibleregions");
|
||||||
if (vis != null) {
|
if (vis != null) {
|
||||||
visible = new HashSet<String>(vis);
|
visible = new HashSet<>(vis);
|
||||||
}
|
}
|
||||||
List<String> hid = cfg.getStringList("hiddenregions");
|
List<String> hid = cfg.getStringList("hiddenregions");
|
||||||
if (hid != null) {
|
if (hid != null) {
|
||||||
hidden = new HashSet<String>(hid);
|
hidden = new HashSet<>(hid);
|
||||||
}
|
}
|
||||||
/* Chec if player sets enabled */
|
/* Chec if player sets enabled */
|
||||||
playersets = cfg.getBoolean("visibility-by-faction", false);
|
playersets = cfg.getBoolean("visibility-by-faction", false);
|
||||||
@ -731,12 +587,14 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
/* Set up update job - based on periond */
|
/* Set up update job - based on periond */
|
||||||
int per = cfg.getInt("update.period", 300);
|
int per = cfg.getInt("update.period", 300);
|
||||||
if(per < 15) per = 15;
|
if (per < 15) {
|
||||||
updperiod = (per*20);
|
per = 15;
|
||||||
|
}
|
||||||
|
updperiod = (per * 20L);
|
||||||
stop = false;
|
stop = false;
|
||||||
|
|
||||||
getServer().getScheduler().scheduleSyncDelayedTask(this, new FactionsUpdate(), 40); /* First time is 2 seconds */
|
getServer().getScheduler().scheduleSyncDelayedTask(this, new FactionsUpdate(this), 40); /* First time is 2 seconds */
|
||||||
getServer().getPluginManager().registerEvents(new OurServerListener(), this);
|
getServer().getPluginManager().registerEvents(new OurServerListener(this), this);
|
||||||
|
|
||||||
info("version " + this.getDescription().getVersion() + " is activated");
|
info("version " + this.getDescription().getVersion() + " is activated");
|
||||||
}
|
}
|
||||||
|
4
src/main/java/org/dynmap/factions/FactionBlock.java
Normal file
4
src/main/java/org/dynmap/factions/FactionBlock.java
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
package org.dynmap.factions;
|
||||||
|
|
||||||
|
public record FactionBlock(int x, int z) {
|
||||||
|
}
|
11
src/main/java/org/dynmap/factions/FactionBlocks.java
Normal file
11
src/main/java/org/dynmap/factions/FactionBlocks.java
Normal 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<>();
|
||||||
|
|
||||||
|
}
|
26
src/main/java/org/dynmap/factions/FactionsUpdate.java
Normal file
26
src/main/java/org/dynmap/factions/FactionsUpdate.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -45,6 +45,7 @@ import java.net.Proxy;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@ -197,12 +198,7 @@ public class MetricsLite {
|
|||||||
try {
|
try {
|
||||||
// Reload the metrics file
|
// Reload the metrics file
|
||||||
configuration.load(getConfigFile());
|
configuration.load(getConfigFile());
|
||||||
} catch (IOException ex) {
|
} catch (IOException | InvalidConfigurationException ex) {
|
||||||
if (debug) {
|
|
||||||
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} catch (InvalidConfigurationException ex) {
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
|
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
|
||||||
}
|
}
|
||||||
@ -381,7 +377,7 @@ public class MetricsLite {
|
|||||||
* @param key the key value
|
* @param key the key value
|
||||||
* @param value the 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));
|
buffer.append('&').append(encode(key)).append('=').append(encode(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,8 +387,8 @@ public class MetricsLite {
|
|||||||
* @param text the text to encode
|
* @param text the text to encode
|
||||||
* @return the encoded text, as UTF-8
|
* @return the encoded text, as UTF-8
|
||||||
*/
|
*/
|
||||||
private static String encode(final String text) throws UnsupportedEncodingException {
|
private static String encode(final String text) {
|
||||||
return URLEncoder.encode(text, "UTF-8");
|
return URLEncoder.encode(text, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
111
src/main/java/org/dynmap/factions/OurServerListener.java
Normal file
111
src/main/java/org/dynmap/factions/OurServerListener.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
17
src/main/java/org/dynmap/factions/PlayerSetUpdate.java
Normal file
17
src/main/java/org/dynmap/factions/PlayerSetUpdate.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,17 @@
|
|||||||
package org.dynmap.factions;
|
package org.dynmap.factions;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* scalable flags primitive - used for keeping track of potentially huge number of tiles
|
* 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
|
* 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
|
* 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).
|
* computed by ((x/64)<<32)+(y/64).
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class TileFlags {
|
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_key = Long.MAX_VALUE;
|
||||||
private long[] last_row;
|
private long[] last_row;
|
||||||
|
|
||||||
@ -23,44 +23,44 @@ public class TileFlags {
|
|||||||
long[] row;
|
long[] row;
|
||||||
if (k == last_key) {
|
if (k == last_key) {
|
||||||
row = last_row;
|
row = last_row;
|
||||||
}
|
} else {
|
||||||
else {
|
row = chunkMap.get(k);
|
||||||
row = chunkmap.get(k);
|
|
||||||
last_key = k;
|
last_key = k;
|
||||||
last_row = row;
|
last_row = row;
|
||||||
}
|
}
|
||||||
if(row == null)
|
if (row == null) {
|
||||||
return false;
|
return false;
|
||||||
else
|
} else {
|
||||||
return (row[y & 0x3F] & (1L << (x & 0x3F))) != 0;
|
return (row[y & 0x3F] & (1L << (x & 0x3F))) != 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setFlag(int x, int y, boolean f) {
|
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;
|
long[] row;
|
||||||
if (k == last_key) {
|
if (k == last_key) {
|
||||||
row = last_row;
|
row = last_row;
|
||||||
}
|
} else {
|
||||||
else {
|
row = chunkMap.get(k);
|
||||||
row = chunkmap.get(k);
|
|
||||||
last_key = k;
|
last_key = k;
|
||||||
last_row = row;
|
last_row = row;
|
||||||
}
|
}
|
||||||
if (f) {
|
if (f) {
|
||||||
if (row == null) {
|
if (row == null) {
|
||||||
row = new long[64];
|
row = new long[64];
|
||||||
chunkmap.put(k, row);
|
chunkMap.put(k, row);
|
||||||
last_row = row;
|
last_row = row;
|
||||||
}
|
}
|
||||||
row[y & 0x3F] |= (1L << (x & 0x3F));
|
row[y & 0x3F] |= (1L << (x & 0x3F));
|
||||||
}
|
} else {
|
||||||
else {
|
if (row != null) {
|
||||||
if(row != null)
|
|
||||||
row[y & 0x3F] &= ~(1L << (x & 0x3F));
|
row[y & 0x3F] &= ~(1L << (x & 0x3F));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
chunkmap.clear();
|
chunkMap.clear();
|
||||||
last_row = null;
|
last_row = null;
|
||||||
last_key = Long.MAX_VALUE;
|
last_key = Long.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user