MassiveCore - Object Titles and Mixed Messages

This commit is contained in:
Olof Larsson 2016-03-15 20:43:54 +01:00
parent 7c131f270b
commit f03733f488
12 changed files with 51 additions and 29 deletions

View File

@ -53,7 +53,10 @@ public abstract class CmdFactionsAccessAbstract extends FactionsCommand
public void sendAccessInfo()
{
message(Txt.titleize("Access at " + chunk.toString(PSFormatHumanSpace.get())));
Object title = "Access at " + chunk.toString(PSFormatHumanSpace.get());
title = Txt.titleize(title);
message(title);
msg("<k>Host Faction: %s", hostFaction.describeTo(msender, true));
msg("<k>Host Faction Allowed: %s", ta.isHostFactionAllowed() ? Txt.parse("<lime>TRUE") : Txt.parse("<rose>FALSE"));
msg("<k>Granted Players: %s", describeRelationParticipators(ta.getGrantedMPlayers(), msender));

View File

@ -34,7 +34,9 @@ public class CmdFactionsExpansions extends FactionsCommand
event.run();
// Title
msg(Txt.titleize("Factions Expansions"));
Object title = "Factions Expansions";
title = Txt.titleize(title);
message(title);
// Lines
for (Entry<String, Boolean> entry : event.getExpansions().entrySet())

View File

@ -45,7 +45,7 @@ public class CmdFactionsFlagShow extends FactionsCommand
Collection<MFlag> mflags = this.readArg(MFlag.getAll());
// Create messages
List<String> messages = new ArrayList<String>();
List<Object> messages = new ArrayList<>();
messages.add(Txt.titleize("Flag for " + faction.describeTo(msender, true)));
for (MFlag mflag : mflags)
{

View File

@ -65,7 +65,7 @@ public class CmdFactionsMap extends FactionsCommand
public void showMap(int width, int height)
{
Location location = me.getLocation();
List<String> message = BoardColl.get().getMap(msenderFaction, PS.valueOf(location), location.getYaw(), width, height);
List<Object> message = BoardColl.get().getMap(msenderFaction, PS.valueOf(location), location.getYaw(), width, height);
message(message);
}

View File

@ -84,7 +84,7 @@ public class CmdFactionsPermSet extends FactionsCommand
}
// Create messages
List<String> messages = new ArrayList<String>();
List<Object> messages = new ArrayList<>();
// Inform sender
messages.add(Txt.titleize("Perm for " + faction.describeTo(msender, true)));

View File

@ -45,7 +45,7 @@ public class CmdFactionsPermShow extends FactionsCommand
Collection<MPerm> mperms = this.readArg(MPerm.getAll());
// Create messages
List<String> messages = new ArrayList<String>();
List<Object> messages = new ArrayList<>();
messages.add(Txt.titleize("Perm for " + faction.describeTo(msender, true)));
messages.add(MPerm.getStateHeaders());

View File

@ -44,7 +44,7 @@ public class CmdFactionsPlayer extends FactionsCommand
MPlayer mplayer = this.readArg(msender);
// INFO: Title
msg(Txt.titleize("Player " + mplayer.describeTo(msender)));
message(Txt.titleize("Player " + mplayer.describeTo(msender)));
// INFO: Power (as progress bar)
double progressbarQuota = 0;

View File

@ -384,7 +384,7 @@ public class EngineMain extends Engine
if (!Mixin.isActualJoin(event)) return;
// ... then prepare the messages ...
final List<String> messages = faction.getMotdMessages();
final List<Object> messages = faction.getMotdMessages();
// ... and send to the player.
if (MConf.get().motdDelayTicks < 0)
@ -669,7 +669,7 @@ public class EngineMain extends Engine
// send host faction info updates
if (mplayer.isMapAutoUpdating())
{
List<String> message = BoardColl.get().getMap(mplayer, chunkTo, player.getLocation().getYaw(), Const.MAP_WIDTH, Const.MAP_HEIGHT);
List<Object> message = BoardColl.get().getMap(mplayer, chunkTo, player.getLocation().getYaw(), Const.MAP_WIDTH, Const.MAP_HEIGHT);
mplayer.message(message);
}
else if (factionFrom != factionTo)

View File

@ -5,6 +5,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
@ -348,11 +349,11 @@ public class Board extends Entity<Board> implements BoardInterface
// MAP GENERATION
@Override
public ArrayList<String> getMap(RelationParticipator observer, PS centerPs, double inDegrees, int width, int height)
public List<Object> getMap(RelationParticipator observer, PS centerPs, double inDegrees, int width, int height)
{
centerPs = centerPs.getChunkCoords(true);
ArrayList<String> ret = new ArrayList<String>();
List<Object> ret = new ArrayList<>();
Faction centerFaction = this.getFactionAt(centerPs);
ret.add(Txt.titleize("(" + centerPs.getChunkX() + "," + centerPs.getChunkZ() + ") " + centerFaction.getName(observer)));
@ -364,6 +365,9 @@ public class Board extends Entity<Board> implements BoardInterface
PS topLeftPs = centerPs.plusChunkCoords(-halfWidth, -halfHeight);
// Get the compass
ArrayList<String> asciiCompass = AsciiCompass.getAsciiCompass(inDegrees, ChatColor.RED, Txt.parse("<a>"));
// Make room for the list of names
height--;
@ -404,16 +408,16 @@ public class Board extends Entity<Board> implements BoardInterface
row.append(hereFaction.getColorTo(observer).toString()).append(fchar);
}
}
ret.add(row.toString());
String line = row.toString();
// Add the compass
if (dz == 0) line = asciiCompass.get(0) + line.substring(3*3);
if (dz == 1) line = asciiCompass.get(1) + line.substring(3*3);
if (dz == 2) line = asciiCompass.get(2) + line.substring(3*3);
ret.add(line);
}
// Get the compass
ArrayList<String> asciiCompass = AsciiCompass.getAsciiCompass(inDegrees, ChatColor.RED, Txt.parse("<a>"));
// Add the compass
ret.set(1, asciiCompass.get(0) + ret.get(1).substring(3*3));
ret.set(2, asciiCompass.get(1) + ret.get(2).substring(3*3));
ret.set(3, asciiCompass.get(2) + ret.get(3).substring(3*3));
String fRow = "";
for (Faction keyfaction : fList.keySet())

View File

@ -1,10 +1,10 @@
package com.massivecraft.factions.entity;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
@ -283,7 +283,7 @@ public class BoardColl extends Coll<Board> implements BoardInterface
// MAP GENERATION
@Override
public ArrayList<String> getMap(RelationParticipator observer, PS centerPs, double inDegrees, int width, int height)
public List<Object> getMap(RelationParticipator observer, PS centerPs, double inDegrees, int width, int height)
{
if (centerPs == null) return null;
Board board = this.get(centerPs.getWorld());

View File

@ -1,6 +1,6 @@
package com.massivecraft.factions.entity;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -41,6 +41,6 @@ public interface BoardInterface
// MAP
// TODO: Could the degrees be embedded in centerPs yaw instead?
public ArrayList<String> getMap(RelationParticipator observer, PS centerPs, double inDegrees, int width, int height);
public List<Object> getMap(RelationParticipator observer, PS centerPs, double inDegrees, int width, int height);
}

View File

@ -27,11 +27,13 @@ import com.massivecraft.factions.RelationParticipator;
import com.massivecraft.factions.util.MiscUtil;
import com.massivecraft.factions.util.RelationUtil;
import com.massivecraft.massivecore.Named;
import com.massivecraft.massivecore.collections.MassiveList;
import com.massivecraft.massivecore.collections.MassiveMapDef;
import com.massivecraft.massivecore.collections.MassiveTreeSetDef;
import com.massivecraft.massivecore.comparator.ComparatorCaseInsensitive;
import com.massivecraft.massivecore.mixin.Mixin;
import com.massivecraft.massivecore.money.Money;
import com.massivecraft.massivecore.mson.Mson;
import com.massivecraft.massivecore.predicate.Predicate;
import com.massivecraft.massivecore.ps.PS;
import com.massivecraft.massivecore.store.Entity;
@ -303,12 +305,23 @@ public class Faction extends Entity<Faction> implements EconomyParticipator, Nam
// FINER
public List<String> getMotdMessages()
public List<Object> getMotdMessages()
{
final String title = Txt.titleize(this.getName() + " - Message of the Day");
final String motd = "<i>" + this.getMotd();
final List<String> messages = Txt.parse(MUtil.list(title, motd, ""));
return messages;
// Create
List<Object> ret = new MassiveList<>();
// Fill
Object title = this.getName() + " - Message of the Day";
title = Txt.titleize(title);
ret.add(title);
String motd = Txt.parse("<i>" + this.getMotd());
ret.add(motd);
ret.add("");
// Return
return ret;
}
// -------------------------------------------- //