From 0d75b1164ab12570ffd4d1ff18a40f6f7d60afde Mon Sep 17 00:00:00 2001 From: Tibo442 Date: Fri, 19 Dec 2014 13:51:24 +0100 Subject: [PATCH] Changed FancyMessage.command() to accept command aliases. Also adds support for servers where slash-less commands are disabled. --- src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java | 3 ++- src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java | 3 ++- src/main/java/com/massivecraft/factions/cmd/CmdInvite.java | 2 +- src/main/java/com/massivecraft/factions/cmd/CmdKick.java | 4 ++-- src/main/java/com/massivecraft/factions/cmd/CmdMod.java | 3 ++- .../java/com/massivecraft/factions/cmd/CmdShowInvites.java | 3 ++- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java b/src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java index a49ea207..e29e6573 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java @@ -1,5 +1,6 @@ package com.massivecraft.factions.cmd; +import com.massivecraft.factions.Conf; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.struct.Permission; @@ -34,7 +35,7 @@ public class CmdDeinvite extends FCommand { for (String id : myFaction.getInvites()) { FPlayer fp = FPlayers.getInstance().getById(id); String name = fp != null ? fp.getName() : id; - msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command("f deinvite " + name); + msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command(Conf.baseCommandAliases.get(0) + " deinvite " + name); } sendFancyMessage(msg); return; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java b/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java index cc632ad1..b20996c3 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java @@ -1,5 +1,6 @@ package com.massivecraft.factions.cmd; +import com.massivecraft.factions.Conf; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.P; import com.massivecraft.factions.struct.Permission; @@ -30,7 +31,7 @@ public class CmdFWarp extends FCommand { FancyMessage msg = new FancyMessage(TL.COMMAND_FWARP_WARPS.toString()).color(ChatColor.GOLD); Map warps = myFaction.getWarps(); for (String s : warps.keySet()) { - msg.then(s + " ").tooltip(TL.COMMAND_FWARP_CLICKTOWARP.toString()).command("f warp " + s).color(ChatColor.WHITE); + msg.then(s + " ").tooltip(TL.COMMAND_FWARP_CLICKTOWARP.toString()).command(Conf.baseCommandAliases.get(0) + " warp " + s).color(ChatColor.WHITE); } sendFancyMessage(msg); } else if (args.size() > 1) { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java b/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java index 6936131a..1e5b15a9 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java @@ -50,7 +50,7 @@ public class CmdInvite extends FCommand { } // Tooltips, colors, and commands only apply to the string immediately before it. - FancyMessage message = new FancyMessage(fme.describeTo(you, true)).tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()).command("f join " + myFaction.getTag()).then(TL.COMMAND_INVITE_INVITEDYOU.toString()).color(ChatColor.YELLOW).tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()).command("f join " + myFaction.getTag()).then(myFaction.describeTo(you)).tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()).command("f join " + myFaction.getTag()); + 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()); message.send(you.getPlayer()); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdKick.java b/src/main/java/com/massivecraft/factions/cmd/CmdKick.java index f1bd6f4b..b21bc609 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdKick.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdKick.java @@ -37,12 +37,12 @@ public class CmdKick extends FCommand { FancyMessage msg = new FancyMessage(TL.COMMAND_KICK_CANDIDATES.toString()).color(ChatColor.GOLD); for (FPlayer player : myFaction.getFPlayersWhereRole(Role.NORMAL)) { String s = player.getName(); - msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("f kick " + s); + msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command(Conf.baseCommandAliases.get(0) + " kick " + s); } if (fme.getRole() == Role.ADMIN) { for (FPlayer player : myFaction.getFPlayersWhereRole(Role.MODERATOR)) { String s = player.getName(); - msg.then(s + " ").color(ChatColor.GRAY).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("f kick " + s); + msg.then(s + " ").color(ChatColor.GRAY).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command(Conf.baseCommandAliases.get(0) + " kick " + s); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMod.java b/src/main/java/com/massivecraft/factions/cmd/CmdMod.java index 47ed4806..6d228363 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMod.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMod.java @@ -1,5 +1,6 @@ package com.massivecraft.factions.cmd; +import com.massivecraft.factions.Conf; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.Faction; import com.massivecraft.factions.struct.Permission; @@ -33,7 +34,7 @@ public class CmdMod extends FCommand { FancyMessage msg = new FancyMessage(TL.COMMAND_MOD_CANDIDATES.toString()).color(ChatColor.GOLD); for (FPlayer player : myFaction.getFPlayersWhereRole(Role.NORMAL)) { String s = player.getName(); - msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("f mod " + s); + msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command(Conf.baseCommandAliases.get(0) + " mod " + s); } sendFancyMessage(msg); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdShowInvites.java b/src/main/java/com/massivecraft/factions/cmd/CmdShowInvites.java index 51180f8c..8d3e5a82 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdShowInvites.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdShowInvites.java @@ -1,5 +1,6 @@ package com.massivecraft.factions.cmd; +import com.massivecraft.factions.Conf; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.struct.Permission; @@ -24,7 +25,7 @@ public class CmdShowInvites extends FCommand { for (String id : myFaction.getInvites()) { FPlayer fp = FPlayers.getInstance().getById(id); String name = fp != null ? fp.getName() : id; - msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_SHOWINVITES_CLICKTOREVOKE.format(name)).command("f deinvite " + name); + msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_SHOWINVITES_CLICKTOREVOKE.format(name)).command(Conf.baseCommandAliases.get(0) + " deinvite " + name); } sendFancyMessage(msg);