Added cross-server Announcements and Global messages.

This commit is contained in:
Jonathan Williams 2015-01-24 01:44:22 -08:00
parent d6e8fdd2ed
commit 58a8a32e93
5 changed files with 131 additions and 10 deletions

View File

@ -0,0 +1,33 @@
package mineplex.core.message;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.serverdata.CommandCallback;
import mineplex.serverdata.ServerCommand;
import mineplex.serverdata.transfers.AnnouncementCommand;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class AnnouncementHandler implements CommandCallback
{
public void run(ServerCommand command)
{
if (command instanceof ServerCommand)
{
AnnouncementCommand announcementCommand = (AnnouncementCommand)command;
String message = announcementCommand.getMessage();
if (announcementCommand.getDisplayTitle())
UtilTextMiddle.display(C.cYellow + "Announcement", message, 10, 120, 10);
for (Player player : Bukkit.getOnlinePlayers())
{
UtilPlayer.message(player, F.main("Announcement", C.cAqua + message));
}
}
}
}

View File

@ -0,0 +1,34 @@
package mineplex.core.message.Commands;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.message.MessageManager;
import mineplex.serverdata.transfers.AnnouncementCommand;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class AnnounceCommand extends CommandBase<MessageManager>
{
public AnnounceCommand(MessageManager plugin)
{
super(plugin, Rank.ADMIN, "announce");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args == null)
{
Plugin.Help(caller);
}
else
{
new AnnouncementCommand(true, F.combine(args, 0, null, false)).publish();
}
}
}

View File

@ -0,0 +1,32 @@
package mineplex.core.message.Commands;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.message.MessageManager;
import mineplex.serverdata.transfers.AnnouncementCommand;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class GlobalCommand extends CommandBase<MessageManager>
{
public GlobalCommand(MessageManager plugin)
{
super(plugin, Rank.ADMIN, "global");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args == null)
{
Plugin.Help(caller);
}
else
{
new AnnouncementCommand(false, F.combine(args, 0, null, false)).publish();
}
}
}

View File

@ -17,6 +17,8 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.message.Commands.*; import mineplex.core.message.Commands.*;
import mineplex.core.preferences.PreferencesManager; import mineplex.core.preferences.PreferencesManager;
import mineplex.serverdata.ServerCommandManager;
import mineplex.serverdata.transfers.AnnouncementCommand;
public class MessageManager extends MiniClientPlugin<ClientMessage> public class MessageManager extends MiniClientPlugin<ClientMessage>
{ {
@ -31,6 +33,8 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
_clientManager = clientManager; _clientManager = clientManager;
_preferences = preferences; _preferences = preferences;
ServerCommandManager.getInstance().registerCommandType("AnnouncementCommand", AnnouncementCommand.class, new AnnouncementHandler());
} }
//Module Functions //Module Functions
@ -83,21 +87,15 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
addCommand(new MessageAdminCommand(this)); addCommand(new MessageAdminCommand(this));
addCommand(new ResendAdminCommand(this)); addCommand(new ResendAdminCommand(this));
addCommand(new AnnounceCommand(this));
addCommand(new GlobalCommand(this));
addCommand(new AdminCommand(this)); addCommand(new AdminCommand(this));
} }
public void Help(Player caller, String message) public void Help(Player caller, String message)
{ {
UtilPlayer.message(caller, F.main(_moduleName, "Commands List:")); UtilPlayer.message(caller, F.main(_moduleName, ChatColor.RED + "Err...something went wrong?"));
UtilPlayer.message(caller, F.help("/npc add <radius> <name>", "Right click mob to attach npc.", Rank.OWNER));
UtilPlayer.message(caller, F.help("/npc del ", "Right click npc to delete", Rank.OWNER));
UtilPlayer.message(caller, F.help("/npc clear", "Removes all npcs", Rank.OWNER));
UtilPlayer.message(caller, F.help("/npc home", " Teleport npcs to home locations.", Rank.OWNER));
UtilPlayer.message(caller, F.help("/npc reattach", "Attempt to reattach npcs to entities.", Rank.OWNER));
if (message != null)
UtilPlayer.message(caller, F.main(_moduleName, ChatColor.RED + message));
} }
public void Help(Player caller) public void Help(Player caller)

View File

@ -0,0 +1,24 @@
package mineplex.serverdata.transfers;
import mineplex.serverdata.ServerCommand;
public class AnnouncementCommand extends ServerCommand
{
private boolean _displayTitle;
private String _message;
public boolean getDisplayTitle() { return _displayTitle; }
public String getMessage() { return _message; }
public AnnouncementCommand(boolean displayTitle, String message)
{
_displayTitle = displayTitle;
_message = message;
}
@Override
public void run()
{
// Utilitizes a callback functionality to seperate dependencies
}
}