Added tip to /f set. Empowered board interface with extra methods.
This commit is contained in:
parent
b1c0512b46
commit
2ac847fe14
@ -40,7 +40,7 @@ public class CmdFactionsDisband extends FactionsCommand
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform()
|
||||||
{
|
{
|
||||||
// Args
|
// Args
|
||||||
Faction faction = this.arg(0, ARFaction.get(), msenderFaction);
|
Faction faction = this.arg(0, ARFaction.get(), msenderFaction);
|
||||||
if (faction == null) return;
|
if (faction == null) return;
|
||||||
|
@ -33,9 +33,13 @@ public class CmdFactionsSet extends FactionsCommand
|
|||||||
this.addSubCommand(this.cmdFactionsSetSquare);
|
this.addSubCommand(this.cmdFactionsSetSquare);
|
||||||
this.addSubCommand(this.cmdFactionsSetCircle);
|
this.addSubCommand(this.cmdFactionsSetCircle);
|
||||||
this.addSubCommand(this.cmdFactionsSetTransfer);
|
this.addSubCommand(this.cmdFactionsSetTransfer);
|
||||||
|
|
||||||
|
this.setHelp("Tip: Set faction <h>none <i>to unclaim.");
|
||||||
|
|
||||||
// Requirements
|
// Requirements
|
||||||
this.addRequirements(ReqHasPerm.get(Perm.SET.node));
|
this.addRequirements(ReqHasPerm.get(Perm.SET.node));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,8 @@ 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.factions.util.AsciiCompass;
|
import com.massivecraft.factions.util.AsciiCompass;
|
||||||
|
import com.massivecraft.massivecore.collections.MassiveMap;
|
||||||
|
import com.massivecraft.massivecore.collections.MassiveSet;
|
||||||
import com.massivecraft.massivecore.ps.PS;
|
import com.massivecraft.massivecore.ps.PS;
|
||||||
import com.massivecraft.massivecore.store.Entity;
|
import com.massivecraft.massivecore.store.Entity;
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
import com.massivecraft.massivecore.util.Txt;
|
||||||
@ -181,6 +183,7 @@ public class Board extends Entity<Board> implements BoardInterface
|
|||||||
return this.getChunks(faction.getId());
|
return this.getChunks(faction.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Set<PS> getChunks(String factionId)
|
public Set<PS> getChunks(String factionId)
|
||||||
{
|
{
|
||||||
Set<PS> ret = new HashSet<PS>();
|
Set<PS> ret = new HashSet<PS>();
|
||||||
@ -196,6 +199,35 @@ public class Board extends Entity<Board> implements BoardInterface
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<Faction, Set<PS>> getFactionToChunks()
|
||||||
|
{
|
||||||
|
Map<Faction, Set<PS>> ret = new MassiveMap<>();
|
||||||
|
|
||||||
|
for (Entry<PS, TerritoryAccess> entry : this.map.entrySet())
|
||||||
|
{
|
||||||
|
// Get Faction
|
||||||
|
TerritoryAccess ta = entry.getValue();
|
||||||
|
Faction faction = ta.getHostFaction();
|
||||||
|
if (faction == null) continue;
|
||||||
|
|
||||||
|
// Get Chunks
|
||||||
|
Set<PS> chunks = ret.get(faction);
|
||||||
|
if (chunks == null)
|
||||||
|
{
|
||||||
|
chunks = new MassiveSet<>();
|
||||||
|
ret.put(faction, chunks);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add Chunk
|
||||||
|
PS chunk = entry.getKey();
|
||||||
|
chunk = chunk.withWorld(this.getId());
|
||||||
|
chunks.add(chunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// COUNT
|
// COUNT
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -216,6 +248,32 @@ public class Board extends Entity<Board> implements BoardInterface
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<Faction, Integer> getFactionToCount()
|
||||||
|
{
|
||||||
|
Map<Faction, Integer> ret = new MassiveMap<>();
|
||||||
|
|
||||||
|
for (Entry<PS, TerritoryAccess> entry : this.map.entrySet())
|
||||||
|
{
|
||||||
|
// Get Faction
|
||||||
|
TerritoryAccess ta = entry.getValue();
|
||||||
|
Faction faction = ta.getHostFaction();
|
||||||
|
if (faction == null) continue;
|
||||||
|
|
||||||
|
// Get Count
|
||||||
|
Integer count = ret.get(faction);
|
||||||
|
if (count == null)
|
||||||
|
{
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add Chunk
|
||||||
|
ret.put(faction, count + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// NEARBY DETECTION
|
// NEARBY DETECTION
|
||||||
|
|
||||||
// Is this coord NOT completely surrounded by coords claimed by the same faction?
|
// Is this coord NOT completely surrounded by coords claimed by the same faction?
|
||||||
|
@ -6,12 +6,14 @@ import java.util.HashSet;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.massivecraft.factions.Const;
|
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.massivecore.collections.MassiveMap;
|
||||||
import com.massivecraft.massivecore.ps.PS;
|
import com.massivecraft.massivecore.ps.PS;
|
||||||
import com.massivecraft.massivecore.store.Coll;
|
import com.massivecraft.massivecore.store.Coll;
|
||||||
import com.massivecraft.massivecore.store.MStore;
|
import com.massivecraft.massivecore.store.MStore;
|
||||||
@ -128,6 +130,51 @@ public class BoardColl extends Coll<Board> implements BoardInterface
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<PS> getChunks(String factionId)
|
||||||
|
{
|
||||||
|
Set<PS> ret = new HashSet<PS>();
|
||||||
|
for (Board board : this.getAll())
|
||||||
|
{
|
||||||
|
ret.addAll(board.getChunks(factionId));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<Faction, Set<PS>> getFactionToChunks()
|
||||||
|
{
|
||||||
|
Map<Faction, Set<PS>> ret = null;
|
||||||
|
for (Board board : this.getAll())
|
||||||
|
{
|
||||||
|
// Use the first board directly
|
||||||
|
Map<Faction, Set<PS>> factionToChunks = board.getFactionToChunks();
|
||||||
|
if (ret == null)
|
||||||
|
{
|
||||||
|
ret = factionToChunks;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Merge the following boards
|
||||||
|
for (Entry<Faction, Set<PS>> entry : factionToChunks.entrySet())
|
||||||
|
{
|
||||||
|
Faction faction = entry.getKey();
|
||||||
|
Set<PS> chunks = ret.get(faction);
|
||||||
|
if (chunks == null)
|
||||||
|
{
|
||||||
|
ret.put(faction, entry.getValue());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
chunks.addAll(entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret == null) ret = new MassiveMap<>();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// COUNT
|
// COUNT
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -147,6 +194,40 @@ public class BoardColl extends Coll<Board> implements BoardInterface
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<Faction, Integer> getFactionToCount()
|
||||||
|
{
|
||||||
|
Map<Faction, Integer> ret = null;
|
||||||
|
for (Board board : this.getAll())
|
||||||
|
{
|
||||||
|
// Use the first board directly
|
||||||
|
Map<Faction, Integer> factionToCount = board.getFactionToCount();
|
||||||
|
if (ret == null)
|
||||||
|
{
|
||||||
|
ret = factionToCount;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Merge the following boards
|
||||||
|
for (Entry<Faction, Integer> entry : factionToCount.entrySet())
|
||||||
|
{
|
||||||
|
Faction faction = entry.getKey();
|
||||||
|
Integer count = ret.get(faction);
|
||||||
|
if (count == null)
|
||||||
|
{
|
||||||
|
ret.put(faction, entry.getValue());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret.put(faction, count + entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret == null) ret = new MassiveMap<>();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// NEARBY DETECTION
|
// NEARBY DETECTION
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.massivecraft.factions.entity;
|
package com.massivecraft.factions.entity;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.massivecraft.factions.RelationParticipator;
|
import com.massivecraft.factions.RelationParticipator;
|
||||||
@ -24,10 +25,13 @@ public interface BoardInterface
|
|||||||
|
|
||||||
// CHUNKS
|
// CHUNKS
|
||||||
public Set<PS> getChunks(Faction faction);
|
public Set<PS> getChunks(Faction faction);
|
||||||
|
public Set<PS> getChunks(String factionId);
|
||||||
|
public Map<Faction, Set<PS>> getFactionToChunks();
|
||||||
|
|
||||||
// COUNT
|
// COUNT
|
||||||
public int getCount(Faction faction);
|
public int getCount(Faction faction);
|
||||||
public int getCount(String factionId);
|
public int getCount(String factionId);
|
||||||
|
public Map<Faction, Integer> getFactionToCount();
|
||||||
|
|
||||||
// NEARBY DETECTION
|
// NEARBY DETECTION
|
||||||
public boolean isBorderPs(PS ps);
|
public boolean isBorderPs(PS ps);
|
||||||
|
@ -804,6 +804,7 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
|
|||||||
{
|
{
|
||||||
return this.tryClaim(newFaction, pss, null, null);
|
return this.tryClaim(newFaction, pss, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean tryClaim(Faction newFaction, Collection<PS> pss, String formatOne, String formatMany)
|
public boolean tryClaim(Faction newFaction, Collection<PS> pss, String formatOne, String formatMany)
|
||||||
{
|
{
|
||||||
// Args
|
// Args
|
||||||
@ -875,14 +876,13 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
|
|||||||
{
|
{
|
||||||
Set<MPlayer> ret = new HashSet<MPlayer>();
|
Set<MPlayer> ret = new HashSet<MPlayer>();
|
||||||
|
|
||||||
ret.add(msender);
|
if (msender != null) ret.add(msender);
|
||||||
|
|
||||||
for (Faction faction : factions)
|
for (Faction faction : factions)
|
||||||
{
|
{
|
||||||
if (faction.isNormal())
|
if (faction == null) continue;
|
||||||
{
|
if (faction.isNone()) continue;
|
||||||
ret.addAll(faction.getMPlayers());
|
ret.addAll(faction.getMPlayers());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MConf.get().logLandClaims)
|
if (MConf.get().logLandClaims)
|
||||||
|
Loading…
Reference in New Issue
Block a user