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

@@ -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;
}
// -------------------------------------------- //