Update for Factions v2.0.0
This commit is contained in:
parent
2e0f40d059
commit
adbc2116e8
Binary file not shown.
BIN
Factions-2.0.0.jar
Normal file
BIN
Factions-2.0.0.jar
Normal file
Binary file not shown.
BIN
mcore-6.4.0.jar
Normal file
BIN
mcore-6.4.0.jar
Normal file
Binary file not shown.
13
pom.xml
13
pom.xml
@ -64,14 +64,21 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>1.4.5-R1.0</version>
|
<version>1.5.2-R1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.massivecraft</groupId>
|
<groupId>com.massivecraft</groupId>
|
||||||
<artifactId>Factions</artifactId>
|
<artifactId>Factions</artifactId>
|
||||||
<version>1.8.2</version>
|
<version>2.0.0</version>
|
||||||
<scope>system</scope>
|
<scope>system</scope>
|
||||||
<systemPath>${project.basedir}/Factions-1.8.2.jar</systemPath>
|
<systemPath>${project.basedir}/Factions-2.0.0.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.massivecraft</groupId>
|
||||||
|
<artifactId>mcore</artifactId>
|
||||||
|
<version>6.4.0</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${project.basedir}/mcore-6.4.0.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -32,20 +32,22 @@ import org.dynmap.markers.MarkerIcon;
|
|||||||
import org.dynmap.markers.MarkerSet;
|
import org.dynmap.markers.MarkerSet;
|
||||||
import org.dynmap.markers.PlayerSet;
|
import org.dynmap.markers.PlayerSet;
|
||||||
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.Board;
|
import com.massivecraft.factions.FFlag;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.TerritoryAccess;
|
||||||
import com.massivecraft.factions.event.FPlayerJoinEvent;
|
import com.massivecraft.factions.entity.Board;
|
||||||
import com.massivecraft.factions.event.FPlayerLeaveEvent;
|
import com.massivecraft.factions.entity.BoardColls;
|
||||||
import com.massivecraft.factions.event.FactionCreateEvent;
|
import com.massivecraft.factions.entity.Faction;
|
||||||
import com.massivecraft.factions.event.FactionDisbandEvent;
|
import com.massivecraft.factions.entity.FactionColl;
|
||||||
import com.massivecraft.factions.event.FactionRenameEvent;
|
import com.massivecraft.factions.entity.FactionColls;
|
||||||
import com.massivecraft.factions.event.LandClaimEvent;
|
import com.massivecraft.factions.entity.UPlayer;
|
||||||
import com.massivecraft.factions.event.LandUnclaimAllEvent;
|
import com.massivecraft.factions.event.FactionsEventChunkChange;
|
||||||
import com.massivecraft.factions.event.LandUnclaimEvent;
|
import com.massivecraft.factions.event.FactionsEventCreate;
|
||||||
import com.massivecraft.factions.struct.FFlag;
|
import com.massivecraft.factions.event.FactionsEventDisband;
|
||||||
import com.massivecraft.factions.struct.TerritoryAccess;
|
import com.massivecraft.factions.event.FactionsEventHomeChange;
|
||||||
|
import com.massivecraft.factions.event.FactionsEventMembershipChange;
|
||||||
|
import com.massivecraft.factions.event.FactionsEventNameChange;
|
||||||
|
import com.massivecraft.mcore.ps.PS;
|
||||||
|
|
||||||
public class DynmapFactionsPlugin extends JavaPlugin {
|
public class DynmapFactionsPlugin extends JavaPlugin {
|
||||||
private static Logger log;
|
private static Logger log;
|
||||||
@ -174,13 +176,15 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Set<String> plids = new HashSet<String>();
|
Set<String> plids = new HashSet<String>();
|
||||||
Faction f = factapi.get(factid); /* Get faction */
|
FactionColl fc = FactionColls.get().get(getServer().getConsoleSender());
|
||||||
|
|
||||||
|
Faction f = fc.getByName(factid); /* Get faction */
|
||||||
if(f != null) {
|
if(f != null) {
|
||||||
Set<FPlayer> ps = f.getFPlayers();
|
List<UPlayer> ps = f.getUPlayers();
|
||||||
for(FPlayer fp : ps) {
|
for(UPlayer fp : ps) {
|
||||||
plids.add(fp.getId());
|
plids.add(fp.getId());
|
||||||
}
|
}
|
||||||
factid = f.getTag();
|
factid = f.getId();
|
||||||
}
|
}
|
||||||
String setid = "factions." + factid;
|
String setid = "factions." + factid;
|
||||||
PlayerSet set = markerapi.getPlayerSet(setid); /* See if set exists */
|
PlayerSet set = markerapi.getPlayerSet(setid); /* See if set exists */
|
||||||
@ -201,35 +205,23 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
private String formatInfoWindow(Faction fact) {
|
private String formatInfoWindow(Faction fact) {
|
||||||
String v = "<div class=\"regioninfo\">"+infowindow+"</div>";
|
String v = "<div class=\"regioninfo\">"+infowindow+"</div>";
|
||||||
v = v.replace("%regionname%", ChatColor.stripColor(fact.getTag()));
|
v = v.replace("%regionname%", ChatColor.stripColor(fact.getName()));
|
||||||
v = v.replace("%description%", ChatColor.stripColor(fact.getDescription()));
|
v = v.replace("%description%", ChatColor.stripColor(fact.getDescription()));
|
||||||
FPlayer adm;
|
UPlayer adm = fact.getLeader();
|
||||||
try {
|
|
||||||
adm = fact.getFPlayerAdmin();
|
|
||||||
} catch (NoSuchMethodError nsme) {
|
|
||||||
adm = fact.getFPlayerLeader();
|
|
||||||
}
|
|
||||||
v = v.replace("%playerowners%", (adm!=null)?adm.getName():"");
|
v = v.replace("%playerowners%", (adm!=null)?adm.getName():"");
|
||||||
String res = "";
|
String res = "";
|
||||||
for(FPlayer r : fact.getFPlayers()) {
|
for(UPlayer r : fact.getUPlayers()) {
|
||||||
if(res.length()>0) res += ", ";
|
if(res.length()>0) res += ", ";
|
||||||
res += r.getName();
|
res += r.getName();
|
||||||
}
|
}
|
||||||
v = v.replace("%playermembers%", res);
|
v = v.replace("%playermembers%", res);
|
||||||
|
|
||||||
v = v.replace("%nation%", ChatColor.stripColor(fact.getTag()));
|
v = v.replace("%nation%", ChatColor.stripColor(fact.getName()));
|
||||||
/* Build flags */
|
/* Build flags */
|
||||||
String flgs = "open: " + fact.getOpen();
|
String flgs = "open: " + fact.isOpen();
|
||||||
try {
|
for(FFlag ff : FFlag.values()) {
|
||||||
for(FFlag ff : FFlag.values()) {
|
flgs += "<br/>" + ff.getNicename() + ": " + fact.getFlag(ff);
|
||||||
flgs += "<br/>" + ff.getNicename() + ": " + fact.getFlag(ff);
|
v = v.replace("%flag." + ff.name() + "%", fact.getFlag(ff)?"true":"false");
|
||||||
v = v.replace("%flag." + ff.name() + "%", fact.getFlag(ff)?"true":"false");
|
|
||||||
}
|
|
||||||
} catch (NoClassDefFoundError ncdfe) {
|
|
||||||
flgs += "<br/>peaceful: " + fact.isPeaceful();
|
|
||||||
v = v.replace("%flag.PEACEFUL%", fact.isPeaceful()?"true":"false");
|
|
||||||
flgs += "<br/>peacefulExplosionsEnabled: " + fact.getPeacefulExplosionsEnabled();
|
|
||||||
v = v.replace("%flag.EXPLOSIONS%", fact.getPeacefulExplosionsEnabled()?"true":"false");
|
|
||||||
}
|
}
|
||||||
v = v.replace("%flags%", flgs);
|
v = v.replace("%flags%", flgs);
|
||||||
return v;
|
return v;
|
||||||
@ -476,54 +468,41 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
Map<String,AreaMarker> newmap = new HashMap<String,AreaMarker>(); /* Build new map */
|
Map<String,AreaMarker> newmap = new HashMap<String,AreaMarker>(); /* Build new map */
|
||||||
Map<String,Marker> newmark = new HashMap<String,Marker>(); /* Build new map */
|
Map<String,Marker> newmark = new HashMap<String,Marker>(); /* Build new map */
|
||||||
|
|
||||||
/* Get board in save format - not good, but best option for traversing the data
|
|
||||||
* Map by world, with Map by coordinate pair ("x,z") with value of faction ID */
|
|
||||||
Map<String, Map<String, TerritoryAccess>> mapdata = Board.dumpAsSaveFormat();
|
|
||||||
/* 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<String, FactionBlocks>();
|
||||||
for(Map.Entry<String, Map<String,TerritoryAccess>> me : mapdata.entrySet()) {
|
FactionColl fc = FactionColls.get().get(getServer().getConsoleSender());
|
||||||
String world = me.getKey();
|
Collection<Faction> facts = fc.getAll();
|
||||||
for(Map.Entry<String,TerritoryAccess> be : me.getValue().entrySet()) {
|
|
||||||
String coord = be.getKey();
|
for (Faction fact : facts) {
|
||||||
Object ta = be.getValue();
|
Set<PS> chunks = BoardColls.get().getChunks(fact);
|
||||||
String fact;
|
String fid = fact.getId();
|
||||||
if(ta instanceof String) {
|
FactionBlocks factblocks = blocks_by_faction.get(fid); /* Look up faction */
|
||||||
fact = (String)ta;
|
if(factblocks == null) { /* Create faction block if first time */
|
||||||
}
|
factblocks = new FactionBlocks();
|
||||||
else {
|
blocks_by_faction.put(fid, factblocks);
|
||||||
fact = ((TerritoryAccess)ta).getHostFactionID();
|
}
|
||||||
}
|
|
||||||
FactionBlocks factblocks = blocks_by_faction.get(fact); /* Look up faction */
|
for (PS cc : chunks) {
|
||||||
if(factblocks == null) { /* Create faction block if first time */
|
String world = cc.getWorld();
|
||||||
factblocks = new FactionBlocks();
|
|
||||||
blocks_by_faction.put(fact, factblocks);
|
|
||||||
}
|
|
||||||
/* Get block set for given world */
|
/* Get block set for given world */
|
||||||
LinkedList<FactionBlock> blocks = factblocks.blocks.get(world);
|
LinkedList<FactionBlock> blocks = factblocks.blocks.get(world);
|
||||||
if(blocks == null) {
|
if(blocks == null) {
|
||||||
blocks = new LinkedList<FactionBlock>();
|
blocks = new LinkedList<FactionBlock>();
|
||||||
factblocks.blocks.put(world, blocks);
|
factblocks.blocks.put(world, blocks);
|
||||||
}
|
}
|
||||||
/* Parse coords */
|
FactionBlock fb = new FactionBlock();
|
||||||
String[] split = coord.split(",");
|
fb.x = cc.getChunkX();
|
||||||
if(split.length == 2) {
|
fb.z = cc.getChunkZ();
|
||||||
try {
|
blocks.add(fb); /* Add to list */
|
||||||
FactionBlock fb = new FactionBlock();
|
|
||||||
fb.x = Integer.valueOf(split[0]);
|
|
||||||
fb.z = Integer.valueOf(split[1]);
|
|
||||||
blocks.add(fb); /* Add to list */
|
|
||||||
} catch (NumberFormatException nfx) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Loop through factions */
|
/* Loop through factions */
|
||||||
Collection<Faction> facts = factapi.get();
|
|
||||||
for(Faction fact : facts) {
|
for(Faction fact : facts) {
|
||||||
String factname = ChatColor.stripColor(fact.getTag());
|
String factname = ChatColor.stripColor(fact.getName());
|
||||||
|
FactionBlocks factblocks = blocks_by_faction.get(fact.getId()); /* Look up faction */
|
||||||
|
if (factblocks == null) continue;
|
||||||
|
|
||||||
FactionBlocks factblocks = blocks_by_faction.get(fact.getId());
|
|
||||||
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()) {
|
||||||
handleFactionOnWorld(factname, fact, worldblocks.getKey(), worldblocks.getValue(), newmap, newmark);
|
handleFactionOnWorld(factname, fact, worldblocks.getKey(), worldblocks.getValue(), newmap, newmark);
|
||||||
@ -531,7 +510,7 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
factblocks.blocks.clear();
|
factblocks.blocks.clear();
|
||||||
|
|
||||||
/* Now, add marker for home location */
|
/* Now, add marker for home location */
|
||||||
Location homeloc = fact.getHome();
|
PS homeloc = fact.getHome();
|
||||||
if(homeloc != null) {
|
if(homeloc != null) {
|
||||||
String markid = factname + "__home";
|
String markid = factname + "__home";
|
||||||
MarkerIcon ico = getMarkerIcon(factname, fact);
|
MarkerIcon ico = getMarkerIcon(factname, fact);
|
||||||
@ -539,11 +518,11 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
Marker home = resmark.remove(markid);
|
Marker home = resmark.remove(markid);
|
||||||
String lbl = factname + " [home]";
|
String lbl = factname + " [home]";
|
||||||
if(home == null) {
|
if(home == null) {
|
||||||
home = set.createMarker(markid, lbl, homeloc.getWorld().getName(),
|
home = set.createMarker(markid, lbl, homeloc.getWorld(),
|
||||||
homeloc.getX(), homeloc.getY(), homeloc.getZ(), ico, false);
|
homeloc.getBlockX(), homeloc.getBlockY(), homeloc.getBlockZ(), ico, false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
home.setLocation(homeloc.getWorld().getName(), homeloc.getX(), homeloc.getY(), homeloc.getZ());
|
home.setLocation(homeloc.getWorld(), homeloc.getBlockX(), homeloc.getBlockY(), homeloc.getBlockZ());
|
||||||
home.setLabel(lbl); /* Update label */
|
home.setLabel(lbl); /* Update label */
|
||||||
home.setMarkerIcon(ico);
|
home.setMarkerIcon(ico);
|
||||||
}
|
}
|
||||||
@ -570,7 +549,8 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
private void updatePlayerSets() {
|
private void updatePlayerSets() {
|
||||||
if(playersets) {
|
if(playersets) {
|
||||||
for(Faction f : factapi.get()) {
|
FactionColl fc = FactionColls.get().get(getServer().getConsoleSender());
|
||||||
|
for(Faction f : fc.getAll()) {
|
||||||
updatePlayerSet(f.getId());
|
updatePlayerSet(f.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -587,21 +567,14 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
@EventHandler(priority=EventPriority.MONITOR)
|
@EventHandler(priority=EventPriority.MONITOR)
|
||||||
public void onFPlayerJoin(FPlayerJoinEvent event) {
|
public void onFPlayerJoin(FactionsEventMembershipChange event) {
|
||||||
if(event.isCancelled())
|
if(event.isCancelled())
|
||||||
return;
|
return;
|
||||||
if(playersets)
|
if(playersets)
|
||||||
requestUpdatePlayerSet(event.getFaction().getId());
|
requestUpdatePlayerSet(event.getNewFaction().getId());
|
||||||
}
|
}
|
||||||
@EventHandler(priority=EventPriority.MONITOR)
|
@EventHandler(priority=EventPriority.MONITOR)
|
||||||
public void onFPlayerLeave(FPlayerLeaveEvent event) {
|
public void onFactionCreate(FactionsEventCreate event) {
|
||||||
if(event.isCancelled())
|
|
||||||
return;
|
|
||||||
if(playersets)
|
|
||||||
requestUpdatePlayerSet(event.getFaction().getId());
|
|
||||||
}
|
|
||||||
@EventHandler(priority=EventPriority.MONITOR)
|
|
||||||
public void onFactionCreate(FactionCreateEvent event) {
|
|
||||||
if(event.isCancelled())
|
if(event.isCancelled())
|
||||||
return;
|
return;
|
||||||
if(playersets)
|
if(playersets)
|
||||||
@ -609,7 +582,7 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
requestUpdateFactions();
|
requestUpdateFactions();
|
||||||
}
|
}
|
||||||
@EventHandler(priority=EventPriority.MONITOR)
|
@EventHandler(priority=EventPriority.MONITOR)
|
||||||
public void onFactionDisband(FactionDisbandEvent event) {
|
public void onFactionDisband(FactionsEventDisband event) {
|
||||||
if(event.isCancelled())
|
if(event.isCancelled())
|
||||||
return;
|
return;
|
||||||
if(playersets)
|
if(playersets)
|
||||||
@ -617,27 +590,23 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
requestUpdateFactions();
|
requestUpdateFactions();
|
||||||
}
|
}
|
||||||
@EventHandler(priority=EventPriority.MONITOR)
|
@EventHandler(priority=EventPriority.MONITOR)
|
||||||
public void onFactionRename(FactionRenameEvent event) {
|
public void onFactionRename(FactionsEventNameChange event) {
|
||||||
if(event.isCancelled())
|
if(event.isCancelled())
|
||||||
return;
|
return;
|
||||||
requestUpdateFactions();
|
requestUpdateFactions();
|
||||||
}
|
}
|
||||||
@EventHandler(priority=EventPriority.MONITOR)
|
@EventHandler(priority=EventPriority.MONITOR)
|
||||||
public void onLandClaim(LandClaimEvent event) {
|
public void onFactionRename(FactionsEventHomeChange event) {
|
||||||
if(event.isCancelled())
|
if(event.isCancelled())
|
||||||
return;
|
return;
|
||||||
requestUpdateFactions();
|
requestUpdateFactions();
|
||||||
}
|
}
|
||||||
@EventHandler(priority=EventPriority.MONITOR)
|
@EventHandler(priority=EventPriority.MONITOR)
|
||||||
public void onLandUnclaim(LandUnclaimEvent event) {
|
public void onFactionRename(FactionsEventChunkChange event) {
|
||||||
if(event.isCancelled())
|
if(event.isCancelled())
|
||||||
return;
|
return;
|
||||||
requestUpdateFactions();
|
requestUpdateFactions();
|
||||||
}
|
}
|
||||||
@EventHandler(priority=EventPriority.MONITOR)
|
|
||||||
public void onLandUnclaimAll(LandUnclaimAllEvent event) {
|
|
||||||
requestUpdateFactions();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
@ -658,8 +627,6 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
factions = p;
|
factions = p;
|
||||||
|
|
||||||
getServer().getPluginManager().registerEvents(new OurServerListener(), this);
|
|
||||||
|
|
||||||
/* If both enabled, activate */
|
/* If both enabled, activate */
|
||||||
if(dynmap.isEnabled() && factions.isEnabled())
|
if(dynmap.isEnabled() && factions.isEnabled())
|
||||||
activate();
|
activate();
|
||||||
@ -680,7 +647,7 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* Connect to factions API */
|
/* Connect to factions API */
|
||||||
factapi = Factions.i;
|
factapi = Factions.get();
|
||||||
|
|
||||||
blocksize = 16; /* Fixed at 16 */
|
blocksize = 16; /* Fixed at 16 */
|
||||||
|
|
||||||
@ -762,6 +729,7 @@ public class DynmapFactionsPlugin extends JavaPlugin {
|
|||||||
stop = false;
|
stop = false;
|
||||||
|
|
||||||
getServer().getScheduler().scheduleSyncDelayedTask(this, new FactionsUpdate(), 40); /* First time is 2 seconds */
|
getServer().getScheduler().scheduleSyncDelayedTask(this, new FactionsUpdate(), 40); /* First time is 2 seconds */
|
||||||
|
getServer().getPluginManager().registerEvents(new OurServerListener(), this);
|
||||||
|
|
||||||
info("version " + this.getDescription().getVersion() + " is activated");
|
info("version " + this.getDescription().getVersion() + " is activated");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user