mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-11-27 04:35:21 +01:00
Moving prefixes and chat from ConfServer to MConf
This commit is contained in:
parent
ec8be2d2c0
commit
b0871b0ee6
@ -2,9 +2,6 @@ package com.massivecraft.factions;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
import com.massivecraft.mcore.SimpleConfig;
|
||||
import com.massivecraft.mcore.util.MUtil;
|
||||
|
||||
@ -25,8 +22,6 @@ public class ConfServer extends SimpleConfig
|
||||
public static List<String> baseCommandAliases = MUtil.list("f");
|
||||
public static String dburi = "default";
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------- //
|
||||
// DOUBTFULLY CONFIGURABLE DEFAULTS (TODO)
|
||||
// -------------------------------------------- //
|
||||
@ -62,15 +57,6 @@ public class ConfServer extends SimpleConfig
|
||||
|
||||
public static double powerFactionMax = 0.0; // if greater than 0, the cap on how much power a faction can have (additional power from players beyond that will act as a "buffer" of sorts)
|
||||
|
||||
// -------------------------------------------- //
|
||||
// PREFIXES
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static String prefixLeader = "**";
|
||||
public static String prefixOfficer = "*";
|
||||
public static String prefixMember = "+";
|
||||
public static String prefixRecruit = "-";
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CORE
|
||||
// -------------------------------------------- //
|
||||
@ -90,43 +76,7 @@ public class ConfServer extends SimpleConfig
|
||||
// Disallow joining/leaving/kicking while power is negative
|
||||
public static boolean canLeaveWithNegativePower = true;
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CHAT
|
||||
// -------------------------------------------- //
|
||||
|
||||
// We offer a simple standard way to set the format
|
||||
public static boolean chatSetFormat = false;
|
||||
public static EventPriority chatSetFormatAt = EventPriority.LOWEST;
|
||||
public static String chatSetFormatTo = "<{factions_relcolor}§l{factions_roleprefix}§r{factions_relcolor}{factions_tag|rp}§f%1$s> %2$s";
|
||||
|
||||
// We offer a simple standard way to parse the chat tags
|
||||
public static boolean chatParseTags = true;
|
||||
public static EventPriority chatParseTagsAt = EventPriority.LOW;
|
||||
|
||||
// TODO: What is this line and can I get rid of it?
|
||||
public static String chatTagFormat = "%s"+ChatColor.WHITE; // This one is almost deprecated now right? or is it?
|
||||
|
||||
// HeroChat: The Faction Channel
|
||||
public static String herochatFactionName = "Faction";
|
||||
public static String herochatFactionNick = "F";
|
||||
public static String herochatFactionFormat = "{color}[&l{nick}&r{color} &l{factions_roleprefix}&r{color}{factions_title|rp}{sender}{color}] &f{msg}";
|
||||
public static ChatColor herochatFactionColor = ChatColor.GREEN;
|
||||
public static int herochatFactionDistance = 0;
|
||||
public static boolean herochatFactionIsShortcutAllowed = false;
|
||||
public static boolean herochatFactionCrossWorld = true;
|
||||
public static boolean herochatFactionMuted = false;
|
||||
public static Set<String> herochatFactionWorlds = new HashSet<String>();
|
||||
|
||||
// HeroChat: The Allies Channel
|
||||
public static String herochatAlliesName = "Allies";
|
||||
public static String herochatAlliesNick = "A";
|
||||
public static String herochatAlliesFormat = "{color}[&l{nick}&r&f {factions_relcolor}&l{factions_roleprefix}&r{factions_relcolor}{factions_tag|rp}{sender}{color}] &f{msg}";
|
||||
public static ChatColor herochatAlliesColor = ChatColor.DARK_PURPLE;
|
||||
public static int herochatAlliesDistance = 0;
|
||||
public static boolean herochatAlliesIsShortcutAllowed = false;
|
||||
public static boolean herochatAlliesCrossWorld = true;
|
||||
public static boolean herochatAlliesMuted = false;
|
||||
public static Set<String> herochatAlliesWorlds = new HashSet<String>();
|
||||
|
||||
// -------------------------------------------- //
|
||||
// AUTO LEAVE
|
||||
|
@ -23,6 +23,7 @@ import com.massivecraft.factions.entity.Board;
|
||||
import com.massivecraft.factions.entity.BoardColl;
|
||||
import com.massivecraft.factions.entity.FPlayerColl;
|
||||
import com.massivecraft.factions.entity.FactionColl;
|
||||
import com.massivecraft.factions.entity.MConfColl;
|
||||
import com.massivecraft.factions.integration.LWCFeatures;
|
||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||
import com.massivecraft.factions.integration.Worldguard;
|
||||
@ -79,6 +80,7 @@ public class Factions extends MPlugin
|
||||
MUtil.registerExtractor(String.class, "accountId", ExtractorFactionAccountId.get());
|
||||
|
||||
// Initialize Collections
|
||||
MConfColl.get().init();
|
||||
FPlayerColl.get().init();
|
||||
FactionColl.get().init();
|
||||
BoardColl.get().init();
|
||||
|
@ -136,22 +136,22 @@ public enum Rel
|
||||
{
|
||||
if (this == LEADER)
|
||||
{
|
||||
return ConfServer.prefixLeader;
|
||||
return MConf.get().prefixLeader;
|
||||
}
|
||||
|
||||
if (this == OFFICER)
|
||||
{
|
||||
return ConfServer.prefixOfficer;
|
||||
return MConf.get().prefixOfficer;
|
||||
}
|
||||
|
||||
if (this == MEMBER)
|
||||
{
|
||||
return ConfServer.prefixMember;
|
||||
return MConf.get().prefixMember;
|
||||
}
|
||||
|
||||
if (this == RECRUIT)
|
||||
{
|
||||
return ConfServer.prefixRecruit;
|
||||
return MConf.get().prefixRecruit;
|
||||
}
|
||||
|
||||
return "";
|
||||
|
@ -565,38 +565,6 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
||||
return this.getColorTo(fplayer)+this.getNameAndTitle();
|
||||
}
|
||||
|
||||
// Chat Tag:
|
||||
// These are injected into the format of global chat messages.
|
||||
|
||||
public String getChatTag()
|
||||
{
|
||||
if ( ! this.hasFaction()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return String.format(ConfServer.chatTagFormat, this.role.getPrefix()+this.getTag());
|
||||
}
|
||||
|
||||
// Colored Chat Tag
|
||||
public String getChatTag(Faction faction)
|
||||
{
|
||||
if ( ! this.hasFaction()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return this.getRelationTo(faction).getColor()+getChatTag();
|
||||
}
|
||||
|
||||
public String getChatTag(FPlayer fplayer)
|
||||
{
|
||||
if ( ! this.hasFaction())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
return this.getColorTo(fplayer)+getChatTag();
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// RELATION AND RELATION COLORS
|
||||
// -------------------------------------------- //
|
||||
|
@ -1,6 +1,10 @@
|
||||
package com.massivecraft.factions.entity;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
import com.massivecraft.mcore.MCore;
|
||||
import com.massivecraft.mcore.store.Entity;
|
||||
@ -30,5 +34,49 @@ public class MConf extends Entity<MConf>
|
||||
public ChatColor colorFriendlyFire = ChatColor.DARK_RED;
|
||||
//public ChatColor colorWilderness = ChatColor.DARK_GREEN;
|
||||
|
||||
// -------------------------------------------- //
|
||||
// PREFIXES
|
||||
// -------------------------------------------- //
|
||||
|
||||
public String prefixLeader = "**";
|
||||
public String prefixOfficer = "*";
|
||||
public String prefixMember = "+";
|
||||
public String prefixRecruit = "-";
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CHAT
|
||||
// -------------------------------------------- //
|
||||
|
||||
// We offer a simple standard way to set the format
|
||||
public boolean chatSetFormat = false;
|
||||
public EventPriority chatSetFormatAt = EventPriority.LOWEST;
|
||||
public String chatSetFormatTo = "<{factions_relcolor}§l{factions_roleprefix}§r{factions_relcolor}{factions_tag|rp}§f%1$s> %2$s";
|
||||
|
||||
// We offer a simple standard way to parse the chat tags
|
||||
public boolean chatParseTags = true;
|
||||
public EventPriority chatParseTagsAt = EventPriority.LOW;
|
||||
|
||||
// HeroChat: The Faction Channel
|
||||
public String herochatFactionName = "Faction";
|
||||
public String herochatFactionNick = "F";
|
||||
public String herochatFactionFormat = "{color}[&l{nick}&r{color} &l{factions_roleprefix}&r{color}{factions_title|rp}{sender}{color}] &f{msg}";
|
||||
public ChatColor herochatFactionColor = ChatColor.GREEN;
|
||||
public int herochatFactionDistance = 0;
|
||||
public boolean herochatFactionIsShortcutAllowed = false;
|
||||
public boolean herochatFactionCrossWorld = true;
|
||||
public boolean herochatFactionMuted = false;
|
||||
public Set<String> herochatFactionWorlds = new HashSet<String>();
|
||||
|
||||
// HeroChat: The Allies Channel
|
||||
public String herochatAlliesName = "Allies";
|
||||
public String herochatAlliesNick = "A";
|
||||
public String herochatAlliesFormat = "{color}[&l{nick}&r&f {factions_relcolor}&l{factions_roleprefix}&r{factions_relcolor}{factions_tag|rp}{sender}{color}] &f{msg}";
|
||||
public ChatColor herochatAlliesColor = ChatColor.DARK_PURPLE;
|
||||
public int herochatAlliesDistance = 0;
|
||||
public boolean herochatAlliesIsShortcutAllowed = false;
|
||||
public boolean herochatAlliesCrossWorld = true;
|
||||
public boolean herochatAlliesMuted = false;
|
||||
public Set<String> herochatAlliesWorlds = new HashSet<String>();
|
||||
|
||||
|
||||
}
|
@ -5,38 +5,38 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
|
||||
public class AlliesChannel extends FactionsChannelAbstract
|
||||
{
|
||||
public static final Set<Rel> targetRelations = EnumSet.of(Rel.MEMBER, Rel.ALLY);
|
||||
@Override public Set<Rel> getTargetRelations() { return targetRelations; }
|
||||
|
||||
@Override public String getName() { return ConfServer.herochatAlliesName; }
|
||||
@Override public String getName() { return MConf.get().herochatAlliesName; }
|
||||
|
||||
@Override public String getNick() { return ConfServer.herochatAlliesNick; }
|
||||
@Override public void setNick(String nick) { ConfServer.herochatAlliesNick = nick; }
|
||||
@Override public String getNick() { return MConf.get().herochatAlliesNick; }
|
||||
@Override public void setNick(String nick) { MConf.get().herochatAlliesNick = nick; }
|
||||
|
||||
@Override public String getFormat() { return ConfServer.herochatAlliesFormat; }
|
||||
@Override public void setFormat(String format) { ConfServer.herochatAlliesFormat = format; }
|
||||
@Override public String getFormat() { return MConf.get().herochatAlliesFormat; }
|
||||
@Override public void setFormat(String format) { MConf.get().herochatAlliesFormat = format; }
|
||||
|
||||
@Override public ChatColor getColor() { return ConfServer.herochatAlliesColor; }
|
||||
@Override public void setColor(ChatColor color) { ConfServer.herochatAlliesColor = color; }
|
||||
@Override public ChatColor getColor() { return MConf.get().herochatAlliesColor; }
|
||||
@Override public void setColor(ChatColor color) { MConf.get().herochatAlliesColor = color; }
|
||||
|
||||
@Override public int getDistance() { return ConfServer.herochatAlliesDistance; }
|
||||
@Override public void setDistance(int distance) { ConfServer.herochatAlliesDistance = distance; }
|
||||
@Override public int getDistance() { return MConf.get().herochatAlliesDistance; }
|
||||
@Override public void setDistance(int distance) { MConf.get().herochatAlliesDistance = distance; }
|
||||
|
||||
@Override public void addWorld(String world) { ConfServer.herochatAlliesWorlds.add(world); }
|
||||
@Override public Set<String> getWorlds() { return ConfServer.herochatAlliesWorlds; }
|
||||
@Override public void setWorlds(Set<String> worlds) { ConfServer.herochatAlliesWorlds = worlds; }
|
||||
@Override public void addWorld(String world) { MConf.get().herochatAlliesWorlds.add(world); }
|
||||
@Override public Set<String> getWorlds() { return MConf.get().herochatAlliesWorlds; }
|
||||
@Override public void setWorlds(Set<String> worlds) { MConf.get().herochatAlliesWorlds = worlds; }
|
||||
|
||||
@Override public boolean isShortcutAllowed() { return ConfServer.herochatAlliesIsShortcutAllowed; }
|
||||
@Override public void setShortcutAllowed(boolean shortcutAllowed) { ConfServer.herochatAlliesIsShortcutAllowed = shortcutAllowed; }
|
||||
@Override public boolean isShortcutAllowed() { return MConf.get().herochatAlliesIsShortcutAllowed; }
|
||||
@Override public void setShortcutAllowed(boolean shortcutAllowed) { MConf.get().herochatAlliesIsShortcutAllowed = shortcutAllowed; }
|
||||
|
||||
@Override public boolean isCrossWorld() { return ConfServer.herochatAlliesCrossWorld; }
|
||||
@Override public void setCrossWorld(boolean crossWorld) { ConfServer.herochatAlliesCrossWorld = crossWorld; }
|
||||
@Override public boolean isCrossWorld() { return MConf.get().herochatAlliesCrossWorld; }
|
||||
@Override public void setCrossWorld(boolean crossWorld) { MConf.get().herochatAlliesCrossWorld = crossWorld; }
|
||||
|
||||
@Override public boolean isMuted() { return ConfServer.herochatAlliesMuted; }
|
||||
@Override public void setMuted(boolean value) { ConfServer.herochatAlliesMuted = value; }
|
||||
@Override public boolean isMuted() { return MConf.get().herochatAlliesMuted; }
|
||||
@Override public void setMuted(boolean value) { MConf.get().herochatAlliesMuted = value; }
|
||||
}
|
||||
|
@ -6,38 +6,38 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
|
||||
public class FactionChannel extends FactionsChannelAbstract
|
||||
{
|
||||
public static final Set<Rel> targetRelations = EnumSet.of(Rel.MEMBER);
|
||||
@Override public Set<Rel> getTargetRelations() { return targetRelations; }
|
||||
|
||||
@Override public String getName() { return ConfServer.herochatFactionName; }
|
||||
@Override public String getName() { return MConf.get().herochatFactionName; }
|
||||
|
||||
@Override public String getNick() { return ConfServer.herochatFactionNick; }
|
||||
@Override public void setNick(String nick) { ConfServer.herochatFactionNick = nick; }
|
||||
@Override public String getNick() { return MConf.get().herochatFactionNick; }
|
||||
@Override public void setNick(String nick) { MConf.get().herochatFactionNick = nick; }
|
||||
|
||||
@Override public String getFormat() { return ConfServer.herochatFactionFormat; }
|
||||
@Override public void setFormat(String format) { ConfServer.herochatFactionFormat = format; }
|
||||
@Override public String getFormat() { return MConf.get().herochatFactionFormat; }
|
||||
@Override public void setFormat(String format) { MConf.get().herochatFactionFormat = format; }
|
||||
|
||||
@Override public ChatColor getColor() { return ConfServer.herochatFactionColor; }
|
||||
@Override public void setColor(ChatColor color) { ConfServer.herochatFactionColor = color; }
|
||||
@Override public ChatColor getColor() { return MConf.get().herochatFactionColor; }
|
||||
@Override public void setColor(ChatColor color) { MConf.get().herochatFactionColor = color; }
|
||||
|
||||
@Override public int getDistance() { return ConfServer.herochatFactionDistance; }
|
||||
@Override public void setDistance(int distance) { ConfServer.herochatFactionDistance = distance; }
|
||||
@Override public int getDistance() { return MConf.get().herochatFactionDistance; }
|
||||
@Override public void setDistance(int distance) { MConf.get().herochatFactionDistance = distance; }
|
||||
|
||||
@Override public void addWorld(String world) { ConfServer.herochatFactionWorlds.add(world); }
|
||||
@Override public Set<String> getWorlds() { return new HashSet<String>(ConfServer.herochatFactionWorlds); }
|
||||
@Override public void setWorlds(Set<String> worlds) { ConfServer.herochatFactionWorlds = worlds; }
|
||||
@Override public void addWorld(String world) { MConf.get().herochatFactionWorlds.add(world); }
|
||||
@Override public Set<String> getWorlds() { return new HashSet<String>(MConf.get().herochatFactionWorlds); }
|
||||
@Override public void setWorlds(Set<String> worlds) { MConf.get().herochatFactionWorlds = worlds; }
|
||||
|
||||
@Override public boolean isShortcutAllowed() { return ConfServer.herochatFactionIsShortcutAllowed; }
|
||||
@Override public void setShortcutAllowed(boolean shortcutAllowed) { ConfServer.herochatFactionIsShortcutAllowed = shortcutAllowed; }
|
||||
@Override public boolean isShortcutAllowed() { return MConf.get().herochatFactionIsShortcutAllowed; }
|
||||
@Override public void setShortcutAllowed(boolean shortcutAllowed) { MConf.get().herochatFactionIsShortcutAllowed = shortcutAllowed; }
|
||||
|
||||
@Override public boolean isCrossWorld() { return ConfServer.herochatFactionCrossWorld; }
|
||||
@Override public void setCrossWorld(boolean crossWorld) { ConfServer.herochatFactionCrossWorld = crossWorld; }
|
||||
@Override public boolean isCrossWorld() { return MConf.get().herochatFactionCrossWorld; }
|
||||
@Override public void setCrossWorld(boolean crossWorld) { MConf.get().herochatFactionCrossWorld = crossWorld; }
|
||||
|
||||
@Override public boolean isMuted() { return ConfServer.herochatFactionMuted; }
|
||||
@Override public void setMuted(boolean value) { ConfServer.herochatFactionMuted = value; }
|
||||
@Override public boolean isMuted() { return MConf.get().herochatFactionMuted; }
|
||||
@Override public void setMuted(boolean value) { MConf.get().herochatFactionMuted = value; }
|
||||
}
|
||||
|
@ -8,9 +8,9 @@ import org.bukkit.event.Listener;
|
||||
|
||||
import com.dthielke.herochat.ChannelChatEvent;
|
||||
import com.dthielke.herochat.Herochat;
|
||||
import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.chat.ChatFormatter;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
|
||||
|
||||
public class HerochatEngine implements Listener
|
||||
@ -48,7 +48,7 @@ public class HerochatEngine implements Listener
|
||||
public void onChannelChatEvent(ChannelChatEvent event)
|
||||
{
|
||||
// Should we even parse?
|
||||
if ( ! ConfServer.chatParseTags) return;
|
||||
if ( ! MConf.get().chatParseTags) return;
|
||||
|
||||
String format = event.getFormat();
|
||||
format = format.replaceAll("&r", "§r");
|
||||
|
@ -6,9 +6,9 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.chat.ChatFormatter;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.mcore.util.SenderUtil;
|
||||
|
||||
public class FactionsListenerChat implements Listener
|
||||
@ -36,13 +36,13 @@ public class FactionsListenerChat implements Listener
|
||||
public static void setFormat(AsyncPlayerChatEvent event, EventPriority currentPriority)
|
||||
{
|
||||
// If we are setting the chat format ...
|
||||
if (!ConfServer.chatSetFormat) return;
|
||||
if (!MConf.get().chatSetFormat) return;
|
||||
|
||||
// ... and this is the right priority ...
|
||||
if (currentPriority != ConfServer.chatSetFormatAt) return;
|
||||
if (currentPriority != MConf.get().chatSetFormatAt) return;
|
||||
|
||||
// ... then set the format.
|
||||
event.setFormat(ConfServer.chatSetFormatTo);
|
||||
event.setFormat(MConf.get().chatSetFormatTo);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
@ -88,10 +88,10 @@ public class FactionsListenerChat implements Listener
|
||||
public static void parseTags(AsyncPlayerChatEvent event, EventPriority currentPriority)
|
||||
{
|
||||
// If we are setting the chat format ...
|
||||
if (!ConfServer.chatParseTags) return;
|
||||
if (!MConf.get().chatParseTags) return;
|
||||
|
||||
// ... and this is the right priority ...
|
||||
if (currentPriority != ConfServer.chatParseTagsAt) return;
|
||||
if (currentPriority != MConf.get().chatParseTagsAt) return;
|
||||
|
||||
// ... then parse tags a.k.a. "format the format".
|
||||
String format = event.getFormat();
|
||||
|
Loading…
Reference in New Issue
Block a user