From f03733f488a8020e2a69013ec525cdab873ec153 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Tue, 15 Mar 2016 20:43:54 +0100 Subject: [PATCH] MassiveCore - Object Titles and Mixed Messages --- .../cmd/CmdFactionsAccessAbstract.java | 5 +++- .../factions/cmd/CmdFactionsExpansions.java | 4 ++- .../factions/cmd/CmdFactionsFlagShow.java | 2 +- .../factions/cmd/CmdFactionsMap.java | 2 +- .../factions/cmd/CmdFactionsPermSet.java | 2 +- .../factions/cmd/CmdFactionsPermShow.java | 2 +- .../factions/cmd/CmdFactionsPlayer.java | 2 +- .../factions/engine/EngineMain.java | 4 +-- .../massivecraft/factions/entity/Board.java | 26 +++++++++++-------- .../factions/entity/BoardColl.java | 4 +-- .../factions/entity/BoardInterface.java | 4 +-- .../massivecraft/factions/entity/Faction.java | 23 ++++++++++++---- 12 files changed, 51 insertions(+), 29 deletions(-) diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsAccessAbstract.java b/src/com/massivecraft/factions/cmd/CmdFactionsAccessAbstract.java index 769cd8bc..c2ad4559 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsAccessAbstract.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsAccessAbstract.java @@ -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("Host Faction: %s", hostFaction.describeTo(msender, true)); msg("Host Faction Allowed: %s", ta.isHostFactionAllowed() ? Txt.parse("TRUE") : Txt.parse("FALSE")); msg("Granted Players: %s", describeRelationParticipators(ta.getGrantedMPlayers(), msender)); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsExpansions.java b/src/com/massivecraft/factions/cmd/CmdFactionsExpansions.java index bf14ac85..1083e3df 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsExpansions.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsExpansions.java @@ -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 entry : event.getExpansions().entrySet()) diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsFlagShow.java b/src/com/massivecraft/factions/cmd/CmdFactionsFlagShow.java index 93349af9..9b941bdb 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsFlagShow.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsFlagShow.java @@ -45,7 +45,7 @@ public class CmdFactionsFlagShow extends FactionsCommand Collection mflags = this.readArg(MFlag.getAll()); // Create messages - List messages = new ArrayList(); + List messages = new ArrayList<>(); messages.add(Txt.titleize("Flag for " + faction.describeTo(msender, true))); for (MFlag mflag : mflags) { diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsMap.java b/src/com/massivecraft/factions/cmd/CmdFactionsMap.java index 59069b81..0070fa54 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsMap.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsMap.java @@ -65,7 +65,7 @@ public class CmdFactionsMap extends FactionsCommand public void showMap(int width, int height) { Location location = me.getLocation(); - List message = BoardColl.get().getMap(msenderFaction, PS.valueOf(location), location.getYaw(), width, height); + List message = BoardColl.get().getMap(msenderFaction, PS.valueOf(location), location.getYaw(), width, height); message(message); } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPermSet.java b/src/com/massivecraft/factions/cmd/CmdFactionsPermSet.java index c58ef663..1eac5e78 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsPermSet.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsPermSet.java @@ -84,7 +84,7 @@ public class CmdFactionsPermSet extends FactionsCommand } // Create messages - List messages = new ArrayList(); + List messages = new ArrayList<>(); // Inform sender messages.add(Txt.titleize("Perm for " + faction.describeTo(msender, true))); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPermShow.java b/src/com/massivecraft/factions/cmd/CmdFactionsPermShow.java index b2ff8dc5..d0d629f5 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsPermShow.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsPermShow.java @@ -45,7 +45,7 @@ public class CmdFactionsPermShow extends FactionsCommand Collection mperms = this.readArg(MPerm.getAll()); // Create messages - List messages = new ArrayList(); + List messages = new ArrayList<>(); messages.add(Txt.titleize("Perm for " + faction.describeTo(msender, true))); messages.add(MPerm.getStateHeaders()); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPlayer.java b/src/com/massivecraft/factions/cmd/CmdFactionsPlayer.java index 0961f1dd..f03af921 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsPlayer.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsPlayer.java @@ -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; diff --git a/src/com/massivecraft/factions/engine/EngineMain.java b/src/com/massivecraft/factions/engine/EngineMain.java index 9e83c8fc..bb5da4c3 100644 --- a/src/com/massivecraft/factions/engine/EngineMain.java +++ b/src/com/massivecraft/factions/engine/EngineMain.java @@ -384,7 +384,7 @@ public class EngineMain extends Engine if (!Mixin.isActualJoin(event)) return; // ... then prepare the messages ... - final List messages = faction.getMotdMessages(); + final List 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 message = BoardColl.get().getMap(mplayer, chunkTo, player.getLocation().getYaw(), Const.MAP_WIDTH, Const.MAP_HEIGHT); + List message = BoardColl.get().getMap(mplayer, chunkTo, player.getLocation().getYaw(), Const.MAP_WIDTH, Const.MAP_HEIGHT); mplayer.message(message); } else if (factionFrom != factionTo) diff --git a/src/com/massivecraft/factions/entity/Board.java b/src/com/massivecraft/factions/entity/Board.java index ceefc5db..e2d7d4c2 100644 --- a/src/com/massivecraft/factions/entity/Board.java +++ b/src/com/massivecraft/factions/entity/Board.java @@ -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 implements BoardInterface // MAP GENERATION @Override - public ArrayList getMap(RelationParticipator observer, PS centerPs, double inDegrees, int width, int height) + public List getMap(RelationParticipator observer, PS centerPs, double inDegrees, int width, int height) { centerPs = centerPs.getChunkCoords(true); - ArrayList ret = new ArrayList(); + List 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 implements BoardInterface PS topLeftPs = centerPs.plusChunkCoords(-halfWidth, -halfHeight); + // Get the compass + ArrayList asciiCompass = AsciiCompass.getAsciiCompass(inDegrees, ChatColor.RED, Txt.parse("")); + // Make room for the list of names height--; @@ -404,16 +408,16 @@ public class Board extends Entity 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 asciiCompass = AsciiCompass.getAsciiCompass(inDegrees, ChatColor.RED, Txt.parse("")); - - // 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()) diff --git a/src/com/massivecraft/factions/entity/BoardColl.java b/src/com/massivecraft/factions/entity/BoardColl.java index 3679cc16..e38b02d7 100644 --- a/src/com/massivecraft/factions/entity/BoardColl.java +++ b/src/com/massivecraft/factions/entity/BoardColl.java @@ -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 implements BoardInterface // MAP GENERATION @Override - public ArrayList getMap(RelationParticipator observer, PS centerPs, double inDegrees, int width, int height) + public List getMap(RelationParticipator observer, PS centerPs, double inDegrees, int width, int height) { if (centerPs == null) return null; Board board = this.get(centerPs.getWorld()); diff --git a/src/com/massivecraft/factions/entity/BoardInterface.java b/src/com/massivecraft/factions/entity/BoardInterface.java index 79daf440..9e4b101d 100644 --- a/src/com/massivecraft/factions/entity/BoardInterface.java +++ b/src/com/massivecraft/factions/entity/BoardInterface.java @@ -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 getMap(RelationParticipator observer, PS centerPs, double inDegrees, int width, int height); + public List getMap(RelationParticipator observer, PS centerPs, double inDegrees, int width, int height); } diff --git a/src/com/massivecraft/factions/entity/Faction.java b/src/com/massivecraft/factions/entity/Faction.java index c3275985..a69a8c1c 100644 --- a/src/com/massivecraft/factions/entity/Faction.java +++ b/src/com/massivecraft/factions/entity/Faction.java @@ -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 implements EconomyParticipator, Nam // FINER - public List getMotdMessages() + public List getMotdMessages() { - final String title = Txt.titleize(this.getName() + " - Message of the Day"); - final String motd = "" + this.getMotd(); - final List messages = Txt.parse(MUtil.list(title, motd, "")); - return messages; + // Create + List ret = new MassiveList<>(); + + // Fill + Object title = this.getName() + " - Message of the Day"; + title = Txt.titleize(title); + ret.add(title); + + String motd = Txt.parse("" + this.getMotd()); + ret.add(motd); + + ret.add(""); + + // Return + return ret; } // -------------------------------------------- //