From 8ff405f2fee0fa7171008c8237bb16123b309977 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Wed, 17 Aug 2011 13:46:27 +0100 Subject: [PATCH] Adding /tpaall - Teleport here request to all players. --- .../essentials/commands/Commandtime.java | 3 +- .../essentials/commands/Commandtpaall.java | 61 +++++++++++++++++++ .../essentials/commands/Commandtpaccept.java | 2 +- .../essentials/commands/Commandtpdeny.java | 2 +- Essentials/src/messages.properties | 5 +- Essentials/src/messages_en.properties | 4 +- Essentials/src/plugin.yml | 3 + 7 files changed, 74 insertions(+), 6 deletions(-) create mode 100644 Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java index 23f9138a9..331fff019 100755 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java @@ -97,8 +97,7 @@ public class Commandtime extends EssentialsCommand // Inform the sender of the change sender.sendMessage(""); - sender.sendMessage(colorDefault + "The time was set to"); - sender.sendMessage(DescParseTickFormat.format(ticks)); + sender.sendMessage(colorDefault + "The time was set to " + DescParseTickFormat.format(ticks)); StringBuilder msg = new StringBuilder(); msg.append(colorDefault); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java new file mode 100644 index 000000000..780e75e1f --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java @@ -0,0 +1,61 @@ +package com.earth2me.essentials.commands; + +import org.bukkit.Server; +import com.earth2me.essentials.User; +import com.earth2me.essentials.Util; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + + +public class Commandtpaall extends EssentialsCommand +{ + public Commandtpaall() + { + super("tpaall"); + } + + @Override + public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + { + if (args.length < 1) + { + if (sender instanceof Player) + { + charge(sender); + teleportAAllPlayers(server, sender, ess.getUser(sender)); + return; + } + throw new NotEnoughArgumentsException(); + } + + User p = getPlayer(server, args, 0); + charge(sender); + teleportAAllPlayers(server, sender, p); + } + + private void teleportAAllPlayers(Server server, CommandSender sender, User p) + { + sender.sendMessage(Util.i18n("teleportAAll")); + for (Player player : server.getOnlinePlayers()) + { + User u = ess.getUser(player); + if (p == u) + { + continue; + } + if (!u.isTeleportEnabled()) + { + continue; + } + try + { + u.requestTeleport(p, true); + u.sendMessage(Util.format("teleportHereRequest", p.getDisplayName())); + } + catch (Exception ex) + { + ess.showError(sender, ex, getName()); + } + } + } +} diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java index 0cba80020..043f23172 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java @@ -33,7 +33,7 @@ public class Commandtpaccept extends EssentialsCommand charge.isAffordableFor(p); } user.sendMessage(Util.i18n("requestAccepted")); - p.sendMessage(Util.i18n("requestAccepted")); + p.sendMessage(Util.format("requestAcceptedFrom", user.getDisplayName())); if (user.isTeleportRequestHere()) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java index 097ea1fdd..e31d7ae3c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java @@ -23,7 +23,7 @@ public class Commandtpdeny extends EssentialsCommand charge(user); user.sendMessage(Util.i18n("requestDenied")); - p.sendMessage(Util.i18n("requestDenied")); + p.sendMessage(Util.format("requestDeniedFrom", user.getDisplayName())); user.requestTeleport(null, false); } } diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index bdb2d45a8..9bbcd7a87 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -230,7 +230,9 @@ protectionOwner = \u00a76[EssentialsProtect] Protection owner: {0} questionFormat = \u00a77[Question]\u00a7f {0} reloadAllPlugins = \u00a77Reloaded all plugins. requestAccepted = \u00a77Teleport request accepted. +requestAcceptedFrom = \u00a77{0} accepted your teleport request. requestDenied = \u00a77Teleport request denied. +requestDeniedFrom = \u00a77{0} denied your teleport request. requestSent = \u00a77Request sent to {0}\u00a77. returnPlayerToJailError = Error occured when trying to return player to jail. second = second @@ -249,10 +251,11 @@ suicideMessage = \u00a77Goodbye Cruel World... suicideSuccess = \u00a77{0} took their own life takenFromAccount = \u00a7c{0} has been taken from your account. takenFromOthersAccount = \u00a7c{0} has been taken from {1} account. +teleportAAll = \u00a77Teleporting request sent to all players... teleportAll = \u00a77Teleporting all players... teleportAtoB = \u00a77{0}\u00a77 teleported you to {1}\u00a77. teleportDisabled = {0} has teleportation disabled. -teleportHereRequest = \u00a7c{0}\u00a7c has requested that you teleport to him/her. +teleportHereRequest = \u00a7c{0}\u00a7c has requested that you teleport to them. teleportNewPlayerError = Failed to teleport new player teleportRequest = \u00a7c{0}\u00a7c has requested to teleport to you. teleportTop = \u00a77Teleporting to top. diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index 1da3bc4a5..84a843dc7 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -230,7 +230,9 @@ protectionOwner = \u00a76[EssentialsProtect] Protection owner: {0} questionFormat = \u00a77[Question]\u00a7f {0} reloadAllPlugins = \u00a77Reloaded all plugins. requestAccepted = \u00a77Teleport request accepted. +requestAcceptedFrom = \u00a77{0} accepted your teleport request. requestDenied = \u00a77Teleport request denied. +requestDeniedFrom = \u00a77{0} denied your teleport request requestSent = \u00a77Request sent to {0}\u00a77. returnPlayerToJailError = Error occured when trying to return player to jail. second = second @@ -252,7 +254,7 @@ takenFromOthersAccount = \u00a7c{0} has been taken from {1} account. teleportAll = \u00a77Teleporting all players... teleportAtoB = \u00a77{0}\u00a77 teleported you to {1}\u00a77. teleportDisabled = {0} has teleportation disabled. -teleportHereRequest = \u00a7c{0}\u00a7c has requested that you teleport to him/her. +teleportHereRequest = \u00a7c{0}\u00a7c has requested that you teleport to them. teleportNewPlayerError = Failed to teleport new player teleportRequest = \u00a7c{0}\u00a7c has requested to teleport to you. teleportTop = \u00a77Teleporting to top. diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index 9c0d51d71..4712203f6 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -293,6 +293,9 @@ commands: tpa: description: Request to teleport to the specified player. usage: / + tpaall: + description: Requests all players online to teleport to you. + usage: / tpaccept: description: Accepts a teleport request. usage: /