Moves classes to packages
This commit is contained in:
		@@ -9,6 +9,10 @@ import org.bukkit.plugin.Plugin;
 | 
				
			|||||||
import org.bukkit.plugin.PluginManager;
 | 
					import org.bukkit.plugin.PluginManager;
 | 
				
			||||||
import org.bukkit.plugin.java.JavaPlugin;
 | 
					import org.bukkit.plugin.java.JavaPlugin;
 | 
				
			||||||
import org.dynmap.DynmapAPI;
 | 
					import org.dynmap.DynmapAPI;
 | 
				
			||||||
 | 
					import org.dynmap.factions.config.AreaStyle;
 | 
				
			||||||
 | 
					import org.dynmap.factions.listener.DynmapFactionsListener;
 | 
				
			||||||
 | 
					import org.dynmap.factions.runnable.FactionsUpdate;
 | 
				
			||||||
 | 
					import org.dynmap.factions.runnable.PlayerSetUpdate;
 | 
				
			||||||
import org.dynmap.markers.AreaMarker;
 | 
					import org.dynmap.markers.AreaMarker;
 | 
				
			||||||
import org.dynmap.markers.Marker;
 | 
					import org.dynmap.markers.Marker;
 | 
				
			||||||
import org.dynmap.markers.MarkerAPI;
 | 
					import org.dynmap.markers.MarkerAPI;
 | 
				
			||||||
@@ -27,28 +31,94 @@ import java.util.logging.Logger;
 | 
				
			|||||||
public class DynmapFactionsPlugin extends JavaPlugin {
 | 
					public class DynmapFactionsPlugin extends JavaPlugin {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static Logger log;
 | 
					    private static Logger log;
 | 
				
			||||||
    Plugin dynmap;
 | 
					 | 
				
			||||||
    DynmapAPI api;
 | 
					 | 
				
			||||||
    MarkerAPI markerAPI;
 | 
					 | 
				
			||||||
    Plugin factions;
 | 
					 | 
				
			||||||
    boolean playerSets;
 | 
					 | 
				
			||||||
    Map<String, AreaMarker> factionAreaMarkers = new HashMap<>();
 | 
					 | 
				
			||||||
    Map<String, Marker> factionMarkers = new HashMap<>();
 | 
					 | 
				
			||||||
    AreaStyle defaultStyle;
 | 
					 | 
				
			||||||
    Map<String, AreaStyle> customStyle;
 | 
					 | 
				
			||||||
    int blockSize;
 | 
					 | 
				
			||||||
    MarkerSet set;
 | 
					 | 
				
			||||||
    long updatePeriod;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Set<String> visible;
 | 
					    private DynmapAPI api;
 | 
				
			||||||
    Set<String> hidden;
 | 
					    private MarkerAPI markerAPI;
 | 
				
			||||||
    boolean stop;
 | 
					    private boolean playerSets;
 | 
				
			||||||
    static DynmapFactionsPlugin instance;
 | 
					
 | 
				
			||||||
 | 
					    private Map<String, AreaMarker> factionAreaMarkers = new HashMap<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private Map<String, Marker> factionMarkers = new HashMap<>();
 | 
				
			||||||
 | 
					    private AreaStyle defaultStyle;
 | 
				
			||||||
 | 
					    private Map<String, AreaStyle> customStyle;
 | 
				
			||||||
 | 
					    private int blockSize;
 | 
				
			||||||
 | 
					    private MarkerSet set;
 | 
				
			||||||
 | 
					    private long updatePeriod;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private Set<String> visible;
 | 
				
			||||||
 | 
					    private Set<String> hidden;
 | 
				
			||||||
 | 
					    private boolean stop;
 | 
				
			||||||
 | 
					    private static DynmapFactionsPlugin instance;
 | 
				
			||||||
    private boolean reload = false;
 | 
					    private boolean reload = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    public void setFactionMarkers(Map<String, Marker> factionMarkers) {
 | 
				
			||||||
    public void onLoad() {
 | 
					        this.factionMarkers = factionMarkers;
 | 
				
			||||||
        log = this.getLogger();
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setFactionAreaMarkers(Map<String, AreaMarker> factionAreaMarkers) {
 | 
				
			||||||
 | 
					        this.factionAreaMarkers = factionAreaMarkers;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setPending(FactionsUpdate pending) {
 | 
				
			||||||
 | 
					        this.pending = pending;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private FactionsUpdate pending = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public MarkerAPI getMarkerAPI() {
 | 
				
			||||||
 | 
					        return markerAPI;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public boolean isPlayerSets() {
 | 
				
			||||||
 | 
					        return playerSets;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public Map<String, AreaMarker> getFactionAreaMarkers() {
 | 
				
			||||||
 | 
					        return factionAreaMarkers;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public Map<String, Marker> getFactionMarkers() {
 | 
				
			||||||
 | 
					        return factionMarkers;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public AreaStyle getDefaultStyle() {
 | 
				
			||||||
 | 
					        return defaultStyle;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public Map<String, AreaStyle> getCustomStyle() {
 | 
				
			||||||
 | 
					        return customStyle;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public int getBlockSize() {
 | 
				
			||||||
 | 
					        return blockSize;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public MarkerSet getSet() {
 | 
				
			||||||
 | 
					        return set;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public long getUpdatePeriod() {
 | 
				
			||||||
 | 
					        return updatePeriod;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public Set<String> getVisible() {
 | 
				
			||||||
 | 
					        return visible;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public Set<String> getHidden() {
 | 
				
			||||||
 | 
					        return hidden;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public boolean isStop() {
 | 
				
			||||||
 | 
					        return stop;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static DynmapFactionsPlugin getInstance() {
 | 
				
			||||||
 | 
					        return instance;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public FactionsUpdate getPending() {
 | 
				
			||||||
 | 
					        return pending;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -64,15 +134,13 @@ public class DynmapFactionsPlugin extends JavaPlugin {
 | 
				
			|||||||
        log.log(Level.SEVERE, msg);
 | 
					        log.log(Level.SEVERE, msg);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void requestUpdatePlayerSet(String factionId) {
 | 
					    public void requestUpdatePlayerSet(String factionId) {
 | 
				
			||||||
        if (playerSets) {
 | 
					        if (playerSets) {
 | 
				
			||||||
            getServer().getScheduler().scheduleSyncDelayedTask(this, new PlayerSetUpdate(this, factionId));
 | 
					            getServer().getScheduler().scheduleSyncDelayedTask(this, new PlayerSetUpdate(this, factionId));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    FactionsUpdate pending = null;
 | 
					    public void updatePlayerSet(String factionId) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
    void updatePlayerSet(String factionId) {
 | 
					 | 
				
			||||||
        /* If Wilderness or other unassociated factions (guid-style ID), skip */
 | 
					        /* If Wilderness or other unassociated factions (guid-style ID), skip */
 | 
				
			||||||
        if (factionId.indexOf('-') >= 0) {
 | 
					        if (factionId.indexOf('-') >= 0) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
@@ -102,6 +170,45 @@ public class DynmapFactionsPlugin extends JavaPlugin {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onLoad() {
 | 
				
			||||||
 | 
					        log = this.getLogger();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onEnable() {
 | 
				
			||||||
 | 
					        instance = this;
 | 
				
			||||||
 | 
					        info("initializing");
 | 
				
			||||||
 | 
					        PluginManager pm = getServer().getPluginManager();
 | 
				
			||||||
 | 
					        /* Get dynmap */
 | 
				
			||||||
 | 
					        Plugin dynmap = pm.getPlugin("dynmap");
 | 
				
			||||||
 | 
					        if (dynmap == null) {
 | 
				
			||||||
 | 
					            severe("Cannot find dynmap!");
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        api = (DynmapAPI) dynmap; /* Get API */
 | 
				
			||||||
 | 
					        /* Get Factions */
 | 
				
			||||||
 | 
					        Plugin p = pm.getPlugin("Factions");
 | 
				
			||||||
 | 
					        if (p == null) {
 | 
				
			||||||
 | 
					            severe("Cannot find Factions!");
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* If both enabled, activate */
 | 
				
			||||||
 | 
					        if (dynmap.isEnabled() && p.isEnabled()) {
 | 
				
			||||||
 | 
					            activate();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onDisable() {
 | 
				
			||||||
 | 
					        if (set != null) {
 | 
				
			||||||
 | 
					            set.deleteMarkerSet();
 | 
				
			||||||
 | 
					            set = null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        factionAreaMarkers.clear();
 | 
				
			||||||
 | 
					        stop = true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void updatePlayerSets() {
 | 
					    private void updatePlayerSets() {
 | 
				
			||||||
        if (playerSets) {
 | 
					        if (playerSets) {
 | 
				
			||||||
@@ -115,32 +222,7 @@ public class DynmapFactionsPlugin extends JavaPlugin {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void onEnable() {
 | 
					    private void activate() {
 | 
				
			||||||
        instance = this;
 | 
					 | 
				
			||||||
        info("initializing");
 | 
					 | 
				
			||||||
        PluginManager pm = getServer().getPluginManager();
 | 
					 | 
				
			||||||
        /* Get dynmap */
 | 
					 | 
				
			||||||
        dynmap = pm.getPlugin("dynmap");
 | 
					 | 
				
			||||||
        if (dynmap == null) {
 | 
					 | 
				
			||||||
            severe("Cannot find dynmap!");
 | 
					 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        api = (DynmapAPI) dynmap; /* Get API */
 | 
					 | 
				
			||||||
        /* Get Factions */
 | 
					 | 
				
			||||||
        Plugin p = pm.getPlugin("Factions");
 | 
					 | 
				
			||||||
        if (p == null) {
 | 
					 | 
				
			||||||
            severe("Cannot find Factions!");
 | 
					 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        factions = p;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        /* If both enabled, activate */
 | 
					 | 
				
			||||||
        if (dynmap.isEnabled() && factions.isEnabled()) {
 | 
					 | 
				
			||||||
            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!");
 | 
				
			||||||
@@ -234,14 +316,4 @@ public class DynmapFactionsPlugin extends JavaPlugin {
 | 
				
			|||||||
        info("version " + this.getDescription().getVersion() + " is activated");
 | 
					        info("version " + this.getDescription().getVersion() + " is activated");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					 | 
				
			||||||
    public void onDisable() {
 | 
					 | 
				
			||||||
        if (set != null) {
 | 
					 | 
				
			||||||
            set.deleteMarkerSet();
 | 
					 | 
				
			||||||
            set = null;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        factionAreaMarkers.clear();
 | 
					 | 
				
			||||||
        stop = true;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,11 +0,0 @@
 | 
				
			|||||||
package org.dynmap.factions;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.util.HashMap;
 | 
					 | 
				
			||||||
import java.util.List;
 | 
					 | 
				
			||||||
import java.util.Map;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class FactionBlocks {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    final Map<String, List<FactionBlock>> blocks = new HashMap<>();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,6 +1,7 @@
 | 
				
			|||||||
package org.dynmap.factions;
 | 
					package org.dynmap.factions.config;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.bukkit.configuration.file.FileConfiguration;
 | 
					import org.bukkit.configuration.file.FileConfiguration;
 | 
				
			||||||
 | 
					import org.dynmap.factions.DynmapFactionsPlugin;
 | 
				
			||||||
import org.dynmap.markers.MarkerIcon;
 | 
					import org.dynmap.markers.MarkerIcon;
 | 
				
			||||||
import org.jetbrains.annotations.NotNull;
 | 
					import org.jetbrains.annotations.NotNull;
 | 
				
			||||||
import org.jetbrains.annotations.Nullable;
 | 
					import org.jetbrains.annotations.Nullable;
 | 
				
			||||||
@@ -71,10 +72,10 @@ public record AreaStyle(String strokeColor, double strokeOpacity, int strokeWeig
 | 
				
			|||||||
                                          @Nullable String homeMarker) {
 | 
					                                          @Nullable String homeMarker) {
 | 
				
			||||||
        MarkerIcon homeIcon = null;
 | 
					        MarkerIcon homeIcon = null;
 | 
				
			||||||
        if (homeMarker != null) {
 | 
					        if (homeMarker != null) {
 | 
				
			||||||
            homeIcon = dynmapFactionsPlugin.markerAPI.getMarkerIcon(homeMarker);
 | 
					            homeIcon = dynmapFactionsPlugin.getMarkerAPI().getMarkerIcon(homeMarker);
 | 
				
			||||||
            if (homeIcon == null) {
 | 
					            if (homeIcon == null) {
 | 
				
			||||||
                DynmapFactionsPlugin.severe("Invalid home icon: " + homeMarker);
 | 
					                DynmapFactionsPlugin.severe("Invalid home icon: " + homeMarker);
 | 
				
			||||||
                homeIcon = dynmapFactionsPlugin.markerAPI.getMarkerIcon("blueicon");
 | 
					                homeIcon = dynmapFactionsPlugin.getMarkerAPI().getMarkerIcon("blueicon");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return homeIcon;
 | 
					        return homeIcon;
 | 
				
			||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
package org.dynmap.factions;
 | 
					package org.dynmap.factions.container;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public record FactionBlock(int x, int z) {
 | 
					public record FactionBlock(int x, int z) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					package org.dynmap.factions.container;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.HashMap;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public record FactionBlocks(Map<String, List<FactionBlock>> blocks) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public FactionBlocks() {
 | 
				
			||||||
 | 
					        this(new HashMap<>());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
package org.dynmap.factions;
 | 
					package org.dynmap.factions.container;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.HashMap;
 | 
					import java.util.HashMap;
 | 
				
			||||||
import java.util.Map;
 | 
					import java.util.Map;
 | 
				
			||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
package org.dynmap.factions;
 | 
					package org.dynmap.factions.listener;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.massivecraft.factions.entity.Faction;
 | 
					import com.massivecraft.factions.entity.Faction;
 | 
				
			||||||
import com.massivecraft.factions.event.EventFactionsChunksChange;
 | 
					import com.massivecraft.factions.event.EventFactionsChunksChange;
 | 
				
			||||||
@@ -12,8 +12,8 @@ import org.bukkit.Bukkit;
 | 
				
			|||||||
import org.bukkit.event.EventHandler;
 | 
					import org.bukkit.event.EventHandler;
 | 
				
			||||||
import org.bukkit.event.EventPriority;
 | 
					import org.bukkit.event.EventPriority;
 | 
				
			||||||
import org.bukkit.event.Listener;
 | 
					import org.bukkit.event.Listener;
 | 
				
			||||||
import org.bukkit.event.server.PluginEnableEvent;
 | 
					import org.dynmap.factions.DynmapFactionsPlugin;
 | 
				
			||||||
import org.bukkit.plugin.Plugin;
 | 
					import org.dynmap.factions.runnable.FactionsUpdate;
 | 
				
			||||||
import org.jetbrains.annotations.NotNull;
 | 
					import org.jetbrains.annotations.NotNull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class DynmapFactionsListener implements Listener {
 | 
					public class DynmapFactionsListener implements Listener {
 | 
				
			||||||
@@ -24,23 +24,12 @@ public class DynmapFactionsListener implements Listener {
 | 
				
			|||||||
        this.dynmapFactionsPlugin = dynmapFactionsPlugin;
 | 
					        this.dynmapFactionsPlugin = dynmapFactionsPlugin;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @EventHandler
 | 
					 | 
				
			||||||
    public void onPluginEnable(@NotNull 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)
 | 
					    @EventHandler(priority = EventPriority.MONITOR)
 | 
				
			||||||
    public void onFPlayerJoin(@NotNull EventFactionsMembershipChange event) {
 | 
					    public void onFPlayerJoin(@NotNull EventFactionsMembershipChange event) {
 | 
				
			||||||
        if (event.isCancelled()) {
 | 
					        if (event.isCancelled()) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (dynmapFactionsPlugin.playerSets) {
 | 
					        if (dynmapFactionsPlugin.isPlayerSets()) {
 | 
				
			||||||
            Faction f = event.getNewFaction();
 | 
					            Faction f = event.getNewFaction();
 | 
				
			||||||
            dynmapFactionsPlugin.requestUpdatePlayerSet(f.getId());
 | 
					            dynmapFactionsPlugin.requestUpdatePlayerSet(f.getId());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -51,7 +40,7 @@ public class DynmapFactionsListener implements Listener {
 | 
				
			|||||||
        if (event.isCancelled()) {
 | 
					        if (event.isCancelled()) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (dynmapFactionsPlugin.playerSets) {
 | 
					        if (dynmapFactionsPlugin.isPlayerSets()) {
 | 
				
			||||||
            dynmapFactionsPlugin.requestUpdatePlayerSet(event.getFactionId());
 | 
					            dynmapFactionsPlugin.requestUpdatePlayerSet(event.getFactionId());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        requestUpdateFactions();
 | 
					        requestUpdateFactions();
 | 
				
			||||||
@@ -62,7 +51,7 @@ public class DynmapFactionsListener implements Listener {
 | 
				
			|||||||
        if (event.isCancelled()) {
 | 
					        if (event.isCancelled()) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (dynmapFactionsPlugin.playerSets) {
 | 
					        if (dynmapFactionsPlugin.isPlayerSets()) {
 | 
				
			||||||
            Faction f = event.getFaction();
 | 
					            Faction f = event.getFaction();
 | 
				
			||||||
            dynmapFactionsPlugin.requestUpdatePlayerSet(f.getId());
 | 
					            dynmapFactionsPlugin.requestUpdatePlayerSet(f.getId());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -102,12 +91,12 @@ public class DynmapFactionsListener implements Listener {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void requestUpdateFactions() {
 | 
					    private void requestUpdateFactions() {
 | 
				
			||||||
        if (DynmapFactionsPlugin.instance.pending == null) {
 | 
					        if (DynmapFactionsPlugin.getInstance().getPending() == null) {
 | 
				
			||||||
            FactionsUpdate factionsUpdate = new FactionsUpdate(DynmapFactionsPlugin.instance,
 | 
					            FactionsUpdate factionsUpdate = new FactionsUpdate(DynmapFactionsPlugin.getInstance(),
 | 
				
			||||||
                    DynmapFactionsPlugin.instance.getConfig());
 | 
					                    DynmapFactionsPlugin.getInstance().getConfig());
 | 
				
			||||||
            factionsUpdate.runonce = true;
 | 
					            factionsUpdate.runonce = true;
 | 
				
			||||||
            DynmapFactionsPlugin.instance.pending = factionsUpdate;
 | 
					            DynmapFactionsPlugin.getInstance().setPending(factionsUpdate);
 | 
				
			||||||
            Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(DynmapFactionsPlugin.instance, factionsUpdate, 20);
 | 
					            Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(DynmapFactionsPlugin.getInstance(), factionsUpdate, 20);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
package org.dynmap.factions;
 | 
					package org.dynmap.factions.property;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * A representation of the directions that make sense in a Dynmap context
 | 
					 * A representation of the directions that make sense in a Dynmap context
 | 
				
			||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
package org.dynmap.factions;
 | 
					package org.dynmap.factions.runnable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.massivecraft.factions.entity.BoardColl;
 | 
					import com.massivecraft.factions.entity.BoardColl;
 | 
				
			||||||
import com.massivecraft.factions.entity.Faction;
 | 
					import com.massivecraft.factions.entity.Faction;
 | 
				
			||||||
@@ -11,6 +11,12 @@ import com.massivecraft.massivecore.ps.PS;
 | 
				
			|||||||
import com.massivecraft.massivecore.store.EntityInternalMap;
 | 
					import com.massivecraft.massivecore.store.EntityInternalMap;
 | 
				
			||||||
import org.bukkit.ChatColor;
 | 
					import org.bukkit.ChatColor;
 | 
				
			||||||
import org.bukkit.configuration.file.FileConfiguration;
 | 
					import org.bukkit.configuration.file.FileConfiguration;
 | 
				
			||||||
 | 
					import org.dynmap.factions.DynmapFactionsPlugin;
 | 
				
			||||||
 | 
					import org.dynmap.factions.config.AreaStyle;
 | 
				
			||||||
 | 
					import org.dynmap.factions.container.FactionBlock;
 | 
				
			||||||
 | 
					import org.dynmap.factions.container.FactionBlocks;
 | 
				
			||||||
 | 
					import org.dynmap.factions.container.TileFlags;
 | 
				
			||||||
 | 
					import org.dynmap.factions.property.Direction;
 | 
				
			||||||
import org.dynmap.markers.AreaMarker;
 | 
					import org.dynmap.markers.AreaMarker;
 | 
				
			||||||
import org.dynmap.markers.Marker;
 | 
					import org.dynmap.markers.Marker;
 | 
				
			||||||
import org.dynmap.markers.MarkerIcon;
 | 
					import org.dynmap.markers.MarkerIcon;
 | 
				
			||||||
@@ -41,16 +47,16 @@ public class FactionsUpdate implements Runnable {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void run() {
 | 
					    public void run() {
 | 
				
			||||||
        if (dynmapFactionsPlugin.stop) {
 | 
					        if (dynmapFactionsPlugin.isStop()) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        updateFactions();
 | 
					        updateFactions();
 | 
				
			||||||
        if (!runonce) {
 | 
					        if (!runonce) {
 | 
				
			||||||
            dynmapFactionsPlugin.getServer().getScheduler().scheduleSyncDelayedTask(dynmapFactionsPlugin,
 | 
					            dynmapFactionsPlugin.getServer().getScheduler().scheduleSyncDelayedTask(dynmapFactionsPlugin,
 | 
				
			||||||
                    this, dynmapFactionsPlugin.updatePeriod);
 | 
					                    this, dynmapFactionsPlugin.getUpdatePeriod());
 | 
				
			||||||
        } else if (dynmapFactionsPlugin.pending == this) {
 | 
					        } else if (dynmapFactionsPlugin.getPending() == this) {
 | 
				
			||||||
            dynmapFactionsPlugin.pending = null;
 | 
					            dynmapFactionsPlugin.setPending(null);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -78,7 +84,7 @@ public class FactionsUpdate implements Runnable {
 | 
				
			|||||||
                String world = cc.getWorld();
 | 
					                String world = cc.getWorld();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                /* Get block set for given world */
 | 
					                /* Get block set for given world */
 | 
				
			||||||
                List<FactionBlock> blocks = factionBlocks.blocks.computeIfAbsent(world, k -> new LinkedList<>());
 | 
					                List<FactionBlock> blocks = factionBlocks.blocks().computeIfAbsent(world, k -> new LinkedList<>());
 | 
				
			||||||
                FactionBlock fb = new FactionBlock(cc.getChunkX(), cc.getChunkZ());
 | 
					                FactionBlock fb = new FactionBlock(cc.getChunkX(), cc.getChunkZ());
 | 
				
			||||||
                blocks.add(fb); /* Add to list */
 | 
					                blocks.add(fb); /* Add to list */
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -93,10 +99,10 @@ public class FactionsUpdate implements Runnable {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            /* Loop through each world that faction has blocks on */
 | 
					            /* Loop through each world that faction has blocks on */
 | 
				
			||||||
            for (Map.Entry<String, List<FactionBlock>> worldBlocks : factionBLocks.blocks.entrySet()) {
 | 
					            for (Map.Entry<String, List<FactionBlock>> worldBlocks : factionBLocks.blocks().entrySet()) {
 | 
				
			||||||
                handleFactionOnWorld(factionName, faction, worldBlocks.getKey(), worldBlocks.getValue(), newMap);
 | 
					                handleFactionOnWorld(factionName, faction, worldBlocks.getKey(), worldBlocks.getValue(), newMap);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            factionBLocks.blocks.clear();
 | 
					            factionBLocks.blocks().clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            /* Now, add marker for home location */
 | 
					            /* Now, add marker for home location */
 | 
				
			||||||
            EntityInternalMap<Warp> warps = faction.getWarps();
 | 
					            EntityInternalMap<Warp> warps = faction.getWarps();
 | 
				
			||||||
@@ -114,10 +120,10 @@ public class FactionsUpdate implements Runnable {
 | 
				
			|||||||
                String markId = fc.getUniverse() + "_" + factionName + "__home";
 | 
					                String markId = fc.getUniverse() + "_" + factionName + "__home";
 | 
				
			||||||
                MarkerIcon ico = getMarkerIcon(factionName);
 | 
					                MarkerIcon ico = getMarkerIcon(factionName);
 | 
				
			||||||
                if (ico != null) {
 | 
					                if (ico != null) {
 | 
				
			||||||
                    Marker homeMarker = dynmapFactionsPlugin.factionMarkers.remove(markId);
 | 
					                    Marker homeMarker = dynmapFactionsPlugin.getFactionMarkers().remove(markId);
 | 
				
			||||||
                    String lbl = factionName + " [home]";
 | 
					                    String lbl = factionName + " [home]";
 | 
				
			||||||
                    if (homeMarker == null) {
 | 
					                    if (homeMarker == null) {
 | 
				
			||||||
                        homeMarker = dynmapFactionsPlugin.set.createMarker(markId, lbl, homeLocation.getWorld(),
 | 
					                        homeMarker = dynmapFactionsPlugin.getSet().createMarker(markId, lbl, homeLocation.getWorld(),
 | 
				
			||||||
                                homeLocation.getLocationX(), homeLocation.getLocationY(), homeLocation.getLocationZ(), ico, false);
 | 
					                                homeLocation.getLocationX(), homeLocation.getLocationY(), homeLocation.getLocationZ(), ico, false);
 | 
				
			||||||
                    } else {
 | 
					                    } else {
 | 
				
			||||||
                        homeMarker.setLocation(homeLocation.getWorld(), homeLocation.getLocationX(), homeLocation.getLocationY(), homeLocation.getLocationZ());
 | 
					                        homeMarker.setLocation(homeLocation.getWorld(), homeLocation.getLocationX(), homeLocation.getLocationY(), homeLocation.getLocationZ());
 | 
				
			||||||
@@ -134,15 +140,15 @@ public class FactionsUpdate implements Runnable {
 | 
				
			|||||||
        blocksByFaction.clear();
 | 
					        blocksByFaction.clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /* Now, review old map - anything left is gone */
 | 
					        /* Now, review old map - anything left is gone */
 | 
				
			||||||
        for (AreaMarker oldMarker : dynmapFactionsPlugin.factionAreaMarkers.values()) {
 | 
					        for (AreaMarker oldMarker : dynmapFactionsPlugin.getFactionAreaMarkers().values()) {
 | 
				
			||||||
            oldMarker.deleteMarker();
 | 
					            oldMarker.deleteMarker();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        for (Marker oldMarker : dynmapFactionsPlugin.factionMarkers.values()) {
 | 
					        for (Marker oldMarker : dynmapFactionsPlugin.getFactionMarkers().values()) {
 | 
				
			||||||
            oldMarker.deleteMarker();
 | 
					            oldMarker.deleteMarker();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        /* And replace with new map */
 | 
					        /* And replace with new map */
 | 
				
			||||||
        dynmapFactionsPlugin.factionAreaMarkers = newMap;
 | 
					        dynmapFactionsPlugin.setFactionAreaMarkers(newMap);
 | 
				
			||||||
        dynmapFactionsPlugin.factionMarkers = newMarkers;
 | 
					        dynmapFactionsPlugin.setFactionMarkers(newMarkers);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -274,13 +280,13 @@ public class FactionsUpdate implements Runnable {
 | 
				
			|||||||
                z = 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);
 | 
					                    int[] line = lineList.get(i);
 | 
				
			||||||
                    x[i] = (double) line[0] * (double) dynmapFactionsPlugin.blockSize;
 | 
					                    x[i] = (double) line[0] * (double) dynmapFactionsPlugin.getBlockSize();
 | 
				
			||||||
                    z[i] = (double) line[1] * (double) dynmapFactionsPlugin.blockSize;
 | 
					                    z[i] = (double) line[1] * (double) dynmapFactionsPlugin.getBlockSize();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                /* Find existing one */
 | 
					                /* Find existing one */
 | 
				
			||||||
                AreaMarker m = dynmapFactionsPlugin.factionAreaMarkers.remove(polyId); /* Existing area? */
 | 
					                AreaMarker m = dynmapFactionsPlugin.getFactionAreaMarkers().remove(polyId); /* Existing area? */
 | 
				
			||||||
                if (m == null) {
 | 
					                if (m == null) {
 | 
				
			||||||
                    m = dynmapFactionsPlugin.set.createAreaMarker(polyId, factionName, false, world, x, z, false);
 | 
					                    m = dynmapFactionsPlugin.getSet().createAreaMarker(polyId, factionName, false, world, x, z, false);
 | 
				
			||||||
                    if (m == null) {
 | 
					                    if (m == null) {
 | 
				
			||||||
                        DynmapFactionsPlugin.info("error adding area marker " + polyId);
 | 
					                        DynmapFactionsPlugin.info("error adding area marker " + polyId);
 | 
				
			||||||
                        return;
 | 
					                        return;
 | 
				
			||||||
@@ -332,9 +338,9 @@ public class FactionsUpdate implements Runnable {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void addStyle(String factionId, AreaMarker areaMarker) {
 | 
					    private void addStyle(String factionId, AreaMarker areaMarker) {
 | 
				
			||||||
        AreaStyle as = dynmapFactionsPlugin.customStyle.get(factionId);
 | 
					        AreaStyle as = dynmapFactionsPlugin.getCustomStyle().get(factionId);
 | 
				
			||||||
        if (as == null) {
 | 
					        if (as == null) {
 | 
				
			||||||
            as = dynmapFactionsPlugin.defaultStyle;
 | 
					            as = dynmapFactionsPlugin.getDefaultStyle();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        int sc = 0xFF0000;
 | 
					        int sc = 0xFF0000;
 | 
				
			||||||
        int fc = 0xFF0000;
 | 
					        int fc = 0xFF0000;
 | 
				
			||||||
@@ -349,21 +355,21 @@ public class FactionsUpdate implements Runnable {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private MarkerIcon getMarkerIcon(String factionName) {
 | 
					    private MarkerIcon getMarkerIcon(String factionName) {
 | 
				
			||||||
        AreaStyle as = dynmapFactionsPlugin.customStyle.get(factionName);
 | 
					        AreaStyle as = dynmapFactionsPlugin.getCustomStyle().get(factionName);
 | 
				
			||||||
        if (as == null) {
 | 
					        if (as == null) {
 | 
				
			||||||
            as = dynmapFactionsPlugin.defaultStyle;
 | 
					            as = dynmapFactionsPlugin.getDefaultStyle();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return as.homeIcon();
 | 
					        return as.homeIcon();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private boolean isVisible(String id, String worldName) {
 | 
					    private boolean isVisible(String id, String worldName) {
 | 
				
			||||||
        if ((dynmapFactionsPlugin.visible != null) && (!dynmapFactionsPlugin.visible.isEmpty())) {
 | 
					        if ((dynmapFactionsPlugin.getVisible() != null) && (!dynmapFactionsPlugin.getVisible().isEmpty())) {
 | 
				
			||||||
            if ((!dynmapFactionsPlugin.visible.contains(id)) && (!dynmapFactionsPlugin.visible.contains("world:" + worldName))) {
 | 
					            if ((!dynmapFactionsPlugin.getVisible().contains(id)) && (!dynmapFactionsPlugin.getVisible().contains("world:" + worldName))) {
 | 
				
			||||||
                return false;
 | 
					                return false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if ((dynmapFactionsPlugin.hidden != null) && (!dynmapFactionsPlugin.hidden.isEmpty())) {
 | 
					        if ((dynmapFactionsPlugin.getHidden() != null) && (!dynmapFactionsPlugin.getHidden().isEmpty())) {
 | 
				
			||||||
            return !dynmapFactionsPlugin.hidden.contains(id) && !dynmapFactionsPlugin.hidden.contains("world:" + worldName);
 | 
					            return !dynmapFactionsPlugin.getHidden().contains(id) && !dynmapFactionsPlugin.getHidden().contains("world:" + worldName);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -1,9 +1,11 @@
 | 
				
			|||||||
package org.dynmap.factions;
 | 
					package org.dynmap.factions.runnable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class PlayerSetUpdate implements Runnable {
 | 
					import org.dynmap.factions.DynmapFactionsPlugin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class PlayerSetUpdate implements Runnable {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final DynmapFactionsPlugin dynmapFactionsPlugin;
 | 
					    private final DynmapFactionsPlugin dynmapFactionsPlugin;
 | 
				
			||||||
    public final String faction;
 | 
					    private final String faction;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public PlayerSetUpdate(DynmapFactionsPlugin dynmapFactionsPlugin, String fid) {
 | 
					    public PlayerSetUpdate(DynmapFactionsPlugin dynmapFactionsPlugin, String fid) {
 | 
				
			||||||
        this.dynmapFactionsPlugin = dynmapFactionsPlugin;
 | 
					        this.dynmapFactionsPlugin = dynmapFactionsPlugin;
 | 
				
			||||||
@@ -11,7 +13,7 @@ class PlayerSetUpdate implements Runnable {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void run() {
 | 
					    public void run() {
 | 
				
			||||||
        if (!dynmapFactionsPlugin.stop) {
 | 
					        if (!dynmapFactionsPlugin.isStop()) {
 | 
				
			||||||
            dynmapFactionsPlugin.updatePlayerSet(faction);
 | 
					            dynmapFactionsPlugin.updatePlayerSet(faction);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
		Reference in New Issue
	
	Block a user