Remove HeroChat integration

This commit is contained in:
Magnus Ulf 2018-12-18 15:52:14 +01:00
parent 6bf9d29bed
commit 129fb6e63f
6 changed files with 0 additions and 548 deletions

12
pom.xml
View File

@ -19,13 +19,6 @@
<description>${massiveColorInfo}${project.name} allows the players to team up and claim land as their own and start wars with other factions. This way we hope to inspire politics, intrigue, and team spirit. ${massiveDescriptionSuffix}</description> <description>${massiveColorInfo}${project.name} allows the players to team up and claim land as their own and start wars with other factions. This way we hope to inspire politics, intrigue, and team spirit. ${massiveDescriptionSuffix}</description>
<url>${massiveBaseUrl}/factions</url> <url>${massiveBaseUrl}/factions</url>
<repositories>
<repository>
<id>sk89q-repo</id>
<url>http://maven.sk89q.com/repo/</url>
</repository>
</repositories>
<!-- Dependencies --> <!-- Dependencies -->
<dependencies> <dependencies>
<!-- Spigot --> <!-- Spigot -->
@ -53,11 +46,6 @@
<groupId>net.milkbowl.vault</groupId> <groupId>net.milkbowl.vault</groupId>
<artifactId>Vault</artifactId> <artifactId>Vault</artifactId>
</dependency> </dependency>
<!-- Herochat -->
<dependency>
<groupId>com.dthielke.herochat</groupId>
<artifactId>Herochat</artifactId>
</dependency>
<!-- LWC --> <!-- LWC -->
<dependency> <dependency>
<groupId>com.griefcraft</groupId> <groupId>com.griefcraft</groupId>

View File

