Revert "Remove Fanciful, fix compilation (part 1/2)"
This reverts commit fc1d08e507
.
We have users on builds before this was included in Spigot. We don't want to break those servers.
This commit is contained in:
parent
1481d604d4
commit
de57060819
14
pom.xml
14
pom.xml
@ -44,10 +44,15 @@
|
|||||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||||
<artifactSet>
|
<artifactSet>
|
||||||
<includes>
|
<includes>
|
||||||
|
<include>mkremins:fanciful</include>
|
||||||
<include>com.google.code.gson:gson</include>
|
<include>com.google.code.gson:gson</include>
|
||||||
</includes>
|
</includes>
|
||||||
</artifactSet>
|
</artifactSet>
|
||||||
<relocations>
|
<relocations>
|
||||||
|
<relocation>
|
||||||
|
<pattern>mkremins.fanciful</pattern>
|
||||||
|
<shadedPattern>com.massivecraft.factions.shade.mkremins.fanciful</shadedPattern>
|
||||||
|
</relocation>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>com.google.gson</pattern>
|
<pattern>com.google.gson</pattern>
|
||||||
<shadedPattern>com.massivecraft.factions.shade.com.google.gson</shadedPattern>
|
<shadedPattern>com.massivecraft.factions.shade.com.google.gson</shadedPattern>
|
||||||
@ -98,6 +103,11 @@
|
|||||||
<artifactId>EssentialsXChat</artifactId>
|
<artifactId>EssentialsXChat</artifactId>
|
||||||
<version>2.0.1-SNAPSHOT</version>
|
<version>2.0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>mkremins</groupId>
|
||||||
|
<artifactId>fanciful</artifactId>
|
||||||
|
<version>0.3.2-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.dynmap</groupId>
|
<groupId>org.dynmap</groupId>
|
||||||
<artifactId>dynmap</artifactId>
|
<artifactId>dynmap</artifactId>
|
||||||
@ -138,5 +148,9 @@
|
|||||||
<id>repo.mikeprimm.com</id>
|
<id>repo.mikeprimm.com</id>
|
||||||
<url>http://repo.mikeprimm.com/</url>
|
<url>http://repo.mikeprimm.com/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>franga2000-repo</id>
|
||||||
|
<url>http://repo.franga2000.com/artifactory/public</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
</project>
|
</project>
|
||||||
|
@ -5,10 +5,8 @@ import com.massivecraft.factions.FPlayer;
|
|||||||
import com.massivecraft.factions.FPlayers;
|
import com.massivecraft.factions.FPlayers;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import mkremins.fanciful.FancyMessage;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import org.bukkit.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
|
|
||||||
public class CmdDeinvite extends FCommand {
|
public class CmdDeinvite extends FCommand {
|
||||||
|
|
||||||
@ -33,18 +31,13 @@ public class CmdDeinvite extends FCommand {
|
|||||||
public void perform() {
|
public void perform() {
|
||||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
FPlayer you = this.argAsBestFPlayerMatch(0);
|
||||||
if (you == null) {
|
if (you == null) {
|
||||||
TextComponent component = new TextComponent(TL.COMMAND_DEINVITE_CANDEINVITE.toString());
|
FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD);
|
||||||
component.setColor(net.md_5.bungee.api.ChatColor.GOLD);
|
|
||||||
for (String id : myFaction.getInvites()) {
|
for (String id : myFaction.getInvites()) {
|
||||||
FPlayer fp = FPlayers.getInstance().getById(id);
|
FPlayer fp = FPlayers.getInstance().getById(id);
|
||||||
String name = fp != null ? fp.getName() : id;
|
String name = fp != null ? fp.getName() : id;
|
||||||
TextComponent then = new TextComponent(name + " ");
|
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command(Conf.baseCommandAliases.get(0) + " deinvite " + name);
|
||||||
then.setColor(net.md_5.bungee.api.ChatColor.WHITE);
|
|
||||||
then.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new BaseComponent[]{new TextComponent(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name))}));
|
|
||||||
then.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, Conf.baseCommandAliases.get(0) + " deinvite " + name));
|
|
||||||
component.addExtra(then);
|
|
||||||
}
|
}
|
||||||
fme.getPlayer().spigot().sendMessage(component);
|
sendFancyMessage(msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,12 +5,9 @@ import com.massivecraft.factions.FPlayer;
|
|||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.util.LazyLocation;
|
import com.massivecraft.factions.util.LazyLocation;
|
||||||
import com.massivecraft.factions.util.WarmUpUtil;
|
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import mkremins.fanciful.FancyMessage;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import org.bukkit.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -31,17 +28,12 @@ public class CmdFWarp extends FCommand {
|
|||||||
public void perform() {
|
public void perform() {
|
||||||
//TODO: check if in combat.
|
//TODO: check if in combat.
|
||||||
if (args.size() == 0) {
|
if (args.size() == 0) {
|
||||||
TextComponent component = new TextComponent(TL.COMMAND_FWARP_WARPS.toString());
|
FancyMessage msg = new FancyMessage(TL.COMMAND_FWARP_WARPS.toString()).color(ChatColor.GOLD);
|
||||||
component.setColor(net.md_5.bungee.api.ChatColor.GOLD);
|
|
||||||
Map<String, LazyLocation> warps = myFaction.getWarps();
|
Map<String, LazyLocation> warps = myFaction.getWarps();
|
||||||
for (String s : warps.keySet()) {
|
for (String s : warps.keySet()) {
|
||||||
TextComponent then = new TextComponent(s + " ");
|
msg.then(s + " ").tooltip(TL.COMMAND_FWARP_CLICKTOWARP.toString()).command(Conf.baseCommandAliases.get(0) + " warp " + s).color(ChatColor.WHITE);
|
||||||
then.setColor(net.md_5.bungee.api.ChatColor.WHITE);
|
|
||||||
then.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new BaseComponent[]{new TextComponent(TL.COMMAND_FWARP_CLICKTOWARP.toString())}));
|
|
||||||
then.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, Conf.baseCommandAliases.get(0) + " warp " + s));
|
|
||||||
component.addExtra(then);
|
|
||||||
}
|
}
|
||||||
fme.getPlayer().spigot().sendMessage(component);
|
sendFancyMessage(msg);
|
||||||
} else if (args.size() > 1) {
|
} else if (args.size() > 1) {
|
||||||
fme.msg(TL.COMMAND_FWARP_COMMANDFORMAT);
|
fme.msg(TL.COMMAND_FWARP_COMMANDFORMAT);
|
||||||
} else {
|
} else {
|
||||||
|
@ -4,7 +4,8 @@ import com.massivecraft.factions.Conf;
|
|||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import net.md_5.bungee.api.chat.*;
|
import mkremins.fanciful.FancyMessage;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
public class CmdInvite extends FCommand {
|
public class CmdInvite extends FCommand {
|
||||||
|
|
||||||
@ -49,13 +50,9 @@ public class CmdInvite extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Tooltips, colors, and commands only apply to the string immediately before it.
|
// Tooltips, colors, and commands only apply to the string immediately before it.
|
||||||
TextComponent component = new TextComponent(fme.describeTo(you, true));
|
FancyMessage message = new FancyMessage(fme.describeTo(you, true)).tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()).command(Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag()).then(TL.COMMAND_INVITE_INVITEDYOU.toString()).color(ChatColor.YELLOW).tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()).command(Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag()).then(myFaction.describeTo(you)).tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()).command(Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag());
|
||||||
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new BaseComponent[]{new TextComponent(TL.COMMAND_INVITE_CLICKTOJOIN.toString())}));
|
|
||||||
component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag()));
|
|
||||||
component.addExtra(new ComponentBuilder(TL.COMMAND_INVITE_INVITEDYOU.toString()).color(net.md_5.bungee.api.ChatColor.YELLOW).create()[0]);
|
|
||||||
component.addExtra(new ComponentBuilder(myFaction.describeTo(you)).color(net.md_5.bungee.api.ChatColor.YELLOW).create()[0]);
|
|
||||||
|
|
||||||
you.getPlayer().spigot().sendMessage(component);
|
message.send(you.getPlayer());
|
||||||
|
|
||||||
//you.msg("%s<i> invited you to %s", fme.describeTo(you, true), myFaction.describeTo(you));
|
//you.msg("%s<i> invited you to %s", fme.describeTo(you, true), myFaction.describeTo(you));
|
||||||
myFaction.msg(TL.COMMAND_INVITE_INVITED, fme.describeTo(myFaction, true), you.describeTo(myFaction));
|
myFaction.msg(TL.COMMAND_INVITE_INVITED, fme.describeTo(myFaction, true), you.describeTo(myFaction));
|
||||||
|
@ -8,11 +8,9 @@ import com.massivecraft.factions.event.FPlayerLeaveEvent;
|
|||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Role;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import mkremins.fanciful.FancyMessage;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
public class CmdKick extends FCommand {
|
public class CmdKick extends FCommand {
|
||||||
|
|
||||||
@ -36,28 +34,19 @@ public class CmdKick extends FCommand {
|
|||||||
public void perform() {
|
public void perform() {
|
||||||
FPlayer toKick = this.argIsSet(0) ? this.argAsBestFPlayerMatch(0) : null;
|
FPlayer toKick = this.argIsSet(0) ? this.argAsBestFPlayerMatch(0) : null;
|
||||||
if (toKick == null) {
|
if (toKick == null) {
|
||||||
TextComponent component = new TextComponent(TL.COMMAND_KICK_CANDIDATES.toString());
|
FancyMessage msg = new FancyMessage(TL.COMMAND_KICK_CANDIDATES.toString()).color(ChatColor.GOLD);
|
||||||
component.setColor(net.md_5.bungee.api.ChatColor.GOLD);
|
|
||||||
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.NORMAL)) {
|
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.NORMAL)) {
|
||||||
String s = player.getName();
|
String s = player.getName();
|
||||||
TextComponent then = new TextComponent(s + " ");
|
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command(Conf.baseCommandAliases.get(0) + " kick " + s);
|
||||||
then.setColor(net.md_5.bungee.api.ChatColor.WHITE);
|
|
||||||
then.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new BaseComponent[]{new TextComponent(TL.COMMAND_KICK_CLICKTOKICK.toString() + s)}));
|
|
||||||
then.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, Conf.baseCommandAliases.get(0) + " kick " + s));
|
|
||||||
component.addExtra(then);
|
|
||||||
}
|
}
|
||||||
if (fme.getRole() == Role.ADMIN) {
|
if (fme.getRole() == Role.ADMIN) {
|
||||||
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.MODERATOR)) {
|
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.MODERATOR)) {
|
||||||
String s = player.getName();
|
String s = player.getName();
|
||||||
TextComponent then = new TextComponent(s + " ");
|
msg.then(s + " ").color(ChatColor.GRAY).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command(Conf.baseCommandAliases.get(0) + " kick " + s);
|
||||||
then.setColor(net.md_5.bungee.api.ChatColor.GRAY);
|
|
||||||
then.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new BaseComponent[]{new TextComponent(TL.COMMAND_KICK_CLICKTOKICK.toString() + s)}));
|
|
||||||
then.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, Conf.baseCommandAliases.get(0) + " kick " + s));
|
|
||||||
component.addExtra(then);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fme.getPlayer().spigot().sendMessage(component);
|
sendFancyMessage(msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,10 +6,8 @@ import com.massivecraft.factions.Faction;
|
|||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Role;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import mkremins.fanciful.FancyMessage;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import org.bukkit.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
|
|
||||||
public class CmdMod extends FCommand {
|
public class CmdMod extends FCommand {
|
||||||
|
|
||||||
@ -33,18 +31,13 @@ public class CmdMod extends FCommand {
|
|||||||
public void perform() {
|
public void perform() {
|
||||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
FPlayer you = this.argAsBestFPlayerMatch(0);
|
||||||
if (you == null) {
|
if (you == null) {
|
||||||
TextComponent component = new TextComponent(TL.COMMAND_MOD_CANDIDATES.toString());
|
FancyMessage msg = new FancyMessage(TL.COMMAND_MOD_CANDIDATES.toString()).color(ChatColor.GOLD);
|
||||||
component.setColor(net.md_5.bungee.api.ChatColor.GOLD);
|
|
||||||
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.NORMAL)) {
|
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.NORMAL)) {
|
||||||
String s = player.getName();
|
String s = player.getName();
|
||||||
TextComponent then = new TextComponent(s + " ");
|
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command(Conf.baseCommandAliases.get(0) + " mod " + s);
|
||||||
then.setColor(net.md_5.bungee.api.ChatColor.WHITE);
|
|
||||||
then.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new BaseComponent[]{new TextComponent(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s)}));
|
|
||||||
then.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, Conf.baseCommandAliases.get(0) + " mod " + s));
|
|
||||||
component.addExtra(then);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fme.getPlayer().spigot().sendMessage(component);
|
sendFancyMessage(msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import com.massivecraft.factions.zcore.util.TagReplacer;
|
import com.massivecraft.factions.zcore.util.TagReplacer;
|
||||||
import com.massivecraft.factions.zcore.util.TagUtil;
|
import com.massivecraft.factions.zcore.util.TagUtil;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import mkremins.fanciful.FancyMessage;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -79,10 +79,10 @@ public class CmdShow extends FCommand {
|
|||||||
|
|
||||||
for (String raw : show) {
|
for (String raw : show) {
|
||||||
String parsed = TagUtil.parsePlain(faction, fme, raw); // use relations
|
String parsed = TagUtil.parsePlain(faction, fme, raw); // use relations
|
||||||
if (TagUtil.hasComponent(parsed)) {
|
if (TagUtil.hasFancy(parsed)) {
|
||||||
List<BaseComponent> components = TagUtil.parseComponent(faction, fme, parsed);
|
List<FancyMessage> fancy = TagUtil.parseFancy(faction, fme, parsed);
|
||||||
if (components != null) {
|
if (fancy != null) {
|
||||||
fme.getPlayer().spigot().sendMessage(components.toArray(new BaseComponent[components.size()]));
|
sendFancyMessage(fancy);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,8 @@ import com.massivecraft.factions.FPlayer;
|
|||||||
import com.massivecraft.factions.FPlayers;
|
import com.massivecraft.factions.FPlayers;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import mkremins.fanciful.FancyMessage;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import org.bukkit.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
|
|
||||||
public class CmdShowInvites extends FCommand {
|
public class CmdShowInvites extends FCommand {
|
||||||
|
|
||||||
@ -23,19 +21,14 @@ public class CmdShowInvites extends FCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
TextComponent component = new TextComponent(TL.COMMAND_SHOWINVITES_PENDING.toString());
|
FancyMessage msg = new FancyMessage(TL.COMMAND_SHOWINVITES_PENDING.toString()).color(ChatColor.GOLD);
|
||||||
component.setColor(net.md_5.bungee.api.ChatColor.GOLD);
|
|
||||||
for (String id : myFaction.getInvites()) {
|
for (String id : myFaction.getInvites()) {
|
||||||
FPlayer fp = FPlayers.getInstance().getById(id);
|
FPlayer fp = FPlayers.getInstance().getById(id);
|
||||||
String name = fp != null ? fp.getName() : id;
|
String name = fp != null ? fp.getName() : id;
|
||||||
TextComponent then = new TextComponent(name + " ");
|
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_SHOWINVITES_CLICKTOREVOKE.format(name)).command(Conf.baseCommandAliases.get(0) + " deinvite " + name);
|
||||||
then.setColor(net.md_5.bungee.api.ChatColor.WHITE);
|
|
||||||
then.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new BaseComponent[]{new TextComponent(TL.COMMAND_SHOWINVITES_CLICKTOREVOKE.format(name))}));
|
|
||||||
then.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, Conf.baseCommandAliases.get(0) + " deinvite " + name));
|
|
||||||
component.addExtra(then);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fme.getPlayer().spigot().sendMessage(component);
|
sendFancyMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -6,6 +6,7 @@ import com.massivecraft.factions.P;
|
|||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||||
|
import mkremins.fanciful.FancyMessage;
|
||||||
import org.apache.commons.lang.time.DurationFormatUtils;
|
import org.apache.commons.lang.time.DurationFormatUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -268,6 +269,16 @@ public abstract class MCommand<T extends MPlugin> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendFancyMessage(FancyMessage message) {
|
||||||
|
message.send(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendFancyMessage(List<FancyMessage> messages) {
|
||||||
|
for (FancyMessage m : messages) {
|
||||||
|
sendFancyMessage(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<String> getToolTips(FPlayer player) {
|
public List<String> getToolTips(FPlayer player) {
|
||||||
List<String> lines = new ArrayList<String>();
|
List<String> lines = new ArrayList<String>();
|
||||||
for (String s : p.getConfig().getStringList("tooltips.show")) {
|
for (String s : p.getConfig().getStringList("tooltips.show")) {
|
||||||
|
@ -6,9 +6,7 @@ import com.massivecraft.factions.Faction;
|
|||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
import com.massivecraft.factions.util.MiscUtil;
|
import com.massivecraft.factions.util.MiscUtil;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import mkremins.fanciful.FancyMessage;
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -76,34 +74,33 @@ public class TagUtil {
|
|||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan a line and parse the component variable into a component list
|
* Scan a line and parse the fancy variable into a fancy list
|
||||||
*
|
*
|
||||||
* @param faction for faction (viewers faction)
|
* @param faction for faction (viewers faction)
|
||||||
* @param fme for player (viewer)
|
* @param fme for player (viewer)
|
||||||
* @param line component prefix
|
* @param line fancy message prefix
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static List<BaseComponent> parseComponent(Faction faction, FPlayer fme, String line) {
|
public static List<FancyMessage> parseFancy(Faction faction, FPlayer fme, String line) {
|
||||||
for (TagReplacer tagReplacer : TagReplacer.getByType(TagType.FANCY)) {
|
for (TagReplacer tagReplacer : TagReplacer.getByType(TagType.FANCY)) {
|
||||||
if (tagReplacer.contains(line)) {
|
if (tagReplacer.contains(line)) {
|
||||||
String clean = line.replace(tagReplacer.getTag(), ""); // remove tag
|
String clean = line.replace(tagReplacer.getTag(), ""); // remove tag
|
||||||
return getComponent(faction, fme, tagReplacer, clean);
|
return getFancy(faction, fme, tagReplacer, clean);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a line has component variables
|
* Checks if a line has fancy variables
|
||||||
*
|
*
|
||||||
* @param line raw line from config with variables
|
* @param line raw line from config with variables
|
||||||
*
|
*
|
||||||
* @return if the line has fancy variables
|
* @return if the line has fancy variables
|
||||||
*/
|
*/
|
||||||
public static boolean hasComponent(String line) {
|
public static boolean hasFancy(String line) {
|
||||||
for (TagReplacer tagReplacer : TagReplacer.getByType(TagType.FANCY)) {
|
for (TagReplacer tagReplacer : TagReplacer.getByType(TagType.FANCY)) {
|
||||||
if (tagReplacer.contains(line)) {
|
if (tagReplacer.contains(line)) {
|
||||||
return true;
|
return true;
|
||||||
@ -112,9 +109,8 @@ public class TagUtil {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lets get components?
|
* Lets get fancy.
|
||||||
*
|
*
|
||||||
* @param target Faction to get relate from
|
* @param target Faction to get relate from
|
||||||
* @param fme Player to relate to
|
* @param fme Player to relate to
|
||||||
@ -122,11 +118,11 @@ public class TagUtil {
|
|||||||
*
|
*
|
||||||
* @return list of fancy messages to send
|
* @return list of fancy messages to send
|
||||||
*/
|
*/
|
||||||
protected static List<BaseComponent> getComponent(Faction target, FPlayer fme, TagReplacer type, String prefix) {
|
protected static List<FancyMessage> getFancy(Faction target, FPlayer fme, TagReplacer type, String prefix) {
|
||||||
List<BaseComponent> components = new ArrayList<BaseComponent>();
|
List<FancyMessage> fancyMessages = new ArrayList<FancyMessage>();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ALLIES_LIST:
|
case ALLIES_LIST:
|
||||||
BaseComponent currentAllies = P.p.txt.parseComponent(prefix);
|
FancyMessage currentAllies = P.p.txt.parseFancy(prefix);
|
||||||
boolean firstAlly = true;
|
boolean firstAlly = true;
|
||||||
for (Faction otherFaction : Factions.getInstance().getAllFactions()) {
|
for (Faction otherFaction : Factions.getInstance().getAllFactions()) {
|
||||||
if (otherFaction == target) {
|
if (otherFaction == target) {
|
||||||
@ -134,27 +130,19 @@ public class TagUtil {
|
|||||||
}
|
}
|
||||||
String s = otherFaction.getTag(fme);
|
String s = otherFaction.getTag(fme);
|
||||||
if (otherFaction.getRelationTo(target).isAlly()) {
|
if (otherFaction.getRelationTo(target).isAlly()) {
|
||||||
TextComponent then = new TextComponent(firstAlly ? s : ", " + s);
|
currentAllies.then(firstAlly ? s : ", " + s);
|
||||||
List<String> list = tipFaction(otherFaction);
|
currentAllies.tooltip(tipFaction(otherFaction)).color(fme.getColorTo(otherFaction));
|
||||||
TextComponent[] hover = new TextComponent[list.size()];
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
TextComponent component = new TextComponent(list.get(i));
|
|
||||||
component.setColor(net.md_5.bungee.api.ChatColor.valueOf(fme.getColorTo(otherFaction).name()));
|
|
||||||
hover[i] = component;
|
|
||||||
}
|
|
||||||
then.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hover));
|
|
||||||
currentAllies.addExtra(then);
|
|
||||||
firstAlly = false;
|
firstAlly = false;
|
||||||
if (currentAllies.toPlainText().length() > ARBITRARY_LIMIT) {
|
if (currentAllies.toJSONString().length() > ARBITRARY_LIMIT) {
|
||||||
components.add(currentAllies);
|
fancyMessages.add(currentAllies);
|
||||||
currentAllies = new TextComponent("");
|
currentAllies = new FancyMessage("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
components.add(currentAllies);
|
fancyMessages.add(currentAllies);
|
||||||
return components; // we must return here and not outside the switch
|
return fancyMessages; // we must return here and not outside the switch
|
||||||
case ENEMIES_LIST:
|
case ENEMIES_LIST:
|
||||||
BaseComponent currentEnemies = P.p.txt.parseComponent(prefix);
|
FancyMessage currentEnemies = P.p.txt.parseFancy(prefix);
|
||||||
boolean firstEnemy = true;
|
boolean firstEnemy = true;
|
||||||
for (Faction otherFaction : Factions.getInstance().getAllFactions()) {
|
for (Faction otherFaction : Factions.getInstance().getAllFactions()) {
|
||||||
if (otherFaction == target) {
|
if (otherFaction == target) {
|
||||||
@ -162,73 +150,49 @@ public class TagUtil {
|
|||||||
}
|
}
|
||||||
String s = otherFaction.getTag(fme);
|
String s = otherFaction.getTag(fme);
|
||||||
if (otherFaction.getRelationTo(target).isEnemy()) {
|
if (otherFaction.getRelationTo(target).isEnemy()) {
|
||||||
TextComponent then = new TextComponent(firstEnemy ? s : ", " + s);
|
currentEnemies.then(firstEnemy ? s : ", " + s);
|
||||||
List<String> list = tipFaction(otherFaction);
|
currentEnemies.tooltip(tipFaction(otherFaction)).color(fme.getColorTo(otherFaction));
|
||||||
TextComponent[] hover = new TextComponent[list.size()];
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
TextComponent component = new TextComponent(list.get(i));
|
|
||||||
component.setColor(net.md_5.bungee.api.ChatColor.valueOf(fme.getColorTo(otherFaction).name()));
|
|
||||||
hover[i] = component;
|
|
||||||
}
|
|
||||||
then.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hover));
|
|
||||||
currentEnemies.addExtra(then);
|
|
||||||
firstEnemy = false;
|
firstEnemy = false;
|
||||||
if (currentEnemies.toPlainText().length() > ARBITRARY_LIMIT) {
|
if (currentEnemies.toJSONString().length() > ARBITRARY_LIMIT) {
|
||||||
components.add(currentEnemies);
|
fancyMessages.add(currentEnemies);
|
||||||
currentEnemies = new TextComponent("");
|
currentEnemies = new FancyMessage("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
components.add(currentEnemies);
|
fancyMessages.add(currentEnemies);
|
||||||
return components; // we must return here and not outside the switch
|
return fancyMessages; // we must return here and not outside the switch
|
||||||
case ONLINE_LIST:
|
case ONLINE_LIST:
|
||||||
BaseComponent currentOnline = P.p.txt.parseComponent(prefix);
|
FancyMessage currentOnline = P.p.txt.parseFancy(prefix);
|
||||||
boolean firstOnline = true;
|
boolean firstOnline = true;
|
||||||
for (FPlayer p : MiscUtil.rankOrder(target.getFPlayersWhereOnline(true))) {
|
for (FPlayer p : MiscUtil.rankOrder(target.getFPlayersWhereOnline(true))) {
|
||||||
String name = p.getNameAndTitle();
|
String name = p.getNameAndTitle();
|
||||||
TextComponent then = new TextComponent(firstOnline ? name : ", " + name);
|
currentOnline.then(firstOnline ? name : ", " + name);
|
||||||
List<String> list = tipPlayer(p);
|
currentOnline.tooltip(tipPlayer(p)).color(fme.getColorTo(p));
|
||||||
TextComponent[] hover = new TextComponent[list.size()];
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
TextComponent component = new TextComponent(list.get(i));
|
|
||||||
component.setColor(net.md_5.bungee.api.ChatColor.valueOf(fme.getColorTo(p).name()));
|
|
||||||
hover[i] = component;
|
|
||||||
}
|
|
||||||
then.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hover));
|
|
||||||
currentOnline.addExtra(then);
|
|
||||||
firstOnline = false;
|
firstOnline = false;
|
||||||
if (currentOnline.toPlainText().length() > ARBITRARY_LIMIT) {
|
if (currentOnline.toJSONString().length() > ARBITRARY_LIMIT) {
|
||||||
components.add(currentOnline);
|
fancyMessages.add(currentOnline);
|
||||||
currentOnline = new TextComponent("");
|
currentOnline = new FancyMessage("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
components.add(currentOnline);
|
fancyMessages.add(currentOnline);
|
||||||
return components; // we must return here and not outside the switch
|
return fancyMessages; // we must return here and not outside the switch
|
||||||
case OFFLINE_LIST:
|
case OFFLINE_LIST:
|
||||||
BaseComponent currentOffline = P.p.txt.parseComponent(prefix);
|
FancyMessage currentOffline = P.p.txt.parseFancy(prefix);
|
||||||
boolean firstOffline = true;
|
boolean firstOffline = true;
|
||||||
for (FPlayer p : MiscUtil.rankOrder(target.getFPlayers())) {
|
for (FPlayer p : MiscUtil.rankOrder(target.getFPlayers())) {
|
||||||
String name = p.getNameAndTitle();
|
String name = p.getNameAndTitle();
|
||||||
if (!p.isOnline()) {
|
if (!p.isOnline()) {
|
||||||
TextComponent then = new TextComponent(firstOffline ? name : ", " + name);
|
currentOffline.then(firstOffline ? name : ", " + name);
|
||||||
List<String> list = tipPlayer(p);
|
currentOffline.tooltip(tipPlayer(p)).color(fme.getColorTo(p));
|
||||||
TextComponent[] hover = new TextComponent[list.size()];
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
TextComponent component = new TextComponent(list.get(i));
|
|
||||||
component.setColor(net.md_5.bungee.api.ChatColor.valueOf(fme.getColorTo(p).name()));
|
|
||||||
hover[i] = component;
|
|
||||||
}
|
|
||||||
then.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hover));
|
|
||||||
currentOffline.addExtra(then);
|
|
||||||
firstOffline = false;
|
firstOffline = false;
|
||||||
if (currentOffline.toPlainText().length() > ARBITRARY_LIMIT) {
|
if (currentOffline.toJSONString().length() > ARBITRARY_LIMIT) {
|
||||||
components.add(currentOffline);
|
fancyMessages.add(currentOffline);
|
||||||
currentOffline = new TextComponent("");
|
currentOffline = new FancyMessage("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
components.add(currentOffline);
|
fancyMessages.add(currentOffline);
|
||||||
return components; // we must return here and not outside the switch
|
return fancyMessages; // we must return here and not outside the switch
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.massivecraft.factions.zcore.util;
|
package com.massivecraft.factions.zcore.util;
|
||||||
|
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import mkremins.fanciful.FancyMessage;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
@ -56,24 +55,41 @@ public class TextUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// Component parsing
|
// Fancy parsing
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public BaseComponent parseComponent(String prefix) {
|
public FancyMessage parseFancy(String prefix) {
|
||||||
return toComponent(parse(prefix));
|
return toFancy(parse(prefix));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BaseComponent toComponent(String first) {
|
public static FancyMessage toFancy(String first) {
|
||||||
BaseComponent[] components = TextComponent.fromLegacyText(first);
|
String text = "";
|
||||||
if (components.length == 0) {
|
FancyMessage message = new FancyMessage(text);
|
||||||
return null;
|
ChatColor color = null;
|
||||||
|
char[] chars = first.toCharArray();
|
||||||
|
|
||||||
|
for (int i = 0; i < chars.length; i++) {
|
||||||
|
if (chars[i] == '§') {
|
||||||
|
if (color != null) {
|
||||||
|
message.then(text).color(color);
|
||||||
|
text = "";
|
||||||
|
color = ChatColor.getByChar(chars[i + 1]);
|
||||||
|
} else {
|
||||||
|
color = ChatColor.getByChar(chars[i + 1]);
|
||||||
|
}
|
||||||
|
i++; // skip color char
|
||||||
|
} else {
|
||||||
|
text += chars[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// convert it to a single component, for ease
|
if (text.length() > 0) {
|
||||||
BaseComponent component = components[0];
|
if (color != null) {
|
||||||
for (int i = 1; i < components.length; i++) {
|
message.then(text).color(color);
|
||||||
component.addExtra(components[i]);
|
} else {
|
||||||
|
message.text(text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return component;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
Loading…
Reference in New Issue
Block a user