Halfway through adding in universe support
This commit is contained in:
parent
de703d3461
commit
9fc75b1fcf
@ -18,6 +18,10 @@ public class Const
|
|||||||
public static final String COLLECTION_BASENAME_PLAYER = COLLECTION_BASENAME_+"player";
|
public static final String COLLECTION_BASENAME_PLAYER = COLLECTION_BASENAME_+"player";
|
||||||
public static final String COLLECTION_BASENAME_FACTION = COLLECTION_BASENAME_+"faction";
|
public static final String COLLECTION_BASENAME_FACTION = COLLECTION_BASENAME_+"faction";
|
||||||
|
|
||||||
|
// Aspect Ids
|
||||||
|
|
||||||
|
public static final String ASPECT_ID = "factions";
|
||||||
|
|
||||||
// Defautlt faction ids
|
// Defautlt faction ids
|
||||||
public static final String FACTIONID_NONE = "0";
|
public static final String FACTIONID_NONE = "0";
|
||||||
public static final String FACTIONID_SAFEZONE = "-1";
|
public static final String FACTIONID_SAFEZONE = "-1";
|
||||||
|
@ -12,9 +12,8 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
|
||||||
import com.massivecraft.factions.entity.BoardColl;
|
import com.massivecraft.factions.entity.BoardColls;
|
||||||
import com.massivecraft.factions.entity.FPlayer;
|
import com.massivecraft.factions.entity.FPlayer;
|
||||||
import com.massivecraft.factions.entity.FPlayerColl;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
import com.massivecraft.factions.entity.Faction;
|
||||||
import com.massivecraft.mcore.ps.PS;
|
import com.massivecraft.mcore.ps.PS;
|
||||||
|
|
||||||
@ -178,7 +177,7 @@ public enum FPerm
|
|||||||
|
|
||||||
if (testSubject instanceof CommandSender)
|
if (testSubject instanceof CommandSender)
|
||||||
{
|
{
|
||||||
rpSubject = FPlayerColl.get().get(testSubject);
|
rpSubject = FPlayer.get(testSubject);
|
||||||
}
|
}
|
||||||
else if (testSubject instanceof RelationParticipator)
|
else if (testSubject instanceof RelationParticipator)
|
||||||
{
|
{
|
||||||
@ -213,7 +212,7 @@ public enum FPerm
|
|||||||
}
|
}
|
||||||
public boolean has(Object testSubject, PS ps, boolean informIfNot)
|
public boolean has(Object testSubject, PS ps, boolean informIfNot)
|
||||||
{
|
{
|
||||||
TerritoryAccess access = BoardColl.get().getTerritoryAccessAt(ps);
|
TerritoryAccess access = BoardColls.get().getTerritoryAccessAt(ps);
|
||||||
|
|
||||||
if (this.isTerritoryPerm())
|
if (this.isTerritoryPerm())
|
||||||
{
|
{
|
||||||
@ -224,7 +223,7 @@ public enum FPerm
|
|||||||
{
|
{
|
||||||
FPlayer notify = null;
|
FPlayer notify = null;
|
||||||
if (testSubject instanceof CommandSender)
|
if (testSubject instanceof CommandSender)
|
||||||
notify = FPlayerColl.get().get(testSubject);
|
notify = FPlayer.get(testSubject);
|
||||||
else if (testSubject instanceof FPlayer)
|
else if (testSubject instanceof FPlayer)
|
||||||
notify = (FPlayer)testSubject;
|
notify = (FPlayer)testSubject;
|
||||||
if (notify != null)
|
if (notify != null)
|
||||||
|
@ -20,9 +20,9 @@ import com.massivecraft.factions.chat.tag.ChatTagTagforce;
|
|||||||
import com.massivecraft.factions.chat.tag.ChatTagTitle;
|
import com.massivecraft.factions.chat.tag.ChatTagTitle;
|
||||||
import com.massivecraft.factions.cmd.*;
|
import com.massivecraft.factions.cmd.*;
|
||||||
import com.massivecraft.factions.entity.Board;
|
import com.massivecraft.factions.entity.Board;
|
||||||
import com.massivecraft.factions.entity.BoardColl;
|
import com.massivecraft.factions.entity.BoardColls;
|
||||||
import com.massivecraft.factions.entity.FPlayerColl;
|
import com.massivecraft.factions.entity.FPlayerColls;
|
||||||
import com.massivecraft.factions.entity.FactionColl;
|
import com.massivecraft.factions.entity.FactionColls;
|
||||||
import com.massivecraft.factions.entity.MConfColl;
|
import com.massivecraft.factions.entity.MConfColl;
|
||||||
import com.massivecraft.factions.integration.LWCFeatures;
|
import com.massivecraft.factions.integration.LWCFeatures;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
@ -38,6 +38,9 @@ import com.massivecraft.factions.task.AutoLeaveTask;
|
|||||||
import com.massivecraft.factions.task.EconLandRewardTask;
|
import com.massivecraft.factions.task.EconLandRewardTask;
|
||||||
|
|
||||||
import com.massivecraft.mcore.MPlugin;
|
import com.massivecraft.mcore.MPlugin;
|
||||||
|
import com.massivecraft.mcore.usys.Aspect;
|
||||||
|
import com.massivecraft.mcore.usys.AspectColl;
|
||||||
|
import com.massivecraft.mcore.usys.Multiverse;
|
||||||
import com.massivecraft.mcore.util.MUtil;
|
import com.massivecraft.mcore.util.MUtil;
|
||||||
import com.massivecraft.mcore.xlib.gson.GsonBuilder;
|
import com.massivecraft.mcore.xlib.gson.GsonBuilder;
|
||||||
|
|
||||||
@ -63,6 +66,11 @@ public class Factions extends MPlugin
|
|||||||
// Listeners
|
// Listeners
|
||||||
public TodoFactionsPlayerListener playerListener;
|
public TodoFactionsPlayerListener playerListener;
|
||||||
|
|
||||||
|
// Aspects
|
||||||
|
private Aspect aspect;
|
||||||
|
public Aspect getAspect() { return this.aspect; }
|
||||||
|
public Multiverse getMultiverse() { return this.getAspect().getMultiverse(); }
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -75,15 +83,23 @@ public class Factions extends MPlugin
|
|||||||
// Load Server Config
|
// Load Server Config
|
||||||
ConfServer.get().load();
|
ConfServer.get().load();
|
||||||
|
|
||||||
|
// Initialize Aspects
|
||||||
|
this.aspect = AspectColl.get().get(Const.ASPECT_ID, true);
|
||||||
|
this.aspect.register();
|
||||||
|
this.aspect.setDesc(
|
||||||
|
"<i>If the factions system even is enabled and how it's configured.",
|
||||||
|
"<i>What factions exists and what players belong to them."
|
||||||
|
);
|
||||||
|
|
||||||
// Register Faction accountId Extractor
|
// Register Faction accountId Extractor
|
||||||
// TODO: Perhaps this should be placed in the econ integration somewhere?
|
// TODO: Perhaps this should be placed in the econ integration somewhere?
|
||||||
MUtil.registerExtractor(String.class, "accountId", ExtractorFactionAccountId.get());
|
MUtil.registerExtractor(String.class, "accountId", ExtractorFactionAccountId.get());
|
||||||
|
|
||||||
// Initialize Collections
|
// Initialize Collections
|
||||||
MConfColl.get().init();
|
MConfColl.get().init();
|
||||||
FPlayerColl.get().init();
|
FPlayerColls.get().init();
|
||||||
FactionColl.get().init();
|
FactionColls.get().init();
|
||||||
BoardColl.get().init();
|
BoardColls.get().init();
|
||||||
|
|
||||||
// Commands
|
// Commands
|
||||||
this.outerCmdFactions = new CmdFactions();
|
this.outerCmdFactions = new CmdFactions();
|
||||||
|
@ -5,7 +5,7 @@ import com.massivecraft.factions.Perm;
|
|||||||
import com.massivecraft.factions.TerritoryAccess;
|
import com.massivecraft.factions.TerritoryAccess;
|
||||||
import com.massivecraft.factions.cmd.arg.ARFPlayer;
|
import com.massivecraft.factions.cmd.arg.ARFPlayer;
|
||||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||||
import com.massivecraft.factions.entity.BoardColl;
|
import com.massivecraft.factions.entity.BoardColls;
|
||||||
import com.massivecraft.factions.entity.FPlayer;
|
import com.massivecraft.factions.entity.FPlayer;
|
||||||
import com.massivecraft.factions.entity.Faction;
|
import com.massivecraft.factions.entity.Faction;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
@ -36,7 +36,7 @@ public class CmdFactionsAccess extends FCommand
|
|||||||
type = (type == null) ? "" : type.toLowerCase();
|
type = (type == null) ? "" : type.toLowerCase();
|
||||||
PS chunk = PS.valueOf(me).getChunk(true);
|
PS chunk = PS.valueOf(me).getChunk(true);
|
||||||
|
|
||||||
TerritoryAccess territory = BoardColl.get().getTerritoryAccessAt(chunk);
|
TerritoryAccess territory = BoardColls.get().getTerritoryAccessAt(chunk);
|
||||||
Faction locFaction = territory.getHostFaction();
|
Faction locFaction = territory.getHostFaction();
|
||||||
boolean accessAny = Perm.ACCESS_ANY.has(sender, false);
|
boolean accessAny = Perm.ACCESS_ANY.has(sender, false);
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import com.massivecraft.factions.Factions;
|
|||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
import com.massivecraft.factions.Rel;
|
import com.massivecraft.factions.Rel;
|
||||||
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
|
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
|
||||||
import com.massivecraft.factions.entity.BoardColl;
|
import com.massivecraft.factions.entity.BoardColls;
|
||||||
import com.massivecraft.factions.entity.FPlayer;
|
import com.massivecraft.factions.entity.FPlayer;
|
||||||
import com.massivecraft.factions.entity.FPlayerColl;
|
import com.massivecraft.factions.entity.FPlayerColl;
|
||||||
import com.massivecraft.factions.entity.Faction;
|
import com.massivecraft.factions.entity.Faction;
|
||||||
@ -69,7 +69,7 @@ public class CmdFactionsHome extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Faction faction = BoardColl.get().getFactionAt(PS.valueOf(me));
|
Faction faction = BoardColls.get().getFactionAt(PS.valueOf(me));
|
||||||
Location loc = me.getLocation().clone();
|
Location loc = me.getLocation().clone();
|
||||||
|
|
||||||
// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby
|
// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
import com.massivecraft.factions.entity.BoardColl;
|
import com.massivecraft.factions.entity.BoardColls;
|
||||||
import com.massivecraft.mcore.cmd.arg.ARBoolean;
|
import com.massivecraft.mcore.cmd.arg.ARBoolean;
|
||||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||||
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
|
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
|
||||||
import com.massivecraft.mcore.ps.PS;
|
import com.massivecraft.mcore.ps.PS;
|
||||||
|
|
||||||
|
|
||||||
public class CmdFactionsMap extends FCommand
|
public class CmdFactionsMap extends FCommand
|
||||||
{
|
{
|
||||||
public CmdFactionsMap()
|
public CmdFactionsMap()
|
||||||
@ -49,7 +48,7 @@ public class CmdFactionsMap extends FCommand
|
|||||||
|
|
||||||
public void showMap()
|
public void showMap()
|
||||||
{
|
{
|
||||||
sendMessage(BoardColl.get().getMap(myFaction, PS.valueOf(me), fme.getPlayer().getLocation().getYaw()));
|
sendMessage(BoardColls.get().getMap(myFaction, PS.valueOf(me), fme.getPlayer().getLocation().getYaw()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.ConfServer;
|
import com.massivecraft.factions.ConfServer;
|
||||||
import com.massivecraft.factions.entity.BoardColl;
|
import com.massivecraft.factions.entity.BoardColls;
|
||||||
import com.massivecraft.factions.entity.Faction;
|
import com.massivecraft.factions.entity.Faction;
|
||||||
import com.massivecraft.factions.entity.MConf;
|
import com.massivecraft.factions.entity.MConf;
|
||||||
import com.massivecraft.factions.event.FactionsEventLandUnclaim;
|
import com.massivecraft.factions.event.FactionsEventLandUnclaim;
|
||||||
@ -29,7 +29,7 @@ public class CmdFactionsUnclaim extends FCommand
|
|||||||
{
|
{
|
||||||
// Args
|
// Args
|
||||||
PS chunk = PS.valueOf(me).getChunk(true);
|
PS chunk = PS.valueOf(me).getChunk(true);
|
||||||
Faction otherFaction = BoardColl.get().getFactionAt(chunk);
|
Faction otherFaction = BoardColls.get().getFactionAt(chunk);
|
||||||
|
|
||||||
// FPerm
|
// FPerm
|
||||||
if ( ! FPerm.TERRITORY.has(sender, otherFaction, true)) return;
|
if ( ! FPerm.TERRITORY.has(sender, otherFaction, true)) return;
|
||||||
@ -54,7 +54,7 @@ public class CmdFactionsUnclaim extends FCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BoardColl.get().removeAt(chunk);
|
BoardColls.get().removeAt(chunk);
|
||||||
SpoutFeatures.updateTerritoryDisplayLoc(chunk);
|
SpoutFeatures.updateTerritoryDisplayLoc(chunk);
|
||||||
myFaction.msg("%s<i> unclaimed some land.", fme.describeTo(myFaction, true));
|
myFaction.msg("%s<i> unclaimed some land.", fme.describeTo(myFaction, true));
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import com.massivecraft.factions.Factions;
|
|||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
import com.massivecraft.factions.Rel;
|
import com.massivecraft.factions.Rel;
|
||||||
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
|
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
|
||||||
import com.massivecraft.factions.entity.BoardColl;
|
import com.massivecraft.factions.entity.BoardColls;
|
||||||
import com.massivecraft.factions.entity.MConf;
|
import com.massivecraft.factions.entity.MConf;
|
||||||
import com.massivecraft.factions.event.FactionsEventLandUnclaimAll;
|
import com.massivecraft.factions.event.FactionsEventLandUnclaimAll;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
@ -45,7 +45,7 @@ public class CmdFactionsUnclaimall extends FCommand
|
|||||||
// TODO: this event cannot be cancelled yet.
|
// TODO: this event cannot be cancelled yet.
|
||||||
|
|
||||||
// Apply
|
// Apply
|
||||||
BoardColl.get().removeAll(myFaction);
|
BoardColls.get().removeAll(myFaction);
|
||||||
|
|
||||||
// Inform
|
// Inform
|
||||||
myFaction.msg("%s<i> unclaimed ALL of your faction's land.", fme.describeTo(myFaction, true));
|
myFaction.msg("%s<i> unclaimed ALL of your faction's land.", fme.describeTo(myFaction, true));
|
||||||
|
@ -32,7 +32,7 @@ public class Board extends Entity<Board> implements BoardInterface
|
|||||||
|
|
||||||
public static Board get(Object oid)
|
public static Board get(Object oid)
|
||||||
{
|
{
|
||||||
return BoardColl.get().get(oid);
|
return BoardColls.get().get2(oid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -169,7 +169,7 @@ public class Board extends Entity<Board> implements BoardInterface
|
|||||||
{
|
{
|
||||||
TerritoryAccess territoryAccess = entry.getValue();
|
TerritoryAccess territoryAccess = entry.getValue();
|
||||||
|
|
||||||
if (FactionColl.get().containsId(territoryAccess.getHostFactionId())) continue;
|
if (FactionColls.get().get(this).containsId(territoryAccess.getHostFactionId())) continue;
|
||||||
|
|
||||||
PS ps = entry.getKey();
|
PS ps = entry.getKey();
|
||||||
this.removeAt(ps);
|
this.removeAt(ps);
|
||||||
|
@ -1,35 +1,25 @@
|
|||||||
package com.massivecraft.factions.entity;
|
package com.massivecraft.factions.entity;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.ConfServer;
|
import com.massivecraft.factions.ConfServer;
|
||||||
import com.massivecraft.factions.Const;
|
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.RelationParticipator;
|
import com.massivecraft.factions.RelationParticipator;
|
||||||
import com.massivecraft.factions.TerritoryAccess;
|
import com.massivecraft.factions.TerritoryAccess;
|
||||||
import com.massivecraft.mcore.ps.PS;
|
import com.massivecraft.mcore.ps.PS;
|
||||||
import com.massivecraft.mcore.ps.PSBuilder;
|
|
||||||
import com.massivecraft.mcore.store.Coll;
|
import com.massivecraft.mcore.store.Coll;
|
||||||
import com.massivecraft.mcore.store.MStore;
|
import com.massivecraft.mcore.store.MStore;
|
||||||
import com.massivecraft.mcore.util.DiscUtil;
|
|
||||||
import com.massivecraft.mcore.util.MUtil;
|
import com.massivecraft.mcore.util.MUtil;
|
||||||
import com.massivecraft.mcore.xlib.gson.reflect.TypeToken;
|
|
||||||
|
|
||||||
public class BoardColl extends Coll<Board> implements BoardInterface
|
public class BoardColl extends Coll<Board> implements BoardInterface
|
||||||
{
|
{
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// INSTANCE & CONSTRUCT
|
// CONSTRUCT
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
private static BoardColl i = new BoardColl();
|
public BoardColl(String name)
|
||||||
public static BoardColl get() { return i; }
|
|
||||||
private BoardColl()
|
|
||||||
{
|
{
|
||||||
super(Const.COLLECTION_BASENAME_BOARD, Board.class, MStore.getDb(ConfServer.dburi), Factions.get(), true, true);
|
super(name, Board.class, MStore.getDb(ConfServer.dburi), Factions.get(), true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -46,50 +36,6 @@ public class BoardColl extends Coll<Board> implements BoardInterface
|
|||||||
return MUtil.extract(String.class, "worldName", oid);
|
return MUtil.extract(String.class, "worldName", oid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init()
|
|
||||||
{
|
|
||||||
super.init();
|
|
||||||
|
|
||||||
this.migrate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void migrate()
|
|
||||||
{
|
|
||||||
// Create file objects
|
|
||||||
File oldFile = new File(Factions.get().getDataFolder(), "board.json");
|
|
||||||
File newFile = new File(Factions.get().getDataFolder(), "board.json.migrated");
|
|
||||||
|
|
||||||
// Already migrated?
|
|
||||||
if ( ! oldFile.exists()) return;
|
|
||||||
|
|
||||||
// Read the file content through GSON.
|
|
||||||
Type type = new TypeToken<Map<String,Map<String,TerritoryAccess>>>(){}.getType();
|
|
||||||
Map<String,Map<String,TerritoryAccess>> worldCoordIds = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type);
|
|
||||||
|
|
||||||
// Set the data
|
|
||||||
for (Entry<String,Map<String,TerritoryAccess>> entry : worldCoordIds.entrySet())
|
|
||||||
{
|
|
||||||
String worldName = entry.getKey();
|
|
||||||
Board board = this.get(worldName);
|
|
||||||
for (Entry<String,TerritoryAccess> entry2 : entry.getValue().entrySet())
|
|
||||||
{
|
|
||||||
String[] ChunkCoordParts = entry2.getKey().trim().split("[,\\s]+");
|
|
||||||
int chunkX = Integer.parseInt(ChunkCoordParts[0]);
|
|
||||||
int chunkZ = Integer.parseInt(ChunkCoordParts[1]);
|
|
||||||
PS ps = new PSBuilder().chunkX(chunkX).chunkZ(chunkZ).build();
|
|
||||||
|
|
||||||
TerritoryAccess territoryAccess = entry2.getValue();
|
|
||||||
|
|
||||||
board.setTerritoryAccessAt(ps, territoryAccess);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mark as migrated
|
|
||||||
oldFile.renameTo(newFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE: BOARD
|
// OVERRIDE: BOARD
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
233
src/com/massivecraft/factions/entity/BoardColls.java
Normal file
233
src/com/massivecraft/factions/entity/BoardColls.java
Normal file
@ -0,0 +1,233 @@
|
|||||||
|
package com.massivecraft.factions.entity;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.Const;
|
||||||
|
import com.massivecraft.factions.Factions;
|
||||||
|
import com.massivecraft.factions.RelationParticipator;
|
||||||
|
import com.massivecraft.factions.TerritoryAccess;
|
||||||
|
import com.massivecraft.mcore.ps.PS;
|
||||||
|
import com.massivecraft.mcore.ps.PSBuilder;
|
||||||
|
import com.massivecraft.mcore.store.Coll;
|
||||||
|
import com.massivecraft.mcore.store.Colls;
|
||||||
|
import com.massivecraft.mcore.store.Entity;
|
||||||
|
import com.massivecraft.mcore.usys.Aspect;
|
||||||
|
import com.massivecraft.mcore.util.DiscUtil;
|
||||||
|
import com.massivecraft.mcore.util.MUtil;
|
||||||
|
import com.massivecraft.mcore.xlib.gson.reflect.TypeToken;
|
||||||
|
|
||||||
|
public class BoardColls extends Colls<BoardColl, Board> implements BoardInterface
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INSTANCE & CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
private static BoardColls i = new BoardColls();
|
||||||
|
public static BoardColls get() { return i; }
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// OVERRIDE: COLLS
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BoardColl createColl(String collName)
|
||||||
|
{
|
||||||
|
return new BoardColl(collName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Aspect getAspect()
|
||||||
|
{
|
||||||
|
return Factions.get().getAspect();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getBasename()
|
||||||
|
{
|
||||||
|
return Const.COLLECTION_BASENAME_UCONF;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BoardColl get(Object o)
|
||||||
|
{
|
||||||
|
if (o == null) return null;
|
||||||
|
|
||||||
|
if (o instanceof Entity)
|
||||||
|
{
|
||||||
|
return this.getForUniverse(((Entity<?>)o).getUniverse());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o instanceof Coll)
|
||||||
|
{
|
||||||
|
return this.getForUniverse(((Coll<?>)o).getUniverse());
|
||||||
|
}
|
||||||
|
|
||||||
|
String worldName = MUtil.extract(String.class, "worldName", o);
|
||||||
|
if (worldName == null) return null;
|
||||||
|
return this.getForWorld(worldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init()
|
||||||
|
{
|
||||||
|
super.init();
|
||||||
|
|
||||||
|
this.migrate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void migrate()
|
||||||
|
{
|
||||||
|
// Create file objects
|
||||||
|
File oldFile = new File(Factions.get().getDataFolder(), "board.json");
|
||||||
|
File newFile = new File(Factions.get().getDataFolder(), "board.json.migrated");
|
||||||
|
|
||||||
|
// Already migrated?
|
||||||
|
if ( ! oldFile.exists()) return;
|
||||||
|
|
||||||
|
// Read the file content through GSON.
|
||||||
|
Type type = new TypeToken<Map<String,Map<String,TerritoryAccess>>>(){}.getType();
|
||||||
|
Map<String,Map<String,TerritoryAccess>> worldCoordIds = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type);
|
||||||
|
|
||||||
|
// Set the data
|
||||||
|
for (Entry<String,Map<String,TerritoryAccess>> entry : worldCoordIds.entrySet())
|
||||||
|
{
|
||||||
|
String worldName = entry.getKey();
|
||||||
|
BoardColl boardColl = this.getForWorld(worldName);
|
||||||
|
Board board = boardColl.get(worldName);
|
||||||
|
for (Entry<String,TerritoryAccess> entry2 : entry.getValue().entrySet())
|
||||||
|
{
|
||||||
|
String[] ChunkCoordParts = entry2.getKey().trim().split("[,\\s]+");
|
||||||
|
int chunkX = Integer.parseInt(ChunkCoordParts[0]);
|
||||||
|
int chunkZ = Integer.parseInt(ChunkCoordParts[1]);
|
||||||
|
PS ps = new PSBuilder().chunkX(chunkX).chunkZ(chunkZ).build();
|
||||||
|
|
||||||
|
TerritoryAccess territoryAccess = entry2.getValue();
|
||||||
|
|
||||||
|
board.setTerritoryAccessAt(ps, territoryAccess);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark as migrated
|
||||||
|
oldFile.renameTo(newFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// OVERRIDE: BOARD
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TerritoryAccess getTerritoryAccessAt(PS ps)
|
||||||
|
{
|
||||||
|
if (ps == null) return null;
|
||||||
|
BoardColl coll = this.getForWorld(ps.getWorld());
|
||||||
|
if (coll == null) return null;
|
||||||
|
return coll.getTerritoryAccessAt(ps);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Faction getFactionAt(PS ps)
|
||||||
|
{
|
||||||
|
if (ps == null) return null;
|
||||||
|
BoardColl coll = this.getForWorld(ps.getWorld());
|
||||||
|
if (coll == null) return null;
|
||||||
|
return coll.getFactionAt(ps);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SET
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTerritoryAccessAt(PS ps, TerritoryAccess territoryAccess)
|
||||||
|
{
|
||||||
|
if (ps == null) return;
|
||||||
|
BoardColl coll = this.getForWorld(ps.getWorld());
|
||||||
|
if (coll == null) return;
|
||||||
|
coll.setTerritoryAccessAt(ps, territoryAccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFactionAt(PS ps, Faction faction)
|
||||||
|
{
|
||||||
|
if (ps == null) return;
|
||||||
|
BoardColl coll = this.getForWorld(ps.getWorld());
|
||||||
|
if (coll == null) return;
|
||||||
|
coll.setFactionAt(ps, faction);
|
||||||
|
}
|
||||||
|
|
||||||
|
// REMOVE
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeAt(PS ps)
|
||||||
|
{
|
||||||
|
if (ps == null) return;
|
||||||
|
BoardColl coll = this.getForWorld(ps.getWorld());
|
||||||
|
if (coll == null) return;
|
||||||
|
coll.removeAt(ps);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeAll(Faction faction)
|
||||||
|
{
|
||||||
|
for (BoardColl coll : this.getColls())
|
||||||
|
{
|
||||||
|
coll.removeAll(faction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clean()
|
||||||
|
{
|
||||||
|
for (BoardColl coll : this.getColls())
|
||||||
|
{
|
||||||
|
coll.clean();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// COUNT
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount(Faction faction)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
for (BoardColl coll : this.getColls())
|
||||||
|
{
|
||||||
|
ret += coll.getCount(faction);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// NEARBY DETECTION
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isBorderPs(PS ps)
|
||||||
|
{
|
||||||
|
if (ps == null) return false;
|
||||||
|
BoardColl coll = this.getForWorld(ps.getWorld());
|
||||||
|
if (coll == null) return false;
|
||||||
|
return coll.isBorderPs(ps);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isConnectedPs(PS ps, Faction faction)
|
||||||
|
{
|
||||||
|
if (ps == null) return false;
|
||||||
|
BoardColl coll = this.getForWorld(ps.getWorld());
|
||||||
|
if (coll == null) return false;
|
||||||
|
return coll.isConnectedPs(ps, faction);
|
||||||
|
}
|
||||||
|
|
||||||
|
// MAP GENERATION
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<String> getMap(RelationParticipator observer, PS centerPs, double inDegrees)
|
||||||
|
{
|
||||||
|
if (centerPs == null) return null;
|
||||||
|
BoardColl coll = this.getForWorld(centerPs.getWorld());
|
||||||
|
if (coll == null) return null;
|
||||||
|
return coll.getMap(observer, centerPs, inDegrees);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -41,7 +41,7 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
|
|
||||||
public static FPlayer get(Object oid)
|
public static FPlayer get(Object oid)
|
||||||
{
|
{
|
||||||
return FPlayerColl.get().get(oid);
|
return FPlayerColls.get().get2(oid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -200,8 +200,8 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
// This method never returns null
|
// This method never returns null
|
||||||
public Faction getFaction()
|
public Faction getFaction()
|
||||||
{
|
{
|
||||||
Faction ret = FactionColl.get().get(this.getFactionId());
|
Faction ret = FactionColls.get().get(this).get(this.getFactionId());
|
||||||
if (ret == null) ret = FactionColl.get().get(Const.FACTIONID_NONE);
|
if (ret == null) ret = FactionColls.get().get(this).get(Const.FACTIONID_NONE);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,15 +235,15 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
// Next we must be attached and inited
|
// Next we must be attached and inited
|
||||||
if (!this.attached()) return;
|
if (!this.attached()) return;
|
||||||
if (!this.getColl().inited()) return;
|
if (!this.getColl().inited()) return;
|
||||||
if (!FactionColl.get().inited()) return;
|
if (!FactionColls.get().get(this).inited()) return;
|
||||||
|
|
||||||
// Spout Derp
|
// Spout Derp
|
||||||
SpoutFeatures.updateTitle(this, null);
|
SpoutFeatures.updateTitle(this, null);
|
||||||
SpoutFeatures.updateTitle(null, this);
|
SpoutFeatures.updateTitle(null, this);
|
||||||
|
|
||||||
// Update index
|
// Update index
|
||||||
Faction oldFaction = FactionColl.get().get(oldFactionId);
|
Faction oldFaction = FactionColls.get().get(this).get(oldFactionId);
|
||||||
Faction faction = FactionColl.get().get(factionId);
|
Faction faction = FactionColls.get().get(this).get(factionId);
|
||||||
|
|
||||||
oldFaction.fplayers.remove(this);
|
oldFaction.fplayers.remove(this);
|
||||||
faction.fplayers.add(this);
|
faction.fplayers.add(this);
|
||||||
@ -596,7 +596,7 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
public Rel getRelationToLocation()
|
public Rel getRelationToLocation()
|
||||||
{
|
{
|
||||||
// TODO: Use some built in system to get sender
|
// TODO: Use some built in system to get sender
|
||||||
return BoardColl.get().getFactionAt(PS.valueOf(this.getPlayer())).getRelationTo(this);
|
return BoardColls.get().getFactionAt(PS.valueOf(this.getPlayer())).getRelationTo(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -626,13 +626,13 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
public boolean isInOwnTerritory()
|
public boolean isInOwnTerritory()
|
||||||
{
|
{
|
||||||
// TODO: Use Mixin to get this PS instead
|
// TODO: Use Mixin to get this PS instead
|
||||||
return BoardColl.get().getFactionAt(PS.valueOf(this.getPlayer())) == this.getFaction();
|
return BoardColls.get().getFactionAt(Mixin.getSenderPs(this.getId())) == this.getFaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInEnemyTerritory()
|
public boolean isInEnemyTerritory()
|
||||||
{
|
{
|
||||||
// TODO: Use Mixin to get this PS instead
|
// TODO: Use Mixin to get this PS instead
|
||||||
return BoardColl.get().getFactionAt(PS.valueOf(this.getPlayer())).getRelationTo(this) == Rel.ENEMY;
|
return BoardColls.get().getFactionAt(Mixin.getSenderPs(this.getId())).getRelationTo(this) == Rel.ENEMY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendFactionHereMessage()
|
public void sendFactionHereMessage()
|
||||||
@ -641,7 +641,7 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Faction factionHere = BoardColl.get().getFactionAt(this.getCurrentChunk());
|
Faction factionHere = BoardColls.get().getFactionAt(this.getCurrentChunk());
|
||||||
String msg = Txt.parse("<i>")+" ~ "+factionHere.getTag(this);
|
String msg = Txt.parse("<i>")+" ~ "+factionHere.getTag(this);
|
||||||
if (factionHere.hasDescription())
|
if (factionHere.hasDescription())
|
||||||
{
|
{
|
||||||
@ -705,7 +705,7 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
if (myFaction.isNormal() && !permanent && myFaction.getFPlayers().isEmpty())
|
if (myFaction.isNormal() && !permanent && myFaction.getFPlayers().isEmpty())
|
||||||
{
|
{
|
||||||
// Remove this faction
|
// Remove this faction
|
||||||
for (FPlayer fplayer : FPlayerColl.get().getAllOnline())
|
for (FPlayer fplayer : FPlayerColls.get().get(this).getAllOnline())
|
||||||
{
|
{
|
||||||
fplayer.msg("<i>%s<i> was disbanded.", myFaction.describeTo(fplayer, true));
|
fplayer.msg("<i>%s<i> was disbanded.", myFaction.describeTo(fplayer, true));
|
||||||
}
|
}
|
||||||
@ -723,7 +723,7 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
String error = null;
|
String error = null;
|
||||||
|
|
||||||
Faction myFaction = this.getFaction();
|
Faction myFaction = this.getFaction();
|
||||||
Faction currentFaction = BoardColl.get().getFactionAt(ps);
|
Faction currentFaction = BoardColls.get().getFactionAt(ps);
|
||||||
int ownedLand = forFaction.getLandCount();
|
int ownedLand = forFaction.getLandCount();
|
||||||
|
|
||||||
if (ConfServer.worldGuardChecking && Worldguard.checkForRegionsInChunk(ps))
|
if (ConfServer.worldGuardChecking && Worldguard.checkForRegionsInChunk(ps))
|
||||||
@ -772,7 +772,7 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
ConfServer.claimsMustBeConnected
|
ConfServer.claimsMustBeConnected
|
||||||
&& ! this.isUsingAdminMode()
|
&& ! this.isUsingAdminMode()
|
||||||
&& myFaction.getLandCountInWorld(ps.getWorld()) > 0
|
&& myFaction.getLandCountInWorld(ps.getWorld()) > 0
|
||||||
&& !BoardColl.get().isConnectedPs(ps, myFaction)
|
&& !BoardColls.get().isConnectedPs(ps, myFaction)
|
||||||
&& (!ConfServer.claimsCanBeUnconnectedIfOwnedByOtherFaction || !currentFaction.isNormal())
|
&& (!ConfServer.claimsCanBeUnconnectedIfOwnedByOtherFaction || !currentFaction.isNormal())
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -788,7 +788,7 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
// TODO more messages WARN current faction most importantly
|
// TODO more messages WARN current faction most importantly
|
||||||
error = Txt.parse("%s<i> owns this land and is strong enough to keep it.", currentFaction.getTag(this));
|
error = Txt.parse("%s<i> owns this land and is strong enough to keep it.", currentFaction.getTag(this));
|
||||||
}
|
}
|
||||||
else if ( ! BoardColl.get().isBorderPs(ps))
|
else if ( ! BoardColls.get().isBorderPs(ps))
|
||||||
{
|
{
|
||||||
error = Txt.parse("<b>You must start claiming land at the border of the territory.");
|
error = Txt.parse("<b>You must start claiming land at the border of the territory.");
|
||||||
}
|
}
|
||||||
@ -806,7 +806,7 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
public boolean attemptClaim(Faction forFaction, PS psChunk, boolean notifyFailure)
|
public boolean attemptClaim(Faction forFaction, PS psChunk, boolean notifyFailure)
|
||||||
{
|
{
|
||||||
psChunk = psChunk.getChunk(true);
|
psChunk = psChunk.getChunk(true);
|
||||||
Faction currentFaction = BoardColl.get().getFactionAt(psChunk);
|
Faction currentFaction = BoardColls.get().getFactionAt(psChunk);
|
||||||
int ownedLand = forFaction.getLandCount();
|
int ownedLand = forFaction.getLandCount();
|
||||||
|
|
||||||
if ( ! this.canClaimForFactionAtLocation(forFaction, psChunk, notifyFailure)) return false;
|
if ( ! this.canClaimForFactionAtLocation(forFaction, psChunk, notifyFailure)) return false;
|
||||||
@ -820,7 +820,7 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
// TODO: The economy integration should cancel the event above!
|
// TODO: The economy integration should cancel the event above!
|
||||||
// Calculate the cost to claim the area
|
// Calculate the cost to claim the area
|
||||||
double cost = Econ.calculateClaimCost(ownedLand, currentFaction.isNormal());
|
double cost = Econ.calculateClaimCost(ownedLand, currentFaction.isNormal());
|
||||||
if (ConfServer.econClaimUnconnectedFee != 0.0 && forFaction.getLandCountInWorld(psChunk.getWorld()) > 0 && !BoardColl.get().isConnectedPs(psChunk, forFaction))
|
if (ConfServer.econClaimUnconnectedFee != 0.0 && forFaction.getLandCountInWorld(psChunk.getWorld()) > 0 && !BoardColls.get().isConnectedPs(psChunk, forFaction))
|
||||||
{
|
{
|
||||||
cost += ConfServer.econClaimUnconnectedFee;
|
cost += ConfServer.econClaimUnconnectedFee;
|
||||||
}
|
}
|
||||||
@ -841,7 +841,7 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
fp.msg("<h>%s<i> claimed land for <h>%s<i> from <h>%s<i>.", this.describeTo(fp, true), forFaction.describeTo(fp), currentFaction.describeTo(fp));
|
fp.msg("<h>%s<i> claimed land for <h>%s<i> from <h>%s<i>.", this.describeTo(fp, true), forFaction.describeTo(fp), currentFaction.describeTo(fp));
|
||||||
}
|
}
|
||||||
|
|
||||||
BoardColl.get().setFactionAt(psChunk, forFaction);
|
BoardColls.get().setFactionAt(psChunk, forFaction);
|
||||||
SpoutFeatures.updateTerritoryDisplayLoc(psChunk);
|
SpoutFeatures.updateTerritoryDisplayLoc(psChunk);
|
||||||
|
|
||||||
if (MConf.get().logLandClaims)
|
if (MConf.get().logLandClaims)
|
||||||
|
@ -1,73 +1,28 @@
|
|||||||
package com.massivecraft.factions.entity;
|
package com.massivecraft.factions.entity;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.ConfServer;
|
import com.massivecraft.factions.ConfServer;
|
||||||
import com.massivecraft.factions.Const;
|
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.Rel;
|
import com.massivecraft.factions.Rel;
|
||||||
import com.massivecraft.mcore.mixin.Mixin;
|
import com.massivecraft.mcore.mixin.Mixin;
|
||||||
import com.massivecraft.mcore.store.MStore;
|
import com.massivecraft.mcore.store.MStore;
|
||||||
import com.massivecraft.mcore.store.SenderColl;
|
import com.massivecraft.mcore.store.SenderColl;
|
||||||
import com.massivecraft.mcore.util.DiscUtil;
|
|
||||||
import com.massivecraft.mcore.util.TimeUnit;
|
import com.massivecraft.mcore.util.TimeUnit;
|
||||||
import com.massivecraft.mcore.xlib.gson.reflect.TypeToken;
|
|
||||||
|
|
||||||
public class FPlayerColl extends SenderColl<FPlayer>
|
public class FPlayerColl extends SenderColl<FPlayer>
|
||||||
{
|
{
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// INSTANCE & CONSTRUCT
|
// CONSTRUCT
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
private static FPlayerColl i = new FPlayerColl();
|
public FPlayerColl(String name)
|
||||||
public static FPlayerColl get() { return i; }
|
|
||||||
private FPlayerColl()
|
|
||||||
{
|
{
|
||||||
super(Const.COLLECTION_BASENAME_PLAYER, FPlayer.class, MStore.getDb(ConfServer.dburi), Factions.get());
|
super(name, FPlayer.class, MStore.getDb(ConfServer.dburi), Factions.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE: COLL
|
// OVERRIDE: COLL
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
// TODO: Init and migration routine!
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init()
|
|
||||||
{
|
|
||||||
super.init();
|
|
||||||
|
|
||||||
this.migrate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void migrate()
|
|
||||||
{
|
|
||||||
// Create file objects
|
|
||||||
File oldFile = new File(Factions.get().getDataFolder(), "players.json");
|
|
||||||
File newFile = new File(Factions.get().getDataFolder(), "players.json.migrated");
|
|
||||||
|
|
||||||
// Already migrated?
|
|
||||||
if ( ! oldFile.exists()) return;
|
|
||||||
|
|
||||||
// Read the file content through GSON.
|
|
||||||
Type type = new TypeToken<Map<String, FPlayer>>(){}.getType();
|
|
||||||
Map<String, FPlayer> id2fplayer = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type);
|
|
||||||
|
|
||||||
// Set the data
|
|
||||||
for (Entry<String, FPlayer> entry : id2fplayer.entrySet())
|
|
||||||
{
|
|
||||||
String playerId = entry.getKey();
|
|
||||||
FPlayer fplayer = entry.getValue();
|
|
||||||
FPlayerColl.get().create(playerId).load(fplayer);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mark as migrated
|
|
||||||
oldFile.renameTo(newFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected synchronized String attach(FPlayer entity, Object oid, boolean noteChange)
|
protected synchronized String attach(FPlayer entity, Object oid, boolean noteChange)
|
||||||
{
|
{
|
||||||
@ -75,7 +30,7 @@ public class FPlayerColl extends SenderColl<FPlayer>
|
|||||||
|
|
||||||
// If inited ...
|
// If inited ...
|
||||||
if (!this.inited()) return ret;
|
if (!this.inited()) return ret;
|
||||||
if (!FactionColl.get().inited()) return ret;
|
if (!FactionColls.get().getForUniverse(this.getUniverse()).inited()) return ret;
|
||||||
|
|
||||||
// ... update the index.
|
// ... update the index.
|
||||||
Faction faction = entity.getFaction();
|
Faction faction = entity.getFaction();
|
||||||
@ -108,7 +63,7 @@ public class FPlayerColl extends SenderColl<FPlayer>
|
|||||||
{
|
{
|
||||||
for (FPlayer fplayer : this.getAll())
|
for (FPlayer fplayer : this.getAll())
|
||||||
{
|
{
|
||||||
if (FactionColl.get().containsId(fplayer.getFactionId())) continue;
|
if (FactionColls.get().get(this).containsId(fplayer.getFactionId())) continue;
|
||||||
|
|
||||||
Factions.get().log("Reset faction data (invalid faction) for player "+fplayer.getName());
|
Factions.get().log("Reset faction data (invalid faction) for player "+fplayer.getName());
|
||||||
fplayer.resetFactionData(false);
|
fplayer.resetFactionData(false);
|
||||||
|
103
src/com/massivecraft/factions/entity/FPlayerColls.java
Normal file
103
src/com/massivecraft/factions/entity/FPlayerColls.java
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
package com.massivecraft.factions.entity;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.Const;
|
||||||
|
import com.massivecraft.factions.Factions;
|
||||||
|
import com.massivecraft.mcore.MCore;
|
||||||
|
import com.massivecraft.mcore.store.Coll;
|
||||||
|
import com.massivecraft.mcore.store.Colls;
|
||||||
|
import com.massivecraft.mcore.store.Entity;
|
||||||
|
import com.massivecraft.mcore.usys.Aspect;
|
||||||
|
import com.massivecraft.mcore.util.DiscUtil;
|
||||||
|
import com.massivecraft.mcore.util.MUtil;
|
||||||
|
import com.massivecraft.mcore.xlib.gson.reflect.TypeToken;
|
||||||
|
|
||||||
|
public class FPlayerColls extends Colls<FPlayerColl, FPlayer>
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INSTANCE & CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
private static FPlayerColls i = new FPlayerColls();
|
||||||
|
public static FPlayerColls get() { return i; }
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// OVERRIDE: COLLS
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FPlayerColl createColl(String collName)
|
||||||
|
{
|
||||||
|
return new FPlayerColl(collName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Aspect getAspect()
|
||||||
|
{
|
||||||
|
return Factions.get().getAspect();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getBasename()
|
||||||
|
{
|
||||||
|
return Const.COLLECTION_BASENAME_PLAYER;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FPlayerColl get(Object o)
|
||||||
|
{
|
||||||
|
if (o == null) return null;
|
||||||
|
|
||||||
|
if (o instanceof Entity)
|
||||||
|
{
|
||||||
|
return this.getForUniverse(((Entity<?>)o).getUniverse());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o instanceof Coll)
|
||||||
|
{
|
||||||
|
return this.getForUniverse(((Coll<?>)o).getUniverse());
|
||||||
|
}
|
||||||
|
|
||||||
|
String worldName = MUtil.extract(String.class, "worldName", o);
|
||||||
|
if (worldName == null) return null;
|
||||||
|
return this.getForWorld(worldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init()
|
||||||
|
{
|
||||||
|
super.init();
|
||||||
|
|
||||||
|
this.migrate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void migrate()
|
||||||
|
{
|
||||||
|
// Create file objects
|
||||||
|
File oldFile = new File(Factions.get().getDataFolder(), "players.json");
|
||||||
|
File newFile = new File(Factions.get().getDataFolder(), "players.json.migrated");
|
||||||
|
|
||||||
|
// Already migrated?
|
||||||
|
if ( ! oldFile.exists()) return;
|
||||||
|
|
||||||
|
// Read the file content through GSON.
|
||||||
|
Type type = new TypeToken<Map<String, FPlayer>>(){}.getType();
|
||||||
|
Map<String, FPlayer> id2fplayer = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type);
|
||||||
|
|
||||||
|
// Set the data
|
||||||
|
for (Entry<String, FPlayer> entry : id2fplayer.entrySet())
|
||||||
|
{
|
||||||
|
String playerId = entry.getKey();
|
||||||
|
FPlayer fplayer = entry.getValue();
|
||||||
|
FPlayerColls.get().getForUniverse(MCore.DEFAULT).create(playerId).load(fplayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark as migrated
|
||||||
|
oldFile.renameTo(newFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -36,7 +36,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
|||||||
|
|
||||||
public static Faction get(Object oid)
|
public static Faction get(Object oid)
|
||||||
{
|
{
|
||||||
return FactionColl.get().get(oid);
|
return FactionColls.get().get2(oid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -238,7 +238,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
|||||||
{
|
{
|
||||||
if (ps == null) return true;
|
if (ps == null) return true;
|
||||||
if (!ConfServer.homesMustBeInClaimedTerritory) return true;
|
if (!ConfServer.homesMustBeInClaimedTerritory) return true;
|
||||||
if (BoardColl.get().getFactionAt(ps) == this) return true;
|
if (BoardColls.get().getFactionAt(ps) == this) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,7 +451,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
|||||||
{
|
{
|
||||||
ret.put(rel, new ArrayList<String>());
|
ret.put(rel, new ArrayList<String>());
|
||||||
}
|
}
|
||||||
for (Faction faction : FactionColl.get().getAll())
|
for (Faction faction : FactionColls.get().get(this).getAll())
|
||||||
{
|
{
|
||||||
Rel relation = faction.getRelationTo(this);
|
Rel relation = faction.getRelationTo(this);
|
||||||
if (onlyNonNeutral && relation == Rel.NEUTRAL) continue;
|
if (onlyNonNeutral && relation == Rel.NEUTRAL) continue;
|
||||||
@ -715,11 +715,11 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
|||||||
|
|
||||||
public int getLandCount()
|
public int getLandCount()
|
||||||
{
|
{
|
||||||
return BoardColl.get().getCount(this);
|
return BoardColls.get().getCount(this);
|
||||||
}
|
}
|
||||||
public int getLandCountInWorld(String worldName)
|
public int getLandCountInWorld(String worldName)
|
||||||
{
|
{
|
||||||
return BoardColl.get().get(worldName).getCount(this);
|
return BoardColls.get().get(worldName).getCount(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasLandInflation()
|
public boolean hasLandInflation()
|
||||||
@ -743,7 +743,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
|||||||
String factionId = this.getId();
|
String factionId = this.getId();
|
||||||
if (factionId == null) return;
|
if (factionId == null) return;
|
||||||
|
|
||||||
for (FPlayer fplayer : FPlayerColl.get().getAll())
|
for (FPlayer fplayer : FPlayerColls.get().get(this).getAll())
|
||||||
{
|
{
|
||||||
if (!MUtil.equals(factionId, fplayer.getFactionId())) continue;
|
if (!MUtil.equals(factionId, fplayer.getFactionId())) continue;
|
||||||
this.fplayers.add(fplayer);
|
this.fplayers.add(fplayer);
|
||||||
@ -805,7 +805,8 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
|||||||
List<CommandSender> ret = new ArrayList<CommandSender>();
|
List<CommandSender> ret = new ArrayList<CommandSender>();
|
||||||
for (CommandSender player : SenderUtil.getOnlineSenders())
|
for (CommandSender player : SenderUtil.getOnlineSenders())
|
||||||
{
|
{
|
||||||
FPlayer fplayer = FPlayerColl.get().get(player);
|
FPlayer fplayer = FPlayer.get(player);
|
||||||
|
if (!MUtil.equals(fplayer.getUniverse(), this.getUniverse())) continue;
|
||||||
if (fplayer.getFaction() != this) continue;
|
if (fplayer.getFaction() != this) continue;
|
||||||
ret.add(player);
|
ret.add(player);
|
||||||
}
|
}
|
||||||
@ -817,7 +818,8 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
|||||||
List<Player> ret = new ArrayList<Player>();
|
List<Player> ret = new ArrayList<Player>();
|
||||||
for (Player player : Bukkit.getOnlinePlayers())
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
FPlayer fplayer = FPlayerColl.get().get(player);
|
FPlayer fplayer = FPlayer.get(player);
|
||||||
|
if (!MUtil.equals(fplayer.getUniverse(), this.getUniverse())) continue;
|
||||||
if (fplayer.getFaction() != this) continue;
|
if (fplayer.getFaction() != this) continue;
|
||||||
ret.add(player);
|
ret.add(player);
|
||||||
}
|
}
|
||||||
@ -856,7 +858,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
|||||||
Factions.get().log("The faction "+this.getTag()+" ("+this.getId()+") has been disbanded since it has no members left.");
|
Factions.get().log("The faction "+this.getTag()+" ("+this.getId()+") has been disbanded since it has no members left.");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (FPlayer fplayer : FPlayerColl.get().getAllOnline())
|
for (FPlayer fplayer : FPlayerColls.get().get(this).getAllOnline())
|
||||||
{
|
{
|
||||||
fplayer.msg("The faction %s<i> was disbanded.", this.getTag(fplayer));
|
fplayer.msg("The faction %s<i> was disbanded.", this.getTag(fplayer));
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,13 @@
|
|||||||
package com.massivecraft.factions.entity;
|
package com.massivecraft.factions.entity;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
import com.massivecraft.mcore.money.Money;
|
import com.massivecraft.mcore.money.Money;
|
||||||
import com.massivecraft.mcore.store.Coll;
|
import com.massivecraft.mcore.store.Coll;
|
||||||
import com.massivecraft.mcore.store.MStore;
|
import com.massivecraft.mcore.store.MStore;
|
||||||
import com.massivecraft.mcore.util.DiscUtil;
|
|
||||||
import com.massivecraft.mcore.util.Txt;
|
import com.massivecraft.mcore.util.Txt;
|
||||||
import com.massivecraft.mcore.xlib.gson.reflect.TypeToken;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.ConfServer;
|
import com.massivecraft.factions.ConfServer;
|
||||||
import com.massivecraft.factions.Const;
|
import com.massivecraft.factions.Const;
|
||||||
@ -26,14 +21,12 @@ import com.massivecraft.factions.util.MiscUtil;
|
|||||||
public class FactionColl extends Coll<Faction>
|
public class FactionColl extends Coll<Faction>
|
||||||
{
|
{
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// INSTANCE & CONSTRUCT
|
// CONSTRUCT
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
private static FactionColl i = new FactionColl();
|
public FactionColl(String name)
|
||||||
public static FactionColl get() { return i; }
|
|
||||||
private FactionColl()
|
|
||||||
{
|
{
|
||||||
super(Const.COLLECTION_BASENAME_FACTION, Faction.class, MStore.getDb(ConfServer.dburi), Factions.get());
|
super(name, Faction.class, MStore.getDb(ConfServer.dburi), Factions.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -45,37 +38,10 @@ public class FactionColl extends Coll<Faction>
|
|||||||
{
|
{
|
||||||
super.init();
|
super.init();
|
||||||
|
|
||||||
this.migrate();
|
|
||||||
this.createDefaultFactions();
|
this.createDefaultFactions();
|
||||||
this.reindexFPlayers();
|
this.reindexFPlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void migrate()
|
|
||||||
{
|
|
||||||
// Create file objects
|
|
||||||
File oldFile = new File(Factions.get().getDataFolder(), "factions.json");
|
|
||||||
File newFile = new File(Factions.get().getDataFolder(), "factions.json.migrated");
|
|
||||||
|
|
||||||
// Already migrated?
|
|
||||||
if ( ! oldFile.exists()) return;
|
|
||||||
|
|
||||||
// Read the file content through GSON.
|
|
||||||
Type type = new TypeToken<Map<String, Faction>>(){}.getType();
|
|
||||||
Map<String, Faction> id2faction = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type);
|
|
||||||
|
|
||||||
// Set the data
|
|
||||||
for (Entry<String, Faction> entry : id2faction.entrySet())
|
|
||||||
{
|
|
||||||
String factionId = entry.getKey();
|
|
||||||
Faction faction = entry.getValue();
|
|
||||||
|
|
||||||
FactionColl.get().create(factionId).load(faction);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mark as migrated
|
|
||||||
oldFile.renameTo(newFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected synchronized String attach(Faction faction, Object oid, boolean noteChange)
|
protected synchronized String attach(Faction faction, Object oid, boolean noteChange)
|
||||||
{
|
{
|
||||||
@ -97,19 +63,16 @@ public class FactionColl extends Coll<Faction>
|
|||||||
public Faction detachId(Object oid)
|
public Faction detachId(Object oid)
|
||||||
{
|
{
|
||||||
Faction faction = this.get(oid);
|
Faction faction = this.get(oid);
|
||||||
if (faction != null)
|
Money.set(faction, 0);
|
||||||
{
|
String universe = faction.getUniverse();
|
||||||
Money.set(faction, faction, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
Faction ret = super.detachId(oid);
|
Faction ret = super.detachId(oid);
|
||||||
|
|
||||||
// Clean the board
|
// Clean the board
|
||||||
// TODO: Use events for this instead?
|
BoardColls.get().getForUniverse(universe).clean();
|
||||||
BoardColl.get().clean();
|
|
||||||
|
|
||||||
// Clean the fplayers
|
// Clean the fplayers
|
||||||
FPlayerColl.get().clean();
|
FPlayerColls.get().getForUniverse(universe).clean();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
104
src/com/massivecraft/factions/entity/FactionColls.java
Normal file
104
src/com/massivecraft/factions/entity/FactionColls.java
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
package com.massivecraft.factions.entity;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.Const;
|
||||||
|
import com.massivecraft.factions.Factions;
|
||||||
|
import com.massivecraft.mcore.MCore;
|
||||||
|
import com.massivecraft.mcore.store.Coll;
|
||||||
|
import com.massivecraft.mcore.store.Colls;
|
||||||
|
import com.massivecraft.mcore.store.Entity;
|
||||||
|
import com.massivecraft.mcore.usys.Aspect;
|
||||||
|
import com.massivecraft.mcore.util.DiscUtil;
|
||||||
|
import com.massivecraft.mcore.util.MUtil;
|
||||||
|
import com.massivecraft.mcore.xlib.gson.reflect.TypeToken;
|
||||||
|
|
||||||
|
public class FactionColls extends Colls<FactionColl, Faction>
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INSTANCE & CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
private static FactionColls i = new FactionColls();
|
||||||
|
public static FactionColls get() { return i; }
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// OVERRIDE: COLLS
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FactionColl createColl(String collName)
|
||||||
|
{
|
||||||
|
return new FactionColl(collName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Aspect getAspect()
|
||||||
|
{
|
||||||
|
return Factions.get().getAspect();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getBasename()
|
||||||
|
{
|
||||||
|
return Const.COLLECTION_BASENAME_FACTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FactionColl get(Object o)
|
||||||
|
{
|
||||||
|
if (o == null) return null;
|
||||||
|
|
||||||
|
if (o instanceof Entity)
|
||||||
|
{
|
||||||
|
return this.getForUniverse(((Entity<?>)o).getUniverse());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o instanceof Coll)
|
||||||
|
{
|
||||||
|
return this.getForUniverse(((Coll<?>)o).getUniverse());
|
||||||
|
}
|
||||||
|
|
||||||
|
String worldName = MUtil.extract(String.class, "worldName", o);
|
||||||
|
if (worldName == null) return null;
|
||||||
|
return this.getForWorld(worldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init()
|
||||||
|
{
|
||||||
|
super.init();
|
||||||
|
|
||||||
|
this.migrate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void migrate()
|
||||||
|
{
|
||||||
|
// Create file objects
|
||||||
|
File oldFile = new File(Factions.get().getDataFolder(), "factions.json");
|
||||||
|
File newFile = new File(Factions.get().getDataFolder(), "factions.json.migrated");
|
||||||
|
|
||||||
|
// Already migrated?
|
||||||
|
if ( ! oldFile.exists()) return;
|
||||||
|
|
||||||
|
// Read the file content through GSON.
|
||||||
|
Type type = new TypeToken<Map<String, Faction>>(){}.getType();
|
||||||
|
Map<String, Faction> id2faction = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type);
|
||||||
|
|
||||||
|
// Set the data
|
||||||
|
for (Entry<String, Faction> entry : id2faction.entrySet())
|
||||||
|
{
|
||||||
|
String factionId = entry.getKey();
|
||||||
|
Faction faction = entry.getValue();
|
||||||
|
|
||||||
|
this.getForUniverse(MCore.DEFAULT).create(factionId).load(faction);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark as migrated
|
||||||
|
oldFile.renameTo(newFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package com.massivecraft.factions.integration;
|
package com.massivecraft.factions.integration;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -14,7 +13,6 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.massivecraft.factions.entity.FPlayer;
|
import com.massivecraft.factions.entity.FPlayer;
|
||||||
import com.massivecraft.factions.entity.FPlayerColl;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
import com.massivecraft.factions.entity.Faction;
|
||||||
import com.massivecraft.factions.util.HealthBarUtil;
|
import com.massivecraft.factions.util.HealthBarUtil;
|
||||||
import com.massivecraft.mcore.ps.PS;
|
import com.massivecraft.mcore.ps.PS;
|
||||||
@ -252,17 +250,16 @@ public class SpoutFeatures
|
|||||||
{
|
{
|
||||||
if ( ! isEnabled()) return;
|
if ( ! isEnabled()) return;
|
||||||
|
|
||||||
Collection<FPlayer> players = FPlayerColl.get().getAllOnline();
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
|
|
||||||
for (FPlayer player : players)
|
|
||||||
{
|
{
|
||||||
|
FPlayer fplayer = FPlayer.get(player);
|
||||||
if (chunk == null)
|
if (chunk == null)
|
||||||
{
|
{
|
||||||
mainListener.updateTerritoryDisplay(player, false);
|
mainListener.updateTerritoryDisplay(fplayer, false);
|
||||||
}
|
}
|
||||||
else if (player.getCurrentChunk().equals(chunk))
|
else if (fplayer.getCurrentChunk().equals(chunk))
|
||||||
{
|
{
|
||||||
mainListener.updateTerritoryDisplay(player, true);
|
mainListener.updateTerritoryDisplay(fplayer, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -281,12 +278,13 @@ public class SpoutFeatures
|
|||||||
|
|
||||||
chunk = chunk.getChunk(true);
|
chunk = chunk.getChunk(true);
|
||||||
|
|
||||||
Collection<FPlayer> players = FPlayerColl.get().getAllOnline();
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
|
|
||||||
for (FPlayer player : players)
|
|
||||||
{
|
{
|
||||||
if (chunk == null || player.getCurrentChunk().equals(chunk))
|
FPlayer fplayer = FPlayer.get(player);
|
||||||
mainListener.updateAccessInfo(player);
|
if (chunk == null || fplayer.getCurrentChunk().equals(chunk))
|
||||||
|
{
|
||||||
|
mainListener.updateAccessInfo(fplayer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,9 +11,8 @@ import org.bukkit.event.Listener;
|
|||||||
import com.massivecraft.factions.ConfServer;
|
import com.massivecraft.factions.ConfServer;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.TerritoryAccess;
|
import com.massivecraft.factions.TerritoryAccess;
|
||||||
import com.massivecraft.factions.entity.BoardColl;
|
import com.massivecraft.factions.entity.BoardColls;
|
||||||
import com.massivecraft.factions.entity.FPlayer;
|
import com.massivecraft.factions.entity.FPlayer;
|
||||||
import com.massivecraft.factions.entity.FPlayerColl;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
import com.massivecraft.factions.entity.Faction;
|
||||||
import com.massivecraft.mcore.ps.PS;
|
import com.massivecraft.mcore.ps.PS;
|
||||||
|
|
||||||
@ -29,7 +28,7 @@ public class SpoutMainListener implements Listener
|
|||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onSpoutCraftEnable(SpoutCraftEnableEvent event)
|
public void onSpoutCraftEnable(SpoutCraftEnableEvent event)
|
||||||
{
|
{
|
||||||
final FPlayer me = FPlayerColl.get().get(event.getPlayer());
|
final FPlayer me = FPlayer.get(event.getPlayer());
|
||||||
|
|
||||||
SpoutFeatures.updateTitle(me, null);
|
SpoutFeatures.updateTitle(me, null);
|
||||||
SpoutFeatures.updateTitle(null, me);
|
SpoutFeatures.updateTitle(null, me);
|
||||||
@ -90,7 +89,7 @@ public class SpoutMainListener implements Listener
|
|||||||
private void doLabels(FPlayer player, SpoutPlayer sPlayer, boolean notify)
|
private void doLabels(FPlayer player, SpoutPlayer sPlayer, boolean notify)
|
||||||
{
|
{
|
||||||
PS here = player.getCurrentChunk();
|
PS here = player.getCurrentChunk();
|
||||||
Faction factionHere = BoardColl.get().getFactionAt(here);
|
Faction factionHere = BoardColls.get().getFactionAt(here);
|
||||||
String tag = factionHere.getColorTo(player).toString() + factionHere.getTag();
|
String tag = factionHere.getColorTo(player).toString() + factionHere.getTag();
|
||||||
|
|
||||||
// ----------------------
|
// ----------------------
|
||||||
@ -181,7 +180,7 @@ public class SpoutMainListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
String msg = "";
|
String msg = "";
|
||||||
TerritoryAccess access = BoardColl.get().getTerritoryAccessAt(here);
|
TerritoryAccess access = BoardColls.get().getTerritoryAccessAt(here);
|
||||||
|
|
||||||
if ( ! access.isDefault())
|
if ( ! access.isDefault())
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ import com.massivecraft.factions.entity.MConf;
|
|||||||
|
|
||||||
public class FactionChannel extends FactionsChannelAbstract
|
public class FactionChannel extends FactionsChannelAbstract
|
||||||
{
|
{
|
||||||
public static final Set<Rel> targetRelations = EnumSet.of(Rel.MEMBER);
|
public static final Set<Rel> targetRelations = EnumSet.of(Rel.MEMBER, Rel.RECRUIT);
|
||||||
@Override public Set<Rel> getTargetRelations() { return targetRelations; }
|
@Override public Set<Rel> getTargetRelations() { return targetRelations; }
|
||||||
|
|
||||||
@Override public String getName() { return MConf.get().herochatFactionName; }
|
@Override public String getName() { return MConf.get().herochatFactionName; }
|
||||||
|
@ -24,7 +24,6 @@ import com.dthielke.herochat.MessageNotFoundException;
|
|||||||
import com.dthielke.herochat.util.Messaging;
|
import com.dthielke.herochat.util.Messaging;
|
||||||
import com.massivecraft.factions.Rel;
|
import com.massivecraft.factions.Rel;
|
||||||
import com.massivecraft.factions.entity.FPlayer;
|
import com.massivecraft.factions.entity.FPlayer;
|
||||||
import com.massivecraft.factions.entity.FPlayerColl;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
import com.massivecraft.factions.entity.Faction;
|
||||||
|
|
||||||
public abstract class FactionsChannelAbstract implements Channel
|
public abstract class FactionsChannelAbstract implements Channel
|
||||||
@ -206,30 +205,27 @@ public abstract class FactionsChannelAbstract implements Channel
|
|||||||
return this.getMutes().contains(name.toLowerCase());
|
return this.getMutes().contains(name.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public abstract Set<Rel> getTargetRelations();
|
public abstract Set<Rel> getTargetRelations();
|
||||||
|
|
||||||
// TODO: When I add in universes I will need to separate the channel per universe.
|
|
||||||
public Set<Player> getRecipients(Player sender)
|
public Set<Player> getRecipients(Player sender)
|
||||||
{
|
{
|
||||||
Set<Player> ret = new HashSet<Player>();
|
Set<Player> ret = new HashSet<Player>();
|
||||||
|
|
||||||
FPlayer fpsender = FPlayerColl.get().get(sender);
|
FPlayer fpsender = FPlayer.get(sender);
|
||||||
Faction faction = fpsender.getFaction();
|
Faction faction = fpsender.getFaction();
|
||||||
ret.addAll(faction.getOnlinePlayers());
|
String universe = fpsender.getUniverse();
|
||||||
|
|
||||||
for (FPlayer fplayer : FPlayerColl.get().getAllOnline())
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if(this.getTargetRelations().contains(faction.getRelationTo(fplayer)))
|
FPlayer frecipient = FPlayer.get(player);
|
||||||
{
|
if (!frecipient.getUniverse().equals(universe)) continue;
|
||||||
ret.add(fplayer.getPlayer());
|
if (!this.getTargetRelations().contains(faction.getRelationTo(frecipient))) continue;
|
||||||
}
|
ret.add(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processChat(ChannelChatEvent event)
|
public void processChat(ChannelChatEvent event)
|
||||||
{
|
{
|
||||||
|
@ -50,9 +50,8 @@ import com.massivecraft.factions.FFlag;
|
|||||||
import com.massivecraft.factions.FPerm;
|
import com.massivecraft.factions.FPerm;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.Rel;
|
import com.massivecraft.factions.Rel;
|
||||||
import com.massivecraft.factions.entity.BoardColl;
|
import com.massivecraft.factions.entity.BoardColls;
|
||||||
import com.massivecraft.factions.entity.FPlayer;
|
import com.massivecraft.factions.entity.FPlayer;
|
||||||
import com.massivecraft.factions.entity.FPlayerColl;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
import com.massivecraft.factions.entity.Faction;
|
||||||
import com.massivecraft.factions.entity.MConf;
|
import com.massivecraft.factions.entity.MConf;
|
||||||
import com.massivecraft.factions.event.FactionsEventPowerChange;
|
import com.massivecraft.factions.event.FactionsEventPowerChange;
|
||||||
@ -90,10 +89,10 @@ public class FactionsListenerMain implements Listener
|
|||||||
{
|
{
|
||||||
// If a player dies ...
|
// If a player dies ...
|
||||||
Player player = event.getEntity();
|
Player player = event.getEntity();
|
||||||
FPlayer fplayer = FPlayerColl.get().get(player);
|
FPlayer fplayer = FPlayer.get(player);
|
||||||
|
|
||||||
// ... and powerloss can happen here ...
|
// ... and powerloss can happen here ...
|
||||||
Faction faction = BoardColl.get().getFactionAt(PS.valueOf(player));
|
Faction faction = BoardColls.get().getFactionAt(PS.valueOf(player));
|
||||||
|
|
||||||
if (!faction.getFlag(FFlag.POWERLOSS))
|
if (!faction.getFlag(FFlag.POWERLOSS))
|
||||||
{
|
{
|
||||||
@ -170,7 +169,7 @@ public class FactionsListenerMain implements Listener
|
|||||||
Entity edefender = event.getEntity();
|
Entity edefender = event.getEntity();
|
||||||
if (!(edefender instanceof Player)) return true;
|
if (!(edefender instanceof Player)) return true;
|
||||||
Player defender = (Player)edefender;
|
Player defender = (Player)edefender;
|
||||||
FPlayer fdefender = FPlayerColl.get().get(edefender);
|
FPlayer fdefender = FPlayer.get(edefender);
|
||||||
|
|
||||||
// ... and the attacker is someone else ...
|
// ... and the attacker is someone else ...
|
||||||
Entity eattacker = event.getDamager();
|
Entity eattacker = event.getDamager();
|
||||||
@ -182,7 +181,7 @@ public class FactionsListenerMain implements Listener
|
|||||||
|
|
||||||
// ... gather defender PS and faction information ...
|
// ... gather defender PS and faction information ...
|
||||||
PS defenderPs = PS.valueOf(defender);
|
PS defenderPs = PS.valueOf(defender);
|
||||||
Faction defenderPsFaction = BoardColl.get().getFactionAt(defenderPs);
|
Faction defenderPsFaction = BoardColls.get().getFactionAt(defenderPs);
|
||||||
|
|
||||||
// ... PVP flag may cause a damage block ...
|
// ... PVP flag may cause a damage block ...
|
||||||
if (defenderPsFaction.getFlag(FFlag.PVP) == false)
|
if (defenderPsFaction.getFlag(FFlag.PVP) == false)
|
||||||
@ -191,7 +190,7 @@ public class FactionsListenerMain implements Listener
|
|||||||
{
|
{
|
||||||
if (notify)
|
if (notify)
|
||||||
{
|
{
|
||||||
FPlayer attacker = FPlayerColl.get().get((Player)eattacker);
|
FPlayer attacker = FPlayer.get(eattacker);
|
||||||
attacker.msg("<i>PVP is disabled in %s.", defenderPsFaction.describeTo(attacker));
|
attacker.msg("<i>PVP is disabled in %s.", defenderPsFaction.describeTo(attacker));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -202,14 +201,14 @@ public class FactionsListenerMain implements Listener
|
|||||||
// ... and if the attacker is a player ...
|
// ... and if the attacker is a player ...
|
||||||
if (!(eattacker instanceof Player)) return true;
|
if (!(eattacker instanceof Player)) return true;
|
||||||
Player attacker = (Player)eattacker;
|
Player attacker = (Player)eattacker;
|
||||||
FPlayer fattacker = FPlayerColl.get().get(attacker);
|
FPlayer fattacker = FPlayer.get(attacker);
|
||||||
|
|
||||||
// ... does this player bypass all protection? ...
|
// ... does this player bypass all protection? ...
|
||||||
if (MConf.get().playersWhoBypassAllProtection.contains(attacker.getName())) return true;
|
if (MConf.get().playersWhoBypassAllProtection.contains(attacker.getName())) return true;
|
||||||
|
|
||||||
// ... gather attacker PS and faction information ...
|
// ... gather attacker PS and faction information ...
|
||||||
PS attackerPs = PS.valueOf(attacker);
|
PS attackerPs = PS.valueOf(attacker);
|
||||||
Faction attackerPsFaction = BoardColl.get().getFactionAt(attackerPs);
|
Faction attackerPsFaction = BoardColls.get().getFactionAt(attackerPs);
|
||||||
|
|
||||||
// ... PVP flag may cause a damage block ...
|
// ... PVP flag may cause a damage block ...
|
||||||
// (just checking the defender as above isn't enough. What about the attacker? It could be in a no-pvp area)
|
// (just checking the defender as above isn't enough. What about the attacker? It could be in a no-pvp area)
|
||||||
@ -293,7 +292,7 @@ public class FactionsListenerMain implements Listener
|
|||||||
{
|
{
|
||||||
// If a player was kicked from the server ...
|
// If a player was kicked from the server ...
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
FPlayer fplayer = FPlayerColl.get().get(player);
|
FPlayer fplayer = FPlayer.get(player);
|
||||||
|
|
||||||
// ... and if the if player was banned (not just kicked) ...
|
// ... and if the if player was banned (not just kicked) ...
|
||||||
if (!event.getReason().equals("Banned by admin.")) return;
|
if (!event.getReason().equals("Banned by admin.")) return;
|
||||||
@ -332,7 +331,7 @@ public class FactionsListenerMain implements Listener
|
|||||||
{
|
{
|
||||||
// If a player is trying to run a command ...
|
// If a player is trying to run a command ...
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
FPlayer fplayer = FPlayerColl.get().get(player);
|
FPlayer fplayer = FPlayer.get(player);
|
||||||
|
|
||||||
// ... and the player does not have adminmode ...
|
// ... and the player does not have adminmode ...
|
||||||
if (fplayer.isUsingAdminMode()) return;
|
if (fplayer.isUsingAdminMode()) return;
|
||||||
@ -351,7 +350,7 @@ public class FactionsListenerMain implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
Rel rel = fplayer.getRelationToLocation();
|
Rel rel = fplayer.getRelationToLocation();
|
||||||
if (BoardColl.get().getFactionAt(fplayer.getCurrentChunk()).isNone()) return;
|
if (BoardColls.get().getFactionAt(fplayer.getCurrentChunk()).isNone()) return;
|
||||||
|
|
||||||
if (rel == Rel.NEUTRAL && containsCommand(command, ConfServer.territoryNeutralDenyCommands))
|
if (rel == Rel.NEUTRAL && containsCommand(command, ConfServer.territoryNeutralDenyCommands))
|
||||||
{
|
{
|
||||||
@ -398,7 +397,7 @@ public class FactionsListenerMain implements Listener
|
|||||||
|
|
||||||
// ... at a place where monsters are forbidden ...
|
// ... at a place where monsters are forbidden ...
|
||||||
PS ps = PS.valueOf(event.getLocation());
|
PS ps = PS.valueOf(event.getLocation());
|
||||||
Faction faction = BoardColl.get().getFactionAt(ps);
|
Faction faction = BoardColls.get().getFactionAt(ps);
|
||||||
if (faction.getFlag(FFlag.MONSTERS)) return;
|
if (faction.getFlag(FFlag.MONSTERS)) return;
|
||||||
|
|
||||||
// ... block the spawn.
|
// ... block the spawn.
|
||||||
@ -413,7 +412,7 @@ public class FactionsListenerMain implements Listener
|
|||||||
|
|
||||||
// ... at a place where monsters are forbidden ...
|
// ... at a place where monsters are forbidden ...
|
||||||
PS ps = PS.valueOf(event.getTarget());
|
PS ps = PS.valueOf(event.getTarget());
|
||||||
Faction faction = BoardColl.get().getFactionAt(ps);
|
Faction faction = BoardColls.get().getFactionAt(ps);
|
||||||
if (faction.getFlag(FFlag.MONSTERS)) return;
|
if (faction.getFlag(FFlag.MONSTERS)) return;
|
||||||
|
|
||||||
// ... then if ghast target nothing ...
|
// ... then if ghast target nothing ...
|
||||||
@ -438,7 +437,7 @@ public class FactionsListenerMain implements Listener
|
|||||||
if (event.getCause() != RemoveCause.EXPLOSION) return;
|
if (event.getCause() != RemoveCause.EXPLOSION) return;
|
||||||
|
|
||||||
// ... and the faction there has explosions disabled ...
|
// ... and the faction there has explosions disabled ...
|
||||||
Faction faction = BoardColl.get().getFactionAt(PS.valueOf(event.getEntity()));
|
Faction faction = BoardColls.get().getFactionAt(PS.valueOf(event.getEntity()));
|
||||||
if (faction.getFlag(FFlag.EXPLOSIONS)) return;
|
if (faction.getFlag(FFlag.EXPLOSIONS)) return;
|
||||||
|
|
||||||
// ... then cancel.
|
// ... then cancel.
|
||||||
@ -453,12 +452,12 @@ public class FactionsListenerMain implements Listener
|
|||||||
while (iter.hasNext())
|
while (iter.hasNext())
|
||||||
{
|
{
|
||||||
Block block = iter.next();
|
Block block = iter.next();
|
||||||
Faction faction = BoardColl.get().getFactionAt(PS.valueOf(block));
|
Faction faction = BoardColls.get().getFactionAt(PS.valueOf(block));
|
||||||
if (faction.getFlag(FFlag.EXPLOSIONS) == false) iter.remove();
|
if (faction.getFlag(FFlag.EXPLOSIONS) == false) iter.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the entity. Are explosions disabled there?
|
// Check the entity. Are explosions disabled there?
|
||||||
if (BoardColl.get().getFactionAt(PS.valueOf(event.getEntity())).getFlag(FFlag.EXPLOSIONS) == false)
|
if (BoardColls.get().getFactionAt(PS.valueOf(event.getEntity())).getFlag(FFlag.EXPLOSIONS) == false)
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -473,7 +472,7 @@ public class FactionsListenerMain implements Listener
|
|||||||
|
|
||||||
// ... and the faction there has explosions disabled ...
|
// ... and the faction there has explosions disabled ...
|
||||||
PS ps = PS.valueOf(event.getBlock());
|
PS ps = PS.valueOf(event.getBlock());
|
||||||
Faction faction = BoardColl.get().getFactionAt(ps);
|
Faction faction = BoardColls.get().getFactionAt(ps);
|
||||||
if (faction.getFlag(FFlag.EXPLOSIONS)) return;
|
if (faction.getFlag(FFlag.EXPLOSIONS)) return;
|
||||||
|
|
||||||
// ... stop the block alteration.
|
// ... stop the block alteration.
|
||||||
@ -493,7 +492,7 @@ public class FactionsListenerMain implements Listener
|
|||||||
|
|
||||||
// ... and the faction there has endergrief disabled ...
|
// ... and the faction there has endergrief disabled ...
|
||||||
PS ps = PS.valueOf(event.getBlock());
|
PS ps = PS.valueOf(event.getBlock());
|
||||||
Faction faction = BoardColl.get().getFactionAt(ps);
|
Faction faction = BoardColls.get().getFactionAt(ps);
|
||||||
if (faction.getFlag(FFlag.ENDERGRIEF)) return;
|
if (faction.getFlag(FFlag.ENDERGRIEF)) return;
|
||||||
|
|
||||||
// ... stop the block alteration.
|
// ... stop the block alteration.
|
||||||
@ -512,7 +511,7 @@ public class FactionsListenerMain implements Listener
|
|||||||
FPlayer me = FPlayer.get(name);
|
FPlayer me = FPlayer.get(name);
|
||||||
if (me.isUsingAdminMode()) return true;
|
if (me.isUsingAdminMode()) return true;
|
||||||
|
|
||||||
Faction factionHere = BoardColl.get().getFactionAt(ps);
|
Faction factionHere = BoardColls.get().getFactionAt(ps);
|
||||||
|
|
||||||
if ( ! FPerm.BUILD.has(me, ps) && FPerm.PAINBUILD.has(me, ps))
|
if ( ! FPerm.BUILD.has(me, ps) && FPerm.PAINBUILD.has(me, ps))
|
||||||
{
|
{
|
||||||
@ -585,13 +584,13 @@ public class FactionsListenerMain implements Listener
|
|||||||
{
|
{
|
||||||
if ( ! ConfServer.pistonProtectionThroughDenyBuild) return;
|
if ( ! ConfServer.pistonProtectionThroughDenyBuild) return;
|
||||||
|
|
||||||
Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(event.getBlock()));
|
Faction pistonFaction = BoardColls.get().getFactionAt(PS.valueOf(event.getBlock()));
|
||||||
|
|
||||||
// target end-of-the-line empty (air) block which is being pushed into, including if piston itself would extend into air
|
// target end-of-the-line empty (air) block which is being pushed into, including if piston itself would extend into air
|
||||||
Block targetBlock = event.getBlock().getRelative(event.getDirection(), event.getLength() + 1);
|
Block targetBlock = event.getBlock().getRelative(event.getDirection(), event.getLength() + 1);
|
||||||
|
|
||||||
// members of faction might not have build rights in their own territory, but pistons should still work regardless; so, address that corner case
|
// members of faction might not have build rights in their own territory, but pistons should still work regardless; so, address that corner case
|
||||||
Faction targetFaction = BoardColl.get().getFactionAt(PS.valueOf(targetBlock));
|
Faction targetFaction = BoardColls.get().getFactionAt(PS.valueOf(targetBlock));
|
||||||
if (targetFaction == pistonFaction) return;
|
if (targetFaction == pistonFaction) return;
|
||||||
|
|
||||||
// if potentially pushing into air/water/lava in another territory, we need to check it out
|
// if potentially pushing into air/water/lava in another territory, we need to check it out
|
||||||
@ -620,10 +619,10 @@ public class FactionsListenerMain implements Listener
|
|||||||
// if potentially retracted block is just air/water/lava, no worries
|
// if potentially retracted block is just air/water/lava, no worries
|
||||||
if (targetLoc.getBlock().isEmpty() || targetLoc.getBlock().isLiquid()) return;
|
if (targetLoc.getBlock().isEmpty() || targetLoc.getBlock().isLiquid()) return;
|
||||||
|
|
||||||
Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(event.getBlock()));
|
Faction pistonFaction = BoardColls.get().getFactionAt(PS.valueOf(event.getBlock()));
|
||||||
|
|
||||||
// members of faction might not have build rights in their own territory, but pistons should still work regardless; so, address that corner case
|
// members of faction might not have build rights in their own territory, but pistons should still work regardless; so, address that corner case
|
||||||
Faction targetFaction = BoardColl.get().getFactionAt(PS.valueOf(targetLoc));
|
Faction targetFaction = BoardColls.get().getFactionAt(PS.valueOf(targetLoc));
|
||||||
if (targetFaction == pistonFaction) return;
|
if (targetFaction == pistonFaction) return;
|
||||||
|
|
||||||
if ( ! FPerm.BUILD.has(pistonFaction, targetLoc))
|
if ( ! FPerm.BUILD.has(pistonFaction, targetLoc))
|
||||||
@ -640,7 +639,7 @@ public class FactionsListenerMain implements Listener
|
|||||||
{
|
{
|
||||||
// If the faction at the block has firespread disabled ...
|
// If the faction at the block has firespread disabled ...
|
||||||
PS ps = PS.valueOf(block);
|
PS ps = PS.valueOf(block);
|
||||||
Faction faction = BoardColl.get().getFactionAt(ps);
|
Faction faction = BoardColls.get().getFactionAt(ps);
|
||||||
if (faction.getFlag(FFlag.FIRESPREAD)) return;
|
if (faction.getFlag(FFlag.FIRESPREAD)) return;
|
||||||
|
|
||||||
// then cancel the event.
|
// then cancel the event.
|
||||||
|
@ -17,9 +17,8 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
|||||||
import com.massivecraft.factions.Const;
|
import com.massivecraft.factions.Const;
|
||||||
import com.massivecraft.factions.FPerm;
|
import com.massivecraft.factions.FPerm;
|
||||||
import com.massivecraft.factions.TerritoryAccess;
|
import com.massivecraft.factions.TerritoryAccess;
|
||||||
import com.massivecraft.factions.entity.BoardColl;
|
import com.massivecraft.factions.entity.BoardColls;
|
||||||
import com.massivecraft.factions.entity.FPlayer;
|
import com.massivecraft.factions.entity.FPlayer;
|
||||||
import com.massivecraft.factions.entity.FPlayerColl;
|
|
||||||
import com.massivecraft.factions.entity.MConf;
|
import com.massivecraft.factions.entity.MConf;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
import com.massivecraft.mcore.event.MCorePlayerLeaveEvent;
|
import com.massivecraft.mcore.event.MCorePlayerLeaveEvent;
|
||||||
@ -34,7 +33,7 @@ public class TodoFactionsPlayerListener implements Listener
|
|||||||
{
|
{
|
||||||
// If a player is joining the server ...
|
// If a player is joining the server ...
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
FPlayer fplayer = FPlayerColl.get().get(player);
|
FPlayer fplayer = FPlayer.get(player);
|
||||||
|
|
||||||
// ... recalculate their power as if they were offline since last recalculation ...
|
// ... recalculate their power as if they were offline since last recalculation ...
|
||||||
fplayer.recalculatePower(false);
|
fplayer.recalculatePower(false);
|
||||||
@ -53,7 +52,7 @@ public class TodoFactionsPlayerListener implements Listener
|
|||||||
public void onPlayerLeave(MCorePlayerLeaveEvent event)
|
public void onPlayerLeave(MCorePlayerLeaveEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
FPlayer fplayer = FPlayerColl.get().get(player);
|
FPlayer fplayer = FPlayer.get(player);
|
||||||
|
|
||||||
// Recalculate the power before the player leaves.
|
// Recalculate the power before the player leaves.
|
||||||
// This is required since we recalculate as if the player were offline when they log back in.
|
// This is required since we recalculate as if the player were offline when they log back in.
|
||||||
@ -71,7 +70,7 @@ public class TodoFactionsPlayerListener implements Listener
|
|||||||
|
|
||||||
// ... update the stored current chunk ...
|
// ... update the stored current chunk ...
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
FPlayer fplayer = FPlayerColl.get().get(player);
|
FPlayer fplayer = FPlayer.get(player);
|
||||||
|
|
||||||
PS chunkFrom = fplayer.getCurrentChunk();
|
PS chunkFrom = fplayer.getCurrentChunk();
|
||||||
PS chunkTo = PS.valueOf(event.getTo()).getChunk(true);
|
PS chunkTo = PS.valueOf(event.getTo()).getChunk(true);
|
||||||
@ -80,17 +79,17 @@ public class TodoFactionsPlayerListener implements Listener
|
|||||||
|
|
||||||
// ... TODO: assorted and uncleaned code below ...
|
// ... TODO: assorted and uncleaned code below ...
|
||||||
|
|
||||||
TerritoryAccess access = BoardColl.get().getTerritoryAccessAt(chunkTo);
|
TerritoryAccess access = BoardColls.get().getTerritoryAccessAt(chunkTo);
|
||||||
|
|
||||||
// Did we change "host"(faction)?
|
// Did we change "host"(faction)?
|
||||||
boolean changedFaction = (BoardColl.get().getFactionAt(chunkFrom) != access.getHostFaction());
|
boolean changedFaction = (BoardColls.get().getFactionAt(chunkFrom) != access.getHostFaction());
|
||||||
|
|
||||||
// let Spout handle most of this if it's available
|
// let Spout handle most of this if it's available
|
||||||
boolean handledBySpout = changedFaction && SpoutFeatures.updateTerritoryDisplay(fplayer);
|
boolean handledBySpout = changedFaction && SpoutFeatures.updateTerritoryDisplay(fplayer);
|
||||||
|
|
||||||
if (fplayer.isMapAutoUpdating())
|
if (fplayer.isMapAutoUpdating())
|
||||||
{
|
{
|
||||||
fplayer.sendMessage(BoardColl.get().getMap(fplayer.getFaction(), chunkTo, player.getLocation().getYaw()));
|
fplayer.sendMessage(BoardColls.get().getMap(fplayer.getFaction(), chunkTo, player.getLocation().getYaw()));
|
||||||
}
|
}
|
||||||
else if (changedFaction && ! handledBySpout)
|
else if (changedFaction && ! handledBySpout)
|
||||||
{
|
{
|
||||||
@ -146,7 +145,7 @@ public class TodoFactionsPlayerListener implements Listener
|
|||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true;
|
if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true;
|
||||||
|
|
||||||
FPlayer me = FPlayerColl.get().get(name);
|
FPlayer me = FPlayer.get(name);
|
||||||
if (me.isUsingAdminMode()) return true;
|
if (me.isUsingAdminMode()) return true;
|
||||||
if (Const.MATERIALS_EDIT_TOOLS.contains(material) && ! FPerm.BUILD.has(me, loc, ! justCheck)) return false;
|
if (Const.MATERIALS_EDIT_TOOLS.contains(material) && ! FPerm.BUILD.has(me, loc, ! justCheck)) return false;
|
||||||
return true;
|
return true;
|
||||||
@ -156,7 +155,7 @@ public class TodoFactionsPlayerListener implements Listener
|
|||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true;
|
if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true;
|
||||||
|
|
||||||
FPlayer me = FPlayerColl.get().get(name);
|
FPlayer me = FPlayer.get(name);
|
||||||
if (me.isUsingAdminMode()) return true;
|
if (me.isUsingAdminMode()) return true;
|
||||||
Location loc = block.getLocation();
|
Location loc = block.getLocation();
|
||||||
Material material = block.getType();
|
Material material = block.getType();
|
||||||
|
@ -2,6 +2,7 @@ package com.massivecraft.factions.task;
|
|||||||
|
|
||||||
import com.massivecraft.factions.ConfServer;
|
import com.massivecraft.factions.ConfServer;
|
||||||
import com.massivecraft.factions.entity.FPlayerColl;
|
import com.massivecraft.factions.entity.FPlayerColl;
|
||||||
|
import com.massivecraft.factions.entity.FPlayerColls;
|
||||||
import com.massivecraft.mcore.ModuloRepeatTask;
|
import com.massivecraft.mcore.ModuloRepeatTask;
|
||||||
import com.massivecraft.mcore.util.TimeUnit;
|
import com.massivecraft.mcore.util.TimeUnit;
|
||||||
|
|
||||||
@ -33,7 +34,10 @@ public class AutoLeaveTask extends ModuloRepeatTask
|
|||||||
@Override
|
@Override
|
||||||
public void invoke()
|
public void invoke()
|
||||||
{
|
{
|
||||||
FPlayerColl.get().autoLeaveOnInactivityRoutine();
|
for (FPlayerColl coll : FPlayerColls.get().getColls())
|
||||||
|
{
|
||||||
|
coll.autoLeaveOnInactivityRoutine();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.massivecraft.factions.task;
|
|||||||
|
|
||||||
import com.massivecraft.factions.ConfServer;
|
import com.massivecraft.factions.ConfServer;
|
||||||
import com.massivecraft.factions.entity.FactionColl;
|
import com.massivecraft.factions.entity.FactionColl;
|
||||||
|
import com.massivecraft.factions.entity.FactionColls;
|
||||||
import com.massivecraft.mcore.ModuloRepeatTask;
|
import com.massivecraft.mcore.ModuloRepeatTask;
|
||||||
import com.massivecraft.mcore.util.TimeUnit;
|
import com.massivecraft.mcore.util.TimeUnit;
|
||||||
|
|
||||||
@ -33,7 +34,10 @@ public class EconLandRewardTask extends ModuloRepeatTask
|
|||||||
@Override
|
@Override
|
||||||
public void invoke()
|
public void invoke()
|
||||||
{
|
{
|
||||||
FactionColl.get().econLandRewardRoutine();
|
for (FactionColl coll : FactionColls.get().getColls())
|
||||||
|
{
|
||||||
|
coll.econLandRewardRoutine();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user