@ -1,371 +0,0 @@
package com.massivecraft.factions.integration.herochat;
import com.dthielke.herochat.Channel;
import com.dthielke.herochat.ChannelChatEvent;
import com.dthielke.herochat.ChannelStorage;
import com.dthielke.herochat.ChatCompleteEvent;
import com.dthielke.herochat.Chatter;
import com.dthielke.herochat.Herochat;
import com.dthielke.herochat.MessageFormatSupplier;
import com.dthielke.herochat.MessageNotFoundException;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.massivecore.mixin.MixinMessage;
import com.massivecraft.massivecore.util.MUtil;
import net.milkbowl.vault.chat.Chat;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.entity.Player;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public abstract class ChannelFactionsAbstract implements Channel
{
private static final Pattern msgPattern = Pattern.compile("(.*)<(.*)%1\\$s(.*)> %2\\$s");
private final ChannelStorage storage = Herochat.getChannelManager().getStorage();
private final MessageFormatSupplier formatSupplier = Herochat.getChannelManager();
@Override
public boolean addMember(Chatter chatter, boolean announce, boolean flagUpdate)
{
if (chatter.hasChannel(this)) return false;
if ((announce) && (this.isVerbose()))
{
try
{
this.announce(Herochat.getMessage("channel_join").replace("$1", chatter.getPlayer().getDisplayName()));
}
catch (MessageNotFoundException e)
{
Herochat.severe("Messages.properties is missing: channel_join");
}
}
chatter.addChannel(this, announce, flagUpdate);
return true;
}
@Override
public boolean kickMember(Chatter chatter, boolean announce)
{
if (!chatter.hasChannel(this)) return false;
this.removeMember(chatter, false, true);
if (announce)
{
try
{
announce(Herochat.getMessage("channel_kick").replace("$1", chatter.getPlayer().getDisplayName()));
}
catch (MessageNotFoundException e)
{
Herochat.severe("Messages.properties is missing: channel_kick");
}
}
return true;
}
@Override
public boolean removeMember(Chatter chatter, boolean announce, boolean flagUpdate)
{
if (!chatter.hasChannel(this)) return false;
chatter.removeChannel(this, announce, flagUpdate);
if (announce && this.isVerbose())
{
try
{
this.announce(Herochat.getMessage("channel_leave").replace("$1", chatter.getPlayer().getDisplayName()));
}
catch (MessageNotFoundException e)
{
Herochat.severe("Messages.properties is missing: channel_leave");
}
}
return true;
}
@Override
public Set<Chatter> getMembers()
{
Set<Chatter> ret = new HashSet<>();
for (Chatter chatter : Herochat.getChatterManager().getChatters())
{
if(chatter.hasChannel(this)) ret.add(chatter);
}
return ret;
}
@Override
public void announce(String message)
{
String colorized = message.replaceAll("(?i)&([a-fklmno0-9])", "§$1");
message = applyFormat(this.getFormatSupplier().getAnnounceFormat(), "").replace("%2$s", colorized);
for (Chatter member : this.getMembers())
{
Player player = member.getPlayer();
MixinMessage.get().messageOne(player, message);
}
Herochat.logChat(ChatColor.stripColor(message));
}
@Override
public String applyFormat(String format, String originalFormat)
{
format = format.replace("{default}", this.getFormatSupplier().getStandardFormat());
format = format.replace("{name}", this.getName());
format = format.replace("{nick}", this.getNick());
format = format.replace("{color}", this.getColor().toString());
format = format.replace("{msg}", "%2$s");
Matcher matcher = msgPattern.matcher(originalFormat);
if (matcher.matches() && matcher.groupCount() == 3)
{
format = format.replace("{sender}", matcher.group(1) + matcher.group(2) + "%1$s" + matcher.group(3));
}
else
{
format = format.replace("{sender}", "%1$s");
}
format = format.replaceAll("(?i)&([a-fklmnor0-9])", "§$1");
return format;
}
@Override
public String applyFormat(String format, String originalFormat, Player sender)
{
format = this.applyFormat(format, originalFormat);
format = format.replace("{plainsender}", sender.getName());
format = format.replace("{world}", sender.getWorld().getName());
Chat chat = Herochat.getChatService();
if (chat != null)
{
try
{
String prefix = chat.getPlayerPrefix(sender);
if (prefix == null || prefix == "")
{
prefix = chat.getPlayerPrefix((String)null, sender.getName());
}
String suffix = chat.getPlayerSuffix(sender);
if (suffix == null || suffix == "")
{
suffix = chat.getPlayerSuffix((String)null, sender.getName());
}
String group = chat.getPrimaryGroup(sender);
String groupPrefix = group == null ? "" : chat.getGroupPrefix(sender.getWorld(), group);
if (group != null && (groupPrefix == null || groupPrefix == ""))
{
groupPrefix = chat.getGroupPrefix((String)null, group);
}
String groupSuffix = group == null ? "" : chat.getGroupSuffix(sender.getWorld(), group);
if (group != null && (groupSuffix == null || groupSuffix == ""))
{
groupSuffix = chat.getGroupSuffix((String)null, group);
}
format = format.replace("{prefix}", prefix == null ? "" : prefix.replace("%", "%%"));
format = format.replace("{suffix}", suffix == null ? "" : suffix.replace("%", "%%"));
format = format.replace("{group}", group == null ? "" : group.replace("%", "%%"));
format = format.replace("{groupprefix}", groupPrefix == null ? "" : groupPrefix.replace("%", "%%"));
format = format.replace("{groupsuffix}", groupSuffix == null ? "" : groupSuffix.replace("%", "%%"));
}
catch (UnsupportedOperationException ignored)
{
}
}
else
{
format = format.replace("{prefix}", "");
format = format.replace("{suffix}", "");
format = format.replace("{group}", "");
format = format.replace("{groupprefix}", "");
format = format.replace("{groupsuffix}", "");
}
format = format.replaceAll("(?i)&([a-fklmno0-9])", "§$1");
return format;
}
@Override
public void emote(Chatter sender, String message)
{
message = this.applyFormat(this.getFormatSupplier().getEmoteFormat(), "").replace("%2$s", message);
Set<Player> recipients = new HashSet<>();
for (Chatter member : this.getMembers())
{
recipients.add(member.getPlayer());
}
this.trimRecipients(recipients, sender);
for (Player recipient : recipients)
{
MixinMessage.get().messageOne(recipient, message);
}
}
@Override
public boolean isMuted(String name)
{
if (this.isMuted()) return true;
return this.getMutes().contains(name.toLowerCase());
}
public abstract Set<Rel> getTargetRelations();
public Set<Player> getRecipients(Player sender)
{
Set<Player> ret = new HashSet<>();
MPlayer fsender = MPlayer.get(sender);
Faction faction = fsender.getFaction();
for (Player player : MUtil.getOnlinePlayers())
{
MPlayer frecipient = MPlayer.get(player);
if (!this.getTargetRelations().contains(faction.getRelationTo(frecipient))) continue;
ret.add(player);
}
return ret;
}
@Override
public void processChat(ChannelChatEvent event)
{
Player player = event.getSender().getPlayer();
String format = this.applyFormat(event.getFormat(), event.getBukkitFormat(), player);
Chatter sender = Herochat.getChatterManager().getChatter(player);
// NOTE: This line is not standard deobfuscation. It's altered to achieve the recipient limitations.
Set<Player> recipients = this.getRecipients(player);
this.trimRecipients(recipients, sender);
String msg = String.format(format, new Object[] { player.getDisplayName(), event.getMessage() });
for (Player recipient : recipients)
{
MixinMessage.get().messageOne(recipient, msg);
}
Bukkit.getPluginManager().callEvent(new ChatCompleteEvent(sender, this, msg));
Herochat.logChat(msg);
}
public boolean isMessageHeard(Set<Player> recipients, Chatter sender)
{
if (!isLocal()) return true;
Player senderPlayer = sender.getPlayer();
for (Player recipient : recipients)
{
if (recipient.equals(senderPlayer)) continue;
if (recipient.hasPermission("herochat.admin.stealth")) continue;
return true;
}
return false;
}
public void trimRecipients(Set<Player> recipients, Chatter sender)
{
World world = sender.getPlayer().getWorld();
Set<Chatter> members = this.getMembers();
Iterator<Player> iterator = recipients.iterator();
while(iterator.hasNext())
{
Chatter recipient = Herochat.getChatterManager().getChatter(iterator.next());
if (recipient == null) continue;
World recipientWorld = recipient.getPlayer().getWorld();
if (!members.contains(recipient))
iterator.remove();
else if ((isLocal()) && (!sender.isInRange(recipient, this.getDistance())))
iterator.remove();
else if (!hasWorld(recipientWorld))
iterator.remove();
else if (recipient.isIgnoring(sender))
iterator.remove();
else if ((!this.isCrossWorld()) && (!world.equals(recipientWorld)))
iterator.remove();
}
}
public boolean equals(Object other)
{
if (other == this) return true;
if (other == null) return false;
if (!(other instanceof Channel)) return false;
Channel channel = (Channel)other;
return (this.getName().equalsIgnoreCase(channel.getName())) || (this.getName().equalsIgnoreCase(channel.getNick()));
}
public int hashCode()
{
int prime = 31;
int result = 1;
result = prime * result + (this.getName() == null ? 0 : this.getName().toLowerCase().hashCode());
result = prime * result + (this.getNick() == null ? 0 : this.getNick().toLowerCase().hashCode());
return result;
}
@Override public boolean isTransient() { return false; }
@Override public String getPassword() { return ""; }
@Override public void setPassword(String password) {}
@Override public boolean isVerbose() { return false; }
@Override public void setVerbose(boolean verbose) {}
@Override public boolean isHidden() { return false; }
@Override public boolean isLocal() { return this.getDistance() != 0; }
@Override public void attachStorage(ChannelStorage storage) { }
@Override public boolean banMember(Chatter chatter, boolean announce) { return false; }
@Override public Set<String> getBans() { return Collections.emptySet(); }
@Override public Set<String> getModerators() { return Collections.emptySet(); }
@Override public Set<String> getMutes() { return Collections.emptySet(); }
@Override public ChannelStorage getStorage() { return this.storage; }
@Override public boolean hasWorld(String world) { return (this.getWorlds().isEmpty()) || (this.getWorlds().contains(world)); }
@Override public boolean hasWorld(World world) { return this.hasWorld(world.getName()); }
@Override public boolean isBanned(String name) { return this.getBans().contains(name.toLowerCase()); }
@Override public boolean isMember(Chatter chatter) { return this.getMembers().contains(chatter); }
@Override public boolean isModerator(String name) { return this.getModerators().contains(name.toLowerCase()); }
@Override public void onFocusGain(Chatter chatter) {}
@Override public void onFocusLoss(Chatter chatter) {}
@Override public void removeWorld(String world) { this.getWorlds().remove(world); }
@Override public void setBanned(String name, boolean banned) {}
@Override public void setBans(Set<String> bans) {}
@Override public void setModerator(String name, boolean moderator) {}
@Override public void setModerators(Set<String> moderators) { }
@Override public void setMuted(String name, boolean muted) {}
@Override public void setMutes(Set<String> mutes) {}
@Override
public MessageFormatSupplier getFormatSupplier()
{
return this.formatSupplier;
}
@Override
public void sendRawMessage(String rawMessage)
{
for (Chatter member : this.getMembers())
{
Player player = member.getPlayer();
MixinMessage.get().messageOne(player, rawMessage);
}
}
}

View File

@ -1,41 +0,0 @@
package com.massivecraft.factions.integration.herochat;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.entity.MConf;
import org.bukkit.ChatColor;
import java.util.EnumSet;
import java.util.Set;
public class ChannelFactionsAllies extends ChannelFactionsAbstract
{
public static final Set<Rel> targetRelations = EnumSet.of(Rel.MEMBER, Rel.RECRUIT, Rel.ALLY);
@Override public Set<Rel> getTargetRelations() { return targetRelations; }
@Override public String getName() { return MConf.get().herochatAlliesName; }
@Override public String getNick() { return MConf.get().herochatAlliesNick; }
@Override public void setNick(String nick) { MConf.get().herochatAlliesNick = nick; }
@Override public String getFormat() { return MConf.get().herochatAlliesFormat; }
@Override public void setFormat(String format) { MConf.get().herochatAlliesFormat = format; }
@Override public ChatColor getColor() { return MConf.get().herochatAlliesColor; }
@Override public void setColor(ChatColor color) { MConf.get().herochatAlliesColor = color; }
@Override public int getDistance() { return MConf.get().herochatAlliesDistance; }
@Override public void setDistance(int distance) { MConf.get().herochatAlliesDistance = distance; }
@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 MConf.get().herochatAlliesIsShortcutAllowed; }
@Override public void setShortcutAllowed(boolean shortcutAllowed) { MConf.get().herochatAlliesIsShortcutAllowed = shortcutAllowed; }
@Override public boolean isCrossWorld() { return MConf.get().herochatAlliesCrossWorld; }
@Override public void setCrossWorld(boolean crossWorld) { MConf.get().herochatAlliesCrossWorld = crossWorld; }
@Override public boolean isMuted() { return MConf.get().herochatAlliesMuted; }
@Override public void setMuted(boolean value) { MConf.get().herochatAlliesMuted = value; }
}

View File

@ -1,42 +0,0 @@
package com.massivecraft.factions.integration.herochat;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.entity.MConf;
import org.bukkit.ChatColor;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
public class ChannelFactionsFaction extends ChannelFactionsAbstract
{
public static final Set<Rel> targetRelations = EnumSet.of(Rel.MEMBER, Rel.RECRUIT);
@Override public Set<Rel> getTargetRelations() { return targetRelations; }
@Override public String getName() { return MConf.get().herochatFactionName; }
@Override public String getNick() { return MConf.get().herochatFactionNick; }
@Override public void setNick(String nick) { MConf.get().herochatFactionNick = nick; }
@Override public String getFormat() { return MConf.get().herochatFactionFormat; }
@Override public void setFormat(String format) { MConf.get().herochatFactionFormat = format; }
@Override public ChatColor getColor() { return MConf.get().herochatFactionColor; }
@Override public void setColor(ChatColor color) { MConf.get().herochatFactionColor = color; }
@Override public int getDistance() { return MConf.get().herochatFactionDistance; }
@Override public void setDistance(int distance) { MConf.get().herochatFactionDistance = distance; }
@Override public void addWorld(String world) { MConf.get().herochatFactionWorlds.add(world); }
@Override public Set<String> getWorlds() { return new HashSet<>(MConf.get().herochatFactionWorlds); }
@Override public void setWorlds(Set<String> worlds) { MConf.get().herochatFactionWorlds = worlds; }
@Override public boolean isShortcutAllowed() { return MConf.get().herochatFactionIsShortcutAllowed; }
@Override public void setShortcutAllowed(boolean shortcutAllowed) { MConf.get().herochatFactionIsShortcutAllowed = shortcutAllowed; }
@Override public boolean isCrossWorld() { return MConf.get().herochatFactionCrossWorld; }
@Override public void setCrossWorld(boolean crossWorld) { MConf.get().herochatFactionCrossWorld = crossWorld; }
@Override public boolean isMuted() { return MConf.get().herochatFactionMuted; }
@Override public void setMuted(boolean value) { MConf.get().herochatFactionMuted = value; }
}

View File

@ -1,53 +0,0 @@
package com.massivecraft.factions.integration.herochat;
import com.dthielke.herochat.ChannelChatEvent;
import com.dthielke.herochat.Herochat;
import com.massivecraft.factions.chat.ChatFormatter;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.massivecore.Engine;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
public class EngineHerochat extends Engine
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static EngineHerochat i = new EngineHerochat();
public static EngineHerochat get() { return i; }
// -------------------------------------------- //
// ACTIVATE & DEACTIVATE
// -------------------------------------------- //
@Override
public void setActiveInner(boolean active)
{
if ( ! active) return;
Herochat.getChannelManager().addChannel(new ChannelFactionsFaction());
Herochat.getChannelManager().addChannel(new ChannelFactionsAllies());
}
// -------------------------------------------- //
// LISTENER
// -------------------------------------------- //
@EventHandler(priority = EventPriority.NORMAL)
public void onChannelChatEvent(ChannelChatEvent event)
{
// Should we even parse?
if ( ! MConf.get().chatParseTags) return;
String format = event.getFormat();
// We trigger a replace of HeroChats tag {default} here
// This way we can replace faction tags hidden withing {default} as well.
format = format.replace("{default}", event.getChannel().getFormatSupplier().getStandardFormat());
format = ChatFormatter.format(format, event.getSender().getPlayer(), null);
event.setFormat(format);
}
}

View File

@ -1,29 +0,0 @@
package com.massivecraft.factions.integration.herochat;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.Integration;
public class IntegrationHerochat extends Integration
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static IntegrationHerochat i = new IntegrationHerochat();
public static IntegrationHerochat get() { return i; }
private IntegrationHerochat()
{
this.setPluginName("Herochat");
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Engine getEngine()
{
return EngineHerochat.get();
}
}