From c32e647d9ef67612da88dca803c60904feead47f Mon Sep 17 00:00:00 2001 From: TadahTech Date: Mon, 18 Jul 2016 22:21:09 -0500 Subject: [PATCH] Add private messaging system --- .../src/mineplex/mapparser/MapParser.java | 3 ++ .../mineplex/mapparser/command/PMCommand.java | 52 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/PMCommand.java diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java index 0d4a5c937..9105e8ea6 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java @@ -26,6 +26,7 @@ import mineplex.mapparser.command.ListCommand; import mineplex.mapparser.command.LockCommand; import mineplex.mapparser.command.MapCommand; import mineplex.mapparser.command.NameCommand; +import mineplex.mapparser.command.PMCommand; import mineplex.mapparser.command.ParseCommand200; import mineplex.mapparser.command.ParseCommand400; import mineplex.mapparser.command.ParseCommand600; @@ -119,6 +120,8 @@ public class MapParser extends JavaPlugin commandModule.add(new WarpCommand(this)); commandModule.add(new CurrentlyLiveCommand(this)); commandModule.add(new AddSplashTextCommand(this)); + commandModule.add(new PMCommand(this)); + loadInfo(); addSplashText(); } diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/PMCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/PMCommand.java new file mode 100644 index 000000000..82a72b071 --- /dev/null +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/PMCommand.java @@ -0,0 +1,52 @@ +package mineplex.mapparser.command; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilServer; +import mineplex.mapparser.MapParser; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +/** + * + */ +public class PMCommand extends BaseCommand +{ + public PMCommand(MapParser plugin) + { + super(plugin, "m", "message"); + } + + @Override + public boolean execute(Player player, String alias, String[] args) + { + if(!player.isOp()) + { + player.sendMessage(C.cRed + "You are not allowed to do that!"); + return true; + } + + if(args.length == 0) + { + player.sendMessage(C.cRed + "Please put a message in!"); + return true; + } + + StringBuilder builder = new StringBuilder(); + for(String s : args) + { + builder.append(s).append(" "); + } + for(Player ops : UtilServer.getPlayers()) + { + if(!ops.isOp()) + { + continue; + } + ops.sendMessage(F.main("Message", builder.toString().trim())); + ops.playSound(ops.getLocation(), Sound.NOTE_PLING, 1.0f, 1.0f); + } + + return true; + } +}