Add faction announcements to send to all players and show to players when they login if they were not online when it was first sent as requested in issue #82.

This commit is contained in:
drtshock
2014-10-18 03:54:45 -05:00
parent 047fe0937a
commit bed6fe0741
8 changed files with 93 additions and 6 deletions

View File

@@ -0,0 +1,42 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.struct.Permission;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
public class CmdAnnounce extends FCommand {
public CmdAnnounce() {
super();
this.aliases.add("ann");
this.aliases.add("announce");
this.requiredArgs.add("message");
this.errorOnToManyArgs = false;
this.permission = Permission.ANNOUNCE.node;
this.disableOnLock = false;
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = true;
}
@Override
public void perform() {
String prefix = ChatColor.GREEN + myFaction.getTag() + ChatColor.YELLOW + " [" + ChatColor.GRAY + me.getName() + ChatColor.YELLOW + "] " + ChatColor.RESET;
String message = StringUtils.join(args, " ");
for (Player player : myFaction.getOnlinePlayers()) {
player.sendMessage(prefix + message);
}
// Add for offline players.
for (FPlayer fp : myFaction.getFPlayersWhereOnline(false)) {
myFaction.addAnnouncement(fp, prefix + message);
}
}
}

View File

@@ -44,6 +44,7 @@ public class CmdInvite extends FCommand {
}
myFaction.invite(you);
if(!you.isOnline()) return;
// Tooltips, colors, and commands only apply to the string immediately before it.
FancyMessage message = new FancyMessage(fme.describeTo(you, true))

View File

@@ -54,6 +54,7 @@ public class FCmdRoot extends FCommand {
public CmdWarunclaimall cmdWarunclaimall = new CmdWarunclaimall();
public CmdSB cmdSB = new CmdSB();
public CmdShowInvites cmdShowInvites = new CmdShowInvites();
public CmdAnnounce cmdAnnounce = new CmdAnnounce();
public FCmdRoot() {
super();
@@ -124,6 +125,7 @@ public class FCmdRoot extends FCommand {
this.addSubCommand(this.cmdWarunclaimall);
this.addSubCommand(this.cmdSB);
this.addSubCommand(this.cmdShowInvites);
this.addSubCommand(this.cmdAnnounce);
}
@Override