mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-11-24 03:05:52 +01:00
New SeeChunk command and cleanup of the show command.
This commit is contained in:
parent
c43d34af79
commit
e935a56ff9
@ -252,6 +252,21 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Rel, List<String>> getFactionTagsPerRelation()
|
||||
{
|
||||
Map<Rel, List<String>> ret = new HashMap<Rel, List<String>>();
|
||||
for (Rel rel : Rel.values())
|
||||
{
|
||||
ret.put(rel, new ArrayList<String>());
|
||||
}
|
||||
for (Faction faction : Factions.i.get())
|
||||
{
|
||||
Rel relation = faction.getRelationTo(this);
|
||||
ret.get(relation).add(faction.getTag(this));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// TODO: Implement a has enough feature.
|
||||
//----------------------------------------------//
|
||||
// Power
|
||||
|
101
src/com/massivecraft/factions/cmd/CmdSeeChunk.java
Normal file
101
src/com/massivecraft/factions/cmd/CmdSeeChunk.java
Normal file
@ -0,0 +1,101 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
// !!!! This is just an experiment.
|
||||
// Proof of concept. We could use fake block updates to visualize the territories.
|
||||
public class CmdSeeChunk extends FCommand
|
||||
{
|
||||
public CmdSeeChunk()
|
||||
{
|
||||
super();
|
||||
this.aliases.add("sc");
|
||||
this.aliases.add("seechunks");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.ADMIN.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeOfficer = false;
|
||||
senderMustBeLeader = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
Location meLoc = me.getLocation();
|
||||
// Which chunk are we standing in ATM?
|
||||
// This bit shifting is something like divide by 16 :P
|
||||
int chunkX = meLoc.getBlockX() >> 4;
|
||||
int chunkZ = meLoc.getBlockZ() >> 4;
|
||||
|
||||
// Get the pillars for that chunk
|
||||
int blockX;
|
||||
int blockZ;
|
||||
|
||||
blockX = chunkX*16;
|
||||
blockZ = chunkZ*16;
|
||||
showPillar(me, me.getWorld(), blockX, blockZ);
|
||||
|
||||
blockX = chunkX*16 + 15;
|
||||
blockZ = chunkZ*16;
|
||||
showPillar(me, me.getWorld(), blockX, blockZ);
|
||||
|
||||
blockX = chunkX*16;
|
||||
blockZ = chunkZ*16 + 15;
|
||||
showPillar(me, me.getWorld(), blockX, blockZ);
|
||||
|
||||
blockX = chunkX*16 + 15;
|
||||
blockZ = chunkZ*16 + 15;
|
||||
showPillar(me, me.getWorld(), blockX, blockZ);
|
||||
}
|
||||
|
||||
public void showPillar(Player player, World world, int blockX, int blockZ)
|
||||
{
|
||||
Location loc = new Location(world, blockX, 0, blockZ);
|
||||
//Block block = loc.getBlock();
|
||||
for (int blockY = 0; blockY <=127; blockY++)
|
||||
{
|
||||
loc.setY(blockY);
|
||||
if (loc.getBlock().getTypeId() != 0) continue;
|
||||
player.sendBlockChange(loc, blockY % 5 == 0 ? Material.GLOWSTONE : Material.GLASS, (byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
// DEV DIRT BELOW...
|
||||
|
||||
public ArrayList<Location> getChunkPillarLocations(int chunkX, int chunkZ)
|
||||
{
|
||||
ArrayList<Location> ret = new ArrayList<Location>();
|
||||
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public ArrayList<Location> getPillar(Block block)
|
||||
{
|
||||
ArrayList<Location> ret = new ArrayList<Location>();
|
||||
|
||||
// y 0-127
|
||||
|
||||
for (int i = 0; i <=127; i++)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
@ -1,19 +1,21 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.struct.FFlag;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||
|
||||
public class CmdShow extends FCommand
|
||||
{
|
||||
|
||||
public CmdShow()
|
||||
{
|
||||
this.aliases.add("show");
|
||||
@ -50,24 +52,21 @@ public class CmdShow extends FCommand
|
||||
|
||||
msg(p.txt.titleize(faction.getTag(fme)));
|
||||
msg("<a>Description: <i>%s", faction.getDescription());
|
||||
/*if ( ! faction.isNormal())
|
||||
{
|
||||
return;
|
||||
}*/
|
||||
|
||||
String peaceStatus = "";
|
||||
if (faction.getFlag(FFlag.PEACEFUL))
|
||||
{
|
||||
peaceStatus = " "+Conf.colorTruce+"This faction is Peaceful";
|
||||
}
|
||||
|
||||
msg("<a>Joining: <i>"+(faction.getOpen() ? "no invitation is needed" : "invitation is required")+peaceStatus);
|
||||
msg("<a>Land / Power / Maxpower: <i> %d/%d/%d", faction.getLandRounded(), faction.getPowerRounded(), faction.getPowerMaxRounded());
|
||||
|
||||
// Display important flags
|
||||
// TODO: Find the non default flags, and display them instead.
|
||||
if (faction.getFlag(FFlag.PERMANENT))
|
||||
{
|
||||
msg("<a>This faction is permanent, remaining even with no members.");
|
||||
}
|
||||
|
||||
if (faction.getFlag(FFlag.PEACEFUL))
|
||||
{
|
||||
sendMessage(Conf.colorTruce+"This faction is peaceful - in truce with everyone.");
|
||||
}
|
||||
|
||||
msg("<a>Joining: <i>"+(faction.getOpen() ? "no invitation is needed" : "invitation is required"));
|
||||
msg("<a>Land / Power / Maxpower: <i> %d/%d/%d", faction.getLandRounded(), faction.getPowerRounded(), faction.getPowerMaxRounded());
|
||||
|
||||
// show the land value
|
||||
if (Econ.shouldBeUsed())
|
||||
@ -82,88 +81,62 @@ public class CmdShow extends FCommand
|
||||
}
|
||||
|
||||
//Show bank contents
|
||||
if(Conf.bankEnabled) {
|
||||
if(Conf.bankEnabled)
|
||||
{
|
||||
msg("<a>Bank contains: <i>"+Econ.moneyString(faction.getAccount().balance()));
|
||||
}
|
||||
}
|
||||
|
||||
String listpart;
|
||||
String sepparator = p.txt.parse("<i>")+", ";
|
||||
|
||||
// List relation
|
||||
String allyList = p.txt.parse("<a>Allies: ");
|
||||
String enemyList = p.txt.parse("<a>Enemies: ");
|
||||
for (Faction otherFaction : Factions.i.get())
|
||||
{
|
||||
if (otherFaction == faction)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
listpart = otherFaction.getTag(fme)+p.txt.parse("<i>")+", ";
|
||||
if (otherFaction.getRelationTo(faction) == Rel.ALLY)
|
||||
{
|
||||
allyList += listpart;
|
||||
}
|
||||
else if (otherFaction.getRelationTo(faction) == Rel.ENEMY)
|
||||
{
|
||||
enemyList += listpart;
|
||||
}
|
||||
}
|
||||
if (allyList.endsWith(", "))
|
||||
{
|
||||
allyList = allyList.substring(0, allyList.length()-2);
|
||||
}
|
||||
if (enemyList.endsWith(", "))
|
||||
{
|
||||
enemyList = enemyList.substring(0, enemyList.length()-2);
|
||||
}
|
||||
|
||||
sendMessage(allyList);
|
||||
sendMessage(enemyList);
|
||||
// List the relations to other factions
|
||||
Map<Rel, List<String>> relationTags = faction.getFactionTagsPerRelation();
|
||||
sendMessage(p.txt.parse("<a>In Truce with: ") + TextUtil.implode(relationTags.get(Rel.TRUCE), sepparator));
|
||||
sendMessage(p.txt.parse("<a>Allied to: ") + TextUtil.implode(relationTags.get(Rel.ALLY), sepparator));
|
||||
sendMessage(p.txt.parse("<a>Enemies: ") + TextUtil.implode(relationTags.get(Rel.ENEMY), sepparator));
|
||||
|
||||
// List the members...
|
||||
String onlineList = p.txt.parse("<a>")+"Members online: ";
|
||||
String offlineList = p.txt.parse("<a>")+"Members offline: ";
|
||||
List<String> memberOnlineNames = new ArrayList<String>();
|
||||
List<String> memberOfflineNames = new ArrayList<String>();
|
||||
|
||||
for (FPlayer follower : admins)
|
||||
{
|
||||
listpart = follower.getNameAndTitle(fme)+p.txt.parse("<i>")+", ";
|
||||
if (follower.isOnline())
|
||||
{
|
||||
onlineList += listpart;
|
||||
memberOnlineNames.add(follower.getNameAndTitle(fme));
|
||||
}
|
||||
else
|
||||
{
|
||||
offlineList += listpart;
|
||||
memberOfflineNames.add(follower.getNameAndTitle(fme));
|
||||
}
|
||||
}
|
||||
|
||||
for (FPlayer follower : mods)
|
||||
{
|
||||
listpart = follower.getNameAndTitle(fme)+p.txt.parse("<i>")+", ";
|
||||
if
|
||||
(follower.isOnline())
|
||||
if (follower.isOnline())
|
||||
{
|
||||
onlineList += listpart;
|
||||
} else {
|
||||
offlineList += listpart;
|
||||
memberOnlineNames.add(follower.getNameAndTitle(fme));
|
||||
}
|
||||
}
|
||||
for (FPlayer follower : normals) {
|
||||
listpart = follower.getNameAndTitle(fme)+p.txt.parse("<i>")+", ";
|
||||
if (follower.isOnline()) {
|
||||
onlineList += listpart;
|
||||
} else {
|
||||
offlineList += listpart;
|
||||
else
|
||||
{
|
||||
memberOfflineNames.add(follower.getNameAndTitle(fme));
|
||||
}
|
||||
}
|
||||
|
||||
if (onlineList.endsWith(", ")) {
|
||||
onlineList = onlineList.substring(0, onlineList.length()-2);
|
||||
}
|
||||
if (offlineList.endsWith(", ")) {
|
||||
offlineList = offlineList.substring(0, offlineList.length()-2);
|
||||
for (FPlayer follower : normals)
|
||||
{
|
||||
if (follower.isOnline())
|
||||
{
|
||||
memberOnlineNames.add(follower.getNameAndTitle(fme));
|
||||
}
|
||||
else
|
||||
{
|
||||
memberOfflineNames.add(follower.getNameAndTitle(fme));
|
||||
}
|
||||
}
|
||||
|
||||
sendMessage(onlineList);
|
||||
sendMessage(offlineList);
|
||||
sendMessage(p.txt.parse("<a>Members online: ") + TextUtil.implode(memberOnlineNames, sepparator));
|
||||
sendMessage(p.txt.parse("<a>Members offline: ") + TextUtil.implode(memberOfflineNames, sepparator));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ public class FCmdRoot extends FCommand
|
||||
public CmdRelationTruce cmdRelationTruce = new CmdRelationTruce();
|
||||
public CmdReload cmdReload = new CmdReload();
|
||||
public CmdSaveAll cmdSaveAll = new CmdSaveAll();
|
||||
public CmdSeeChunk cmdSeeChunks = new CmdSeeChunk();
|
||||
public CmdSethome cmdSethome = new CmdSethome();
|
||||
public CmdShow cmdShow = new CmdShow();
|
||||
public CmdTag cmdTag = new CmdTag();
|
||||
@ -98,6 +99,7 @@ public class FCmdRoot extends FCommand
|
||||
this.addSubCommand(this.cmdRelationTruce);
|
||||
this.addSubCommand(this.cmdReload);
|
||||
this.addSubCommand(this.cmdSaveAll);
|
||||
this.addSubCommand(this.cmdSeeChunks);
|
||||
this.addSubCommand(this.cmdSethome);
|
||||
this.addSubCommand(this.cmdShow);
|
||||
this.addSubCommand(this.cmdTag);
|
||||
|
Loading…
Reference in New Issue
Block a user