Changes to the ascii map and minor tweaking

This commit is contained in:
Olof Larsson 2011-10-24 09:28:08 +02:00
parent 1ec7842ed4
commit bb5a676430
9 changed files with 101 additions and 103 deletions

View File

@ -12,7 +12,7 @@ import java.util.TreeMap;
import org.bukkit.ChatColor;
import com.google.gson.reflect.TypeToken;
import com.massivecraft.factions.struct.Rel;
import com.massivecraft.factions.iface.RelationParticipator;
import com.massivecraft.factions.util.AsciiCompass;
import com.massivecraft.factions.zcore.util.DiscUtil;
@ -159,11 +159,11 @@ public class Board
* north is in the direction of decreasing x
* east is in the direction of decreasing z
*/
public static ArrayList<String> getMap(Faction faction, FLocation flocation, double inDegrees)
public static ArrayList<String> getMap(RelationParticipator observer, FLocation flocation, double inDegrees)
{
ArrayList<String> ret = new ArrayList<String>();
Faction factionLoc = getFactionAt(flocation);
ret.add(P.p.txt.titleize("("+flocation.getCoordString()+") "+factionLoc.getTag(faction)));
ret.add(P.p.txt.titleize("("+flocation.getCoordString()+") "+factionLoc.getTag(observer)));
int halfWidth = Conf.mapWidth / 2;
int halfHeight = Conf.mapHeight / 2;
@ -171,12 +171,12 @@ public class Board
int width = halfWidth * 2 + 1;
int height = halfHeight * 2 + 1;
if (Conf.showMapFactionKey)
/*if (Conf.showMapFactionKey)
{
height--;
}
}*/
Map<String, Character> fList = new HashMap<String, Character>();
Map<Faction, Character> fList = new HashMap<Faction, Character>();
int chrIdx = 0;
// For each row
@ -189,25 +189,17 @@ public class Board
if(dz == -(halfWidth) && dx == halfHeight)
{
row += ChatColor.AQUA+"+";
continue;
}
else
{
FLocation flocationHere = topLeft.getRelative(dx, dz);
Faction factionHere = getFactionAt(flocationHere);
Rel relation = faction.getRelationTo(factionHere);
//Rel relation = faction.getRelationTo(factionHere);
if (factionHere.isNone())
{
row += ChatColor.GRAY+"-";
}
/*else if (factionHere.isSafeZone())
{
row += Conf.colorPeaceful+"+";
}
else if (factionHere.isWarZone())
{
row += ChatColor.DARK_RED+"+";
}*/
else if
else /*if
(
factionHere == faction
||
@ -218,18 +210,17 @@ public class Board
(Conf.showNeutralFactionsOnMap && relation.equals(Rel.NEUTRAL))
||
(Conf.showEnemyFactionsOnMap && relation.equals(Rel.ENEMY))
)
)*/
{
if (!fList.containsKey(factionHere.getTag()))
fList.put(factionHere.getTag(), Conf.mapKeyChrs[chrIdx++]);
char tag = fList.get(factionHere.getTag());
row += factionHere.getColorTo(faction) + "" + tag;
fList.put(factionHere, Conf.mapKeyChrs[chrIdx++]);
char tag = fList.get(factionHere);
row += factionHere.getColorTo(observer) + "" + tag;
}
else
/*else
{
row += ChatColor.GRAY+"-";
}
}
}*/
}
ret.add(row);
}
@ -243,15 +234,17 @@ public class Board
ret.set(3, asciiCompass.get(2)+ret.get(3).substring(3*3));
// Add the faction key
if (Conf.showMapFactionKey)
{
// TODO: relation color for them
//if (Conf.showMapFactionKey)
//{
String fRow = "";
for(String key : fList.keySet())
for(Faction keyfaction : fList.keySet())
{
fRow += String.format("%s%s: %s ", ChatColor.GRAY, fList.get(key), key);
fRow += String.format("%s%s: %s ", keyfaction.getColorTo(observer), fList.get(keyfaction), keyfaction.getTag());
}
ret.add(fRow);
}
//}
return ret;
}

View File

@ -17,12 +17,12 @@ public class Conf
// Colors
public static ChatColor colorMember = ChatColor.GREEN;
public static ChatColor colorAlly = ChatColor.LIGHT_PURPLE;
public static ChatColor colorTruce = ChatColor.GOLD;
public static ChatColor colorTruce = ChatColor.DARK_PURPLE;
public static ChatColor colorNeutral = ChatColor.WHITE;
public static ChatColor colorEnemy = ChatColor.RED;
//public static ChatColor colorPeaceful = ChatColor.GOLD;
//public static ChatColor colorWar = ChatColor.DARK_RED;
public static ChatColor colorNoPVP = ChatColor.GOLD;
public static ChatColor colorFriendlyFire = ChatColor.DARK_RED;
//public static ChatColor colorWilderness = ChatColor.DARK_GREEN;
public static Map<FFlag, Boolean> factionFlagDefaults;
@ -51,9 +51,9 @@ public class Conf
// what faction ID to start new players in when they first join the server; default is 0, "no faction"
public static String newPlayerStartingFactionID = "0";
public static boolean showMapFactionKey = true;
public static boolean showNeutralFactionsOnMap = true;
public static boolean showEnemyFactionsOnMap = true;
//public static boolean showMapFactionKey = true;
//public static boolean showNeutralFactionsOnMap = true;
//public static boolean showEnemyFactionsOnMap = true;
// Disallow joining/leaving/kicking while power is negative
public static boolean canLeaveWithNegativePower = true;

View File

@ -38,13 +38,13 @@ public class Faction extends Entity implements EconomyParticipator
private String tag;
public String getTag() { return this.tag; }
public String getTag(String prefix) { return prefix+this.tag; }
public String getTag(Faction otherFaction)
public String getTag(RelationParticipator observer)
{
if (otherFaction == null)
if (observer == null)
{
return getTag();
}
return this.getTag(this.getColorTo(otherFaction).toString());
return this.getTag(this.getColorTo(observer).toString());
}
public String getTag(FPlayer otherFplayer) {
if (otherFplayer == null)

View File

@ -37,10 +37,9 @@ public class CmdFlag extends FCommand
}
if (faction == null) return;
msg(p.txt.titleize("Flag(s) for " + faction.describeTo(fme)));
if ( ! this.argIsSet(1))
{
msg(p.txt.titleize("Flags for " + faction.describeTo(fme)));
for (FFlag flag : FFlag.values())
{
msg(flag.getStateInfo(faction.getFlag(flag), true));
@ -52,6 +51,7 @@ public class CmdFlag extends FCommand
if (flag == null) return;
if ( ! this.argIsSet(2))
{
msg(p.txt.titleize("Flag for " + faction.describeTo(fme)));
msg(flag.getStateInfo(faction.getFlag(flag), true));
return;
}
@ -81,6 +81,7 @@ public class CmdFlag extends FCommand
}
// Do the change
msg(p.txt.titleize("Flag for " + faction.describeTo(fme)));
faction.setFlag(flag, targetValue);
msg(flag.getStateInfo(faction.getFlag(flag), true));
}

View File

@ -42,10 +42,9 @@ public class CmdPerm extends FCommand
}
if (faction == null) return;
msg(p.txt.titleize("Perm(s) for " + faction.describeTo(fme)));
if ( ! this.argIsSet(1))
{
msg(p.txt.titleize("Perms for " + faction.describeTo(fme)));
for (FPerm perm : FPerm.values())
{
msg(perm.getStateInfo(faction.getPermittedRelations(perm), true));
@ -57,6 +56,7 @@ public class CmdPerm extends FCommand
if (perm == null) return;
if ( ! this.argIsSet(2))
{
msg(p.txt.titleize("Perm for " + faction.describeTo(fme)));
msg(perm.getStateInfo(faction.getPermittedRelations(perm), true));
return;
}
@ -81,6 +81,7 @@ public class CmdPerm extends FCommand
// Do the change
faction.setPermittedRelations(perm, targetValue);
msg(p.txt.titleize("Perm for " + faction.describeTo(fme)));
msg(perm.getStateInfo(faction.getPermittedRelations(perm), true));
}

View File

@ -28,6 +28,29 @@ public class FactionsBlockListener extends BlockListener
this.p = p;
}
public static boolean playerCanBuildDestroyBlock(Player player, Block block, String action, boolean justCheck)
{
FPlayer me = FPlayers.i.get(player);
if (me.isAdminBypassing()) return true;
Location location = block.getLocation();
FLocation loc = new FLocation(location);
Faction factionHere = Board.getFactionAt(loc);
if (FPerm.PAINBUILD.has(me, location))
{
if (!justCheck)
{
me.msg("<b>It is painful to %s in the territory of %s<b>.", action, factionHere.describeTo(me));
player.damage(Conf.actionDeniedPainAmount);
}
return true;
}
return FPerm.BUILD.has(me, location, true);
}
@Override
public void onBlockPlace(BlockPlaceEvent event)
{
@ -62,8 +85,9 @@ public class FactionsBlockListener extends BlockListener
public void onBlockDamage(BlockDamageEvent event)
{
if (event.isCancelled()) return;
if ( ! event.getInstaBreak()) return;
if (event.getInstaBreak() && ! playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock(), "destroy", false))
if (! playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock(), "destroy", false))
{
event.setCancelled(true);
}
@ -113,27 +137,4 @@ public class FactionsBlockListener extends BlockListener
event.setCancelled(true);
}
}
public static boolean playerCanBuildDestroyBlock(Player player, Block block, String action, boolean justCheck)
{
FPlayer me = FPlayers.i.get(player);
if (me.isAdminBypassing()) return true;
Location location = block.getLocation();
FLocation loc = new FLocation(location);
Faction factionHere = Board.getFactionAt(loc);
if (FPerm.PAINBUILD.has(me, location))
{
if (!justCheck)
{
me.msg("<b>It is painful to %s in the territory of %s<b>.", action, factionHere.describeTo(me));
player.damage(Conf.actionDeniedPainAmount);
}
return true;
}
return FPerm.BUILD.has(me, location, true);
}
}

View File

@ -81,7 +81,14 @@ public enum FPerm
{
rels.add("<p>"+rel.nicename);
}
if (rels.size() > 0)
{
ret += TextUtil.implode(rels, "<c>+");
}
else
{
ret += "NOONE";
}
if (withDesc)
{

View File

@ -22,6 +22,7 @@ import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.P;
// TODO: Is this one even used anymore??
public class MapFLocToStringSetTypeAdapter implements JsonDeserializer<Map<FLocation, Set<String>>>, JsonSerializer<Map<FLocation, Set<String>>>
{

View File

@ -2,6 +2,7 @@ package com.massivecraft.factions.util;
import org.bukkit.ChatColor;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.iface.RelationParticipator;
@ -121,26 +122,19 @@ public class RelationUtil
public static ChatColor getColorOfThatToMe(RelationParticipator that, RelationParticipator me)
{
//Faction thatFaction = getFaction(that);
// TODO: Add special colors to zone as a feature to replace this one
/*if (thatFaction != null)
Faction thatFaction = getFaction(that);
if (thatFaction != null && thatFaction != getFaction(me))
{
if (thatFaction.isPeaceful() && thatFaction != getFaction(me))
if (thatFaction.getFlag(FFlag.FRIENDLYFIRE) == true)
{
return Conf.colorPeaceful;
return Conf.colorFriendlyFire;
}
if (thatFaction.isSafeZone() && thatFaction != getFaction(me))
if (thatFaction.getFlag(FFlag.PVP) == false)
{
return Conf.colorPeaceful;
return Conf.colorNoPVP;
}
if (thatFaction.isWarZone() && thatFaction != getFaction(me))
{
return Conf.colorWar;
}
}*/
return getRelationTo(that, me).getColor();
}
}