Add clean command

This commit is contained in:
Olof Larsson
2017-03-24 20:19:04 +01:00
parent 42fe618b6b
commit 59112577b8
8 changed files with 66 additions and 5 deletions

View File

@@ -159,8 +159,12 @@ public class Board extends Entity<Board> implements BoardInterface
// Removes orphaned foreign keys
@Override
public void clean()
public int clean()
{
int ret = 0;
if (!FactionColl.get().isActive()) return ret;
for (Entry<PS, TerritoryAccess> entry : this.map.entrySet())
{
TerritoryAccess territoryAccess = entry.getValue();
@@ -171,8 +175,12 @@ public class Board extends Entity<Board> implements BoardInterface
PS ps = entry.getKey();
this.removeAt(ps);
ret += 0;
Factions.get().log("Board cleaner removed "+factionId+" from "+ps);
}
return ret;
}
// CHUNKS

View File

@@ -118,12 +118,16 @@ public class BoardColl extends Coll<Board> implements BoardInterface
}
@Override
public void clean()
public int clean()
{
int ret = 0;
for (Board board : this.getAll())
{
board.clean();
ret += board.clean();
}
return ret;
}
// CHUNKS

View File

@@ -21,7 +21,7 @@ public interface BoardInterface
// REMOVE
void removeAt(PS ps);
void removeAll(Faction faction);
void clean();
int clean();
// CHUNKS
Set<PS> getChunks(Faction faction);

View File

@@ -82,8 +82,12 @@ public class MPlayerColl extends SenderColl<MPlayer>
// EXTRAS
// -------------------------------------------- //
public void clean()
public int clean()
{
int ret = 0;
if (!FactionColl.get().isActive()) return ret;
// For each player ...
for (MPlayer mplayer : this.getAll())
{
@@ -93,11 +97,14 @@ public class MPlayerColl extends SenderColl<MPlayer>
// ... reset their faction data ...
mplayer.resetFactionData();
ret += 1;
// ... and log.
String message = Txt.parse("<i>Reset data for <h>%s <i>. Unknown factionId <h>%s", mplayer.getDisplayName(IdUtil.getConsole()), factionId);
Factions.get().log(message);
}
return ret;
}
public void considerRemovePlayerMillis()