From 8ad812bea68cd79424da1d9eb6595e862e320fb6 Mon Sep 17 00:00:00 2001 From: TheComputerGeek2 Date: Mon, 6 Mar 2017 11:23:03 -0800 Subject: [PATCH] Make types look nicer --- src/com/massivecraft/factions/Rel.java | 82 ++++++++----------- .../factions/cmd/type/TypeFaction.java | 3 + .../event/EventFactionsChunkChangeType.java | 32 ++++++-- 3 files changed, 60 insertions(+), 57 deletions(-) diff --git a/src/com/massivecraft/factions/Rel.java b/src/com/massivecraft/factions/Rel.java index 9b2b888c..6a16ade9 100644 --- a/src/com/massivecraft/factions/Rel.java +++ b/src/com/massivecraft/factions/Rel.java @@ -6,10 +6,11 @@ import java.util.Set; import org.bukkit.ChatColor; import com.massivecraft.factions.entity.MConf; +import com.massivecraft.massivecore.Colorized; +import com.massivecraft.massivecore.Named; import com.massivecraft.massivecore.collections.MassiveSet; - -public enum Rel +public enum Rel implements Colorized, Named { // -------------------------------------------- // // ENUM @@ -18,35 +19,42 @@ public enum Rel ENEMY( "an enemy", "enemies", "an enemy faction", "enemy factions", "Enemy" - ), + ) { @Override public ChatColor getColor() { return MConf.get().colorEnemy; } }, + NEUTRAL( "someone neutral to you", "those neutral to you", "a neutral faction", "neutral factions", "Neutral" - ), + ) { @Override public ChatColor getColor() { return MConf.get().colorNeutral; } }, + TRUCE( "someone in truce with you", "those in truce with you", "a faction in truce", "factions in truce", "Truce" - ), + ) { @Override public ChatColor getColor() { return MConf.get().colorTruce; } }, + ALLY( "an ally", "allies", "an allied faction", "allied factions", "Ally" - ), + ) { @Override public ChatColor getColor() { return MConf.get().colorAlly; } }, + RECRUIT( "a recruit in your faction", "recruits in your faction", "", "", "Recruit" - ), + ) { @Override public String getPrefix() { return MConf.get().prefixRecruit; } }, + MEMBER( "a member in your faction", "members in your faction", "your faction", "your factions", "Member" - ), - OFFICER - ( + ) { @Override public String getPrefix() { return MConf.get().prefixMember; } }, + + OFFICER( "an officer in your faction", "officers in your faction", "", "", "Officer", "Moderator" - ), - LEADER("your faction leader", "your faction leader", "", "", + ) { @Override public String getPrefix() { return MConf.get().prefixOfficer; } }, + + LEADER( + "your faction leader", "your faction leader", "", "", "Leader", "Admin", "Owner" - ), + ) { @Override public String getPrefix() { return MConf.get().prefixLeader; } }, // END OF LIST ; @@ -71,13 +79,13 @@ public enum Rel private final Set names; public Set getNames() { return this.names; } - public String getName() { return this.getNames().iterator().next(); } + @Override public String getName() { return this.getNames().iterator().next(); } // -------------------------------------------- // // CONSTRUCT // -------------------------------------------- // - private Rel(String descPlayerOne, String descPlayerMany, String descFactionOne, String descFactionMany, String... names) + Rel(String descPlayerOne, String descPlayerMany, String descFactionOne, String descFactionMany, String... names) { this.descPlayerOne = descPlayerOne; this.descPlayerMany = descPlayerMany; @@ -86,6 +94,16 @@ public enum Rel this.names = Collections.unmodifiableSet(new MassiveSet(names)); } + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public ChatColor getColor() + { + return MConf.get().colorMember; + } + // -------------------------------------------- // // UTIL // -------------------------------------------- // @@ -121,42 +139,8 @@ public enum Rel return this.isAtLeast(TRUCE); } - public ChatColor getColor() - { - if (this.isAtLeast(RECRUIT)) - return MConf.get().colorMember; - else if (this == ALLY) - return MConf.get().colorAlly; - else if (this == NEUTRAL) - return MConf.get().colorNeutral; - else if (this == TRUCE) - return MConf.get().colorTruce; - else - return MConf.get().colorEnemy; - } - public String getPrefix() { - if (this == LEADER) - { - return MConf.get().prefixLeader; - } - - if (this == OFFICER) - { - return MConf.get().prefixOfficer; - } - - if (this == MEMBER) - { - return MConf.get().prefixMember; - } - - if (this == RECRUIT) - { - return MConf.get().prefixRecruit; - } - return ""; } diff --git a/src/com/massivecraft/factions/cmd/type/TypeFaction.java b/src/com/massivecraft/factions/cmd/type/TypeFaction.java index fb8448b3..2aa3a786 100644 --- a/src/com/massivecraft/factions/cmd/type/TypeFaction.java +++ b/src/com/massivecraft/factions/cmd/type/TypeFaction.java @@ -79,13 +79,16 @@ public class TypeFaction extends TypeAbstract @Override public Collection getTabList(CommandSender sender, String arg) { + // Create Set ret = new TreeSet(ComparatorCaseInsensitive.get()); + // Fill for (Faction faction : FactionColl.get().getAll()) { ret.add(ChatColor.stripColor(faction.getName())); } + // Return return ret; } diff --git a/src/com/massivecraft/factions/event/EventFactionsChunkChangeType.java b/src/com/massivecraft/factions/event/EventFactionsChunkChangeType.java index 15e7e1b0..09bae0cc 100644 --- a/src/com/massivecraft/factions/event/EventFactionsChunkChangeType.java +++ b/src/com/massivecraft/factions/event/EventFactionsChunkChangeType.java @@ -1,18 +1,21 @@ package com.massivecraft.factions.event; -import com.massivecraft.factions.entity.Faction; +import org.bukkit.ChatColor; -public enum EventFactionsChunkChangeType +import com.massivecraft.factions.entity.Faction; +import com.massivecraft.massivecore.Colorized; + +public enum EventFactionsChunkChangeType implements Colorized { // -------------------------------------------- // // ENUM // -------------------------------------------- // - NONE("none", "none"), - BUY("buy", "bought"), - SELL("sell", "sold"), - CONQUER("conquer", "conquered"), - PILLAGE("pillage", "pillaged"), + NONE("none", "none", ChatColor.WHITE), + BUY("buy", "bought", ChatColor.GREEN), + SELL("sell", "sold", ChatColor.GREEN), + CONQUER("conquer", "conquered", ChatColor.DARK_GREEN), + PILLAGE("pillage", "pillaged", ChatColor.RED), // END OF LIST ; @@ -24,14 +27,27 @@ public enum EventFactionsChunkChangeType public final String now; public final String past; + public final ChatColor color; + // -------------------------------------------- // // CONSTRUCT // -------------------------------------------- // - EventFactionsChunkChangeType(String now, String past) + EventFactionsChunkChangeType(String now, String past, ChatColor color) { this.now = now; this.past = past; + this.color = color; + } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public ChatColor getColor() + { + return this.color; } // -------------------------------------------- //