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

4
.gitignore vendored
View File

@ -22,4 +22,6 @@
/manifest.mf
# Mac filesystem dust
/.DS_Store
/.DS_Store
*.iml

Binary file not shown.

Binary file not shown.

169
pom.xml
View File

@ -1,90 +1,83 @@
<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>
<properties>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyyMMddHHmm</maven.build.timestamp.format>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<BUILD_NUMBER>Dev${timestamp}</BUILD_NUMBER>
</properties>
<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.92</version>
<properties>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyyMMddHHmm</maven.build.timestamp.format>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<BUILD_NUMBER>Dev${timestamp}</BUILD_NUMBER>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>*.yml</include>
<include>*.txt</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>*.yml</exclude>
<exclude>*.txt</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<releases>
</releases>
<snapshots>
</snapshots>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/repositories/releases/</url>
</repository>
<repository>
<releases>
</releases>
<snapshots>
</snapshots>
<id>dynmap-repo</id>
<url>http://repo.mikeprimm.com/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.dynmap</groupId>
<artifactId>dynmap-api</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.7.10-R0.1-SNAPSHOT</version>
</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>
</dependency>
<dependency>
<groupId>com.massivecraft</groupId>
<artifactId>MassiveCore</artifactId>
<version>2.7.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/MassiveCore-2.7.1.jar</systemPath>
</dependency>
</dependencies>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>*.yml</include>
<include>*.txt</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>*.yml</exclude>
<exclude>*.txt</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>16</source>
<target>16</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>dynmap</id>
<url>https://repo.mikeprimm.com/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>us.dynmap</groupId>
<artifactId>dynmap-api</artifactId>
<version>3.6-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<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>3.3.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.massivecraft.massivecore</groupId>
<artifactId>MassiveCore</artifactId>
<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
}

File diff suppressed because it is too large Load Diff

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());
}
@ -378,10 +374,10 @@ public class MetricsLite {
* </code>
*
* @param buffer the stringbuilder to append the data pair onto
* @param key the key value
* @param value the value
* @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,67 +1,67 @@
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 long last_key = Long.MAX_VALUE;
private long[] last_row;
public TileFlags() {
}
public boolean getFlag(int x, int y) {
long k = (((long)(x >> 6)) << 32) | (0xFFFFFFFFL & (long)(y >> 6));
long[] row;
if(k == last_key) {
row = last_row;
}
else {
row = chunkmap.get(k);
last_key = k;
last_row = row;
}
if(row == null)
return false;
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[] row;
if(k == last_key) {
row = last_row;
}
else {
row = chunkmap.get(k);
last_key = k;
last_row = row;
}
if(f) {
if(row == null) {
row = new long[64];
chunkmap.put(k, row);
last_row = row;
}
row[y & 0x3F] |= (1L << (x & 0x3F));
}
else {
if(row != null)
row[y & 0x3F] &= ~(1L << (x & 0x3F));
}
}
public void clear() {
chunkmap.clear();
last_row = null;
last_key = Long.MAX_VALUE;
}
private final Map<Long, long[]> chunkMap = new HashMap<>();
private long last_key = Long.MAX_VALUE;
private long[] last_row;
public TileFlags() {
}
public boolean getFlag(int x, int y) {
long k = (((long) (x >> 6)) << 32) | (0xFFFFFFFFL & (long) (y >> 6));
long[] row;
if (k == last_key) {
row = last_row;
} else {
row = chunkMap.get(k);
last_key = k;
last_row = row;
}
if (row == null) {
return false;
} 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[] row;
if (k == last_key) {
row = last_row;
} else {
row = chunkMap.get(k);
last_key = k;
last_row = row;
}
if (f) {
if (row == null) {
row = new long[64];
chunkMap.put(k, row);
last_row = row;
}
row[y & 0x3F] |= (1L << (x & 0x3F));
} else {
if (row != null) {
row[y & 0x3F] &= ~(1L << (x & 0x3F));
}
}
}
public void clear() {
chunkMap.clear();
last_row = null;
last_key = Long.MAX_VALUE;
}
}

View File

@ -12,7 +12,7 @@ layer:
layerprio: 2
# (optional) set minimum zoom level before layer is visible (0 = defalt, always visible)
minzoom: 0
# Format for popup - substitute values for macros
infowindow: '<div class="infowindow"><span style="font-size:120%;">%regionname%</span><br />Flags<br /><span style="font-weight:bold;">%flags%</span></div>'
@ -27,15 +27,15 @@ regionstyle:
fillOpacity: 0.35
homeicon: "redflag"
boost: false
# Optional setting to limit which regions to show, by name - if commented out, all regions are shown
# To show all regions on a given world, add 'world:<worldname>' to the list
visibleregions: [ ]
# Optional setting to hide specific regions, by name
# To hide all regions on a given world, add 'world:<worldname>' to the list
hiddenregions: [ ]
# Optional per-region overrides for regionstyle (any defined replace those in regionstyle)
custstyle:
SafeZone: