diff --git a/Factions-1.8.2.jar b/Factions-1.8.2.jar deleted file mode 100644 index 6e91079..0000000 Binary files a/Factions-1.8.2.jar and /dev/null differ diff --git a/Factions-2.0.0.jar b/Factions-2.0.0.jar new file mode 100644 index 0000000..ef2404e Binary files /dev/null and b/Factions-2.0.0.jar differ diff --git a/mcore-6.4.0.jar b/mcore-6.4.0.jar new file mode 100644 index 0000000..6b9bb12 Binary files /dev/null and b/mcore-6.4.0.jar differ diff --git a/pom.xml b/pom.xml index 033fe3a..9092fd5 100644 --- a/pom.xml +++ b/pom.xml @@ -64,14 +64,21 @@ org.bukkit bukkit - 1.4.5-R1.0 + 1.5.2-R1.0 com.massivecraft Factions - 1.8.2 + 2.0.0 system - ${project.basedir}/Factions-1.8.2.jar + ${project.basedir}/Factions-2.0.0.jar + + + com.massivecraft + mcore + 6.4.0 + system + ${project.basedir}/mcore-6.4.0.jar diff --git a/src/main/java/org/dynmap/factions/DynmapFactionsPlugin.java b/src/main/java/org/dynmap/factions/DynmapFactionsPlugin.java index d214030..457159d 100644 --- a/src/main/java/org/dynmap/factions/DynmapFactionsPlugin.java +++ b/src/main/java/org/dynmap/factions/DynmapFactionsPlugin.java @@ -32,20 +32,22 @@ import org.dynmap.markers.MarkerIcon; import org.dynmap.markers.MarkerSet; import org.dynmap.markers.PlayerSet; -import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.Factions; -import com.massivecraft.factions.Board; -import com.massivecraft.factions.Faction; -import com.massivecraft.factions.event.FPlayerJoinEvent; -import com.massivecraft.factions.event.FPlayerLeaveEvent; -import com.massivecraft.factions.event.FactionCreateEvent; -import com.massivecraft.factions.event.FactionDisbandEvent; -import com.massivecraft.factions.event.FactionRenameEvent; -import com.massivecraft.factions.event.LandClaimEvent; -import com.massivecraft.factions.event.LandUnclaimAllEvent; -import com.massivecraft.factions.event.LandUnclaimEvent; -import com.massivecraft.factions.struct.FFlag; -import com.massivecraft.factions.struct.TerritoryAccess; +import com.massivecraft.factions.FFlag; +import com.massivecraft.factions.TerritoryAccess; +import com.massivecraft.factions.entity.Board; +import com.massivecraft.factions.entity.BoardColls; +import com.massivecraft.factions.entity.Faction; +import com.massivecraft.factions.entity.FactionColl; +import com.massivecraft.factions.entity.FactionColls; +import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.event.FactionsEventChunkChange; +import com.massivecraft.factions.event.FactionsEventCreate; +import com.massivecraft.factions.event.FactionsEventDisband; +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 { private static Logger log; @@ -174,13 +176,15 @@ public class DynmapFactionsPlugin extends JavaPlugin { return; } Set plids = new HashSet(); - Faction f = factapi.get(factid); /* Get faction */ + FactionColl fc = FactionColls.get().get(getServer().getConsoleSender()); + + Faction f = fc.getByName(factid); /* Get faction */ if(f != null) { - Set ps = f.getFPlayers(); - for(FPlayer fp : ps) { + List ps = f.getUPlayers(); + for(UPlayer fp : ps) { plids.add(fp.getId()); } - factid = f.getTag(); + factid = f.getId(); } String setid = "factions." + factid; PlayerSet set = markerapi.getPlayerSet(setid); /* See if set exists */ @@ -201,35 +205,23 @@ public class DynmapFactionsPlugin extends JavaPlugin { private String formatInfoWindow(Faction fact) { String v = "
"+infowindow+"
"; - v = v.replace("%regionname%", ChatColor.stripColor(fact.getTag())); + v = v.replace("%regionname%", ChatColor.stripColor(fact.getName())); v = v.replace("%description%", ChatColor.stripColor(fact.getDescription())); - FPlayer adm; - try { - adm = fact.getFPlayerAdmin(); - } catch (NoSuchMethodError nsme) { - adm = fact.getFPlayerLeader(); - } + UPlayer adm = fact.getLeader(); v = v.replace("%playerowners%", (adm!=null)?adm.getName():""); String res = ""; - for(FPlayer r : fact.getFPlayers()) { + for(UPlayer r : fact.getUPlayers()) { if(res.length()>0) res += ", "; res += r.getName(); } v = v.replace("%playermembers%", res); - v = v.replace("%nation%", ChatColor.stripColor(fact.getTag())); + v = v.replace("%nation%", ChatColor.stripColor(fact.getName())); /* Build flags */ - String flgs = "open: " + fact.getOpen(); - try { - for(FFlag ff : FFlag.values()) { - flgs += "
" + ff.getNicename() + ": " + fact.getFlag(ff); - v = v.replace("%flag." + ff.name() + "%", fact.getFlag(ff)?"true":"false"); - } - } catch (NoClassDefFoundError ncdfe) { - flgs += "
peaceful: " + fact.isPeaceful(); - v = v.replace("%flag.PEACEFUL%", fact.isPeaceful()?"true":"false"); - flgs += "
peacefulExplosionsEnabled: " + fact.getPeacefulExplosionsEnabled(); - v = v.replace("%flag.EXPLOSIONS%", fact.getPeacefulExplosionsEnabled()?"true":"false"); + String flgs = "open: " + fact.isOpen(); + for(FFlag ff : FFlag.values()) { + flgs += "
" + ff.getNicename() + ": " + fact.getFlag(ff); + v = v.replace("%flag." + ff.name() + "%", fact.getFlag(ff)?"true":"false"); } v = v.replace("%flags%", flgs); return v; @@ -476,54 +468,41 @@ public class DynmapFactionsPlugin extends JavaPlugin { Map newmap = new HashMap(); /* Build new map */ Map newmark = new HashMap(); /* 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> mapdata = Board.dumpAsSaveFormat(); /* Parse into faction centric mapping, split by world */ Map blocks_by_faction = new HashMap(); - for(Map.Entry> me : mapdata.entrySet()) { - String world = me.getKey(); - for(Map.Entry be : me.getValue().entrySet()) { - String coord = be.getKey(); - Object ta = be.getValue(); - String fact; - if(ta instanceof String) { - fact = (String)ta; - } - else { - fact = ((TerritoryAccess)ta).getHostFactionID(); - } - FactionBlocks factblocks = blocks_by_faction.get(fact); /* Look up faction */ - if(factblocks == null) { /* Create faction block if first time */ - factblocks = new FactionBlocks(); - blocks_by_faction.put(fact, factblocks); - } + FactionColl fc = FactionColls.get().get(getServer().getConsoleSender()); + Collection facts = fc.getAll(); + + for (Faction fact : facts) { + Set chunks = BoardColls.get().getChunks(fact); + String fid = fact.getId(); + FactionBlocks factblocks = blocks_by_faction.get(fid); /* Look up faction */ + if(factblocks == null) { /* Create faction block if first time */ + factblocks = new FactionBlocks(); + blocks_by_faction.put(fid, factblocks); + } + + for (PS cc : chunks) { + String world = cc.getWorld(); + /* Get block set for given world */ LinkedList blocks = factblocks.blocks.get(world); if(blocks == null) { blocks = new LinkedList(); factblocks.blocks.put(world, blocks); } - /* Parse coords */ - String[] split = coord.split(","); - if(split.length == 2) { - try { - 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) { - } - } + FactionBlock fb = new FactionBlock(); + fb.x = cc.getChunkX(); + fb.z = cc.getChunkZ(); + blocks.add(fb); /* Add to list */ } } /* Loop through factions */ - Collection facts = factapi.get(); 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 */ for(Map.Entry> worldblocks : factblocks.blocks.entrySet()) { handleFactionOnWorld(factname, fact, worldblocks.getKey(), worldblocks.getValue(), newmap, newmark); @@ -531,7 +510,7 @@ public class DynmapFactionsPlugin extends JavaPlugin { factblocks.blocks.clear(); /* Now, add marker for home location */ - Location homeloc = fact.getHome(); + PS homeloc = fact.getHome(); if(homeloc != null) { String markid = factname + "__home"; MarkerIcon ico = getMarkerIcon(factname, fact); @@ -539,11 +518,11 @@ public class DynmapFactionsPlugin extends JavaPlugin { Marker home = resmark.remove(markid); String lbl = factname + " [home]"; if(home == null) { - home = set.createMarker(markid, lbl, homeloc.getWorld().getName(), - homeloc.getX(), homeloc.getY(), homeloc.getZ(), ico, false); + home = set.createMarker(markid, lbl, homeloc.getWorld(), + homeloc.getBlockX(), homeloc.getBlockY(), homeloc.getBlockZ(), ico, false); } 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.setMarkerIcon(ico); } @@ -570,7 +549,8 @@ public class DynmapFactionsPlugin extends JavaPlugin { private void updatePlayerSets() { if(playersets) { - for(Faction f : factapi.get()) { + FactionColl fc = FactionColls.get().get(getServer().getConsoleSender()); + for(Faction f : fc.getAll()) { updatePlayerSet(f.getId()); } } @@ -587,21 +567,14 @@ public class DynmapFactionsPlugin extends JavaPlugin { } } @EventHandler(priority=EventPriority.MONITOR) - public void onFPlayerJoin(FPlayerJoinEvent event) { + public void onFPlayerJoin(FactionsEventMembershipChange event) { if(event.isCancelled()) return; if(playersets) - requestUpdatePlayerSet(event.getFaction().getId()); + requestUpdatePlayerSet(event.getNewFaction().getId()); } @EventHandler(priority=EventPriority.MONITOR) - public void onFPlayerLeave(FPlayerLeaveEvent event) { - if(event.isCancelled()) - return; - if(playersets) - requestUpdatePlayerSet(event.getFaction().getId()); - } - @EventHandler(priority=EventPriority.MONITOR) - public void onFactionCreate(FactionCreateEvent event) { + public void onFactionCreate(FactionsEventCreate event) { if(event.isCancelled()) return; if(playersets) @@ -609,7 +582,7 @@ public class DynmapFactionsPlugin extends JavaPlugin { requestUpdateFactions(); } @EventHandler(priority=EventPriority.MONITOR) - public void onFactionDisband(FactionDisbandEvent event) { + public void onFactionDisband(FactionsEventDisband event) { if(event.isCancelled()) return; if(playersets) @@ -617,27 +590,23 @@ public class DynmapFactionsPlugin extends JavaPlugin { requestUpdateFactions(); } @EventHandler(priority=EventPriority.MONITOR) - public void onFactionRename(FactionRenameEvent event) { + public void onFactionRename(FactionsEventNameChange event) { if(event.isCancelled()) return; requestUpdateFactions(); } @EventHandler(priority=EventPriority.MONITOR) - public void onLandClaim(LandClaimEvent event) { + public void onFactionRename(FactionsEventHomeChange event) { if(event.isCancelled()) return; requestUpdateFactions(); } @EventHandler(priority=EventPriority.MONITOR) - public void onLandUnclaim(LandUnclaimEvent event) { + public void onFactionRename(FactionsEventChunkChange event) { if(event.isCancelled()) return; requestUpdateFactions(); } - @EventHandler(priority=EventPriority.MONITOR) - public void onLandUnclaimAll(LandUnclaimAllEvent event) { - requestUpdateFactions(); - } } public void onEnable() { @@ -658,8 +627,6 @@ public class DynmapFactionsPlugin extends JavaPlugin { } factions = p; - getServer().getPluginManager().registerEvents(new OurServerListener(), this); - /* If both enabled, activate */ if(dynmap.isEnabled() && factions.isEnabled()) activate(); @@ -680,7 +647,7 @@ public class DynmapFactionsPlugin extends JavaPlugin { return; } /* Connect to factions API */ - factapi = Factions.i; + factapi = Factions.get(); blocksize = 16; /* Fixed at 16 */ @@ -762,6 +729,7 @@ public class DynmapFactionsPlugin extends JavaPlugin { stop = false; 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"); }