From 71358629f4347c570d2e267b7102f3af812e71d7 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Thu, 22 Mar 2012 22:59:52 +0000 Subject: [PATCH] New command: /fly New perm: essentials.fly.others --- .../com/earth2me/essentials/Essentials.java | 2 +- .../earth2me/essentials/OfflinePlayer.java | 13 +++- .../essentials/commands/Commandfly.java | 63 +++++++++++++++++++ Essentials/src/messages.properties | 1 + Essentials/src/messages_da.properties | 1 + Essentials/src/messages_de.properties | 3 +- Essentials/src/messages_en.properties | 1 + Essentials/src/messages_es.properties | 1 + Essentials/src/messages_fr.properties | 1 + Essentials/src/messages_nl.properties | 1 + Essentials/src/plugin.yml | 4 ++ 11 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 Essentials/src/com/earth2me/essentials/commands/Commandfly.java diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 4111d3ca7..660d4887b 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -66,7 +66,7 @@ import org.yaml.snakeyaml.error.YAMLException; public class Essentials extends JavaPlugin implements IEssentials { - public static final int BUKKIT_VERSION = 2100; + public static final int BUKKIT_VERSION = 2105; private static final Logger LOGGER = Logger.getLogger("Minecraft"); private transient ISettings settings; private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this); diff --git a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java index 6a88eb533..c6230f5e0 100644 --- a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java +++ b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java @@ -26,7 +26,6 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; - public class OfflinePlayer implements Player { private final transient IEssentials ess; @@ -1040,4 +1039,16 @@ public class OfflinePlayer implements Player { throw new UnsupportedOperationException("Not supported yet."); } + + @Override + public boolean isFlying() + { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFlying(boolean arg0) + { + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandfly.java b/Essentials/src/com/earth2me/essentials/commands/Commandfly.java new file mode 100644 index 000000000..ea6192589 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/commands/Commandfly.java @@ -0,0 +1,63 @@ +package com.earth2me.essentials.commands; + +import static com.earth2me.essentials.I18n._; +import com.earth2me.essentials.User; +import java.util.Locale; +import org.bukkit.GameMode; +import org.bukkit.Server; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + + +public class Commandfly extends EssentialsCommand +{ + public Commandfly() + { + super("fly"); + } + + @Override + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + { + if (args.length < 1) + { + throw new NotEnoughArgumentsException(); + } + + flyOtherPlayers(server, sender, args[0]); + } + + @Override + protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception + { + if (args.length > 0 && !args[0].trim().isEmpty() && user.isAuthorized("essentials.fly.others")) + { + flyOtherPlayers(server, user, args[0]); + return; + } + user.setAllowFlight(!user.getAllowFlight()); + if (!user.getAllowFlight()) + { + user.setFlying(false); + } + user.sendMessage(_("flyMode", _(user.getAllowFlight() ? "true" : "false"), user.getDisplayName())); + } + + private void flyOtherPlayers(final Server server, final CommandSender sender, final String name) + { + for (Player matchPlayer : server.matchPlayer(name)) + { + final User player = ess.getUser(matchPlayer); + if (player.isHidden()) + { + continue; + } + player.setAllowFlight(!player.getAllowFlight()); + if (!player.getAllowFlight()) + { + player.setFlying(false); + } + sender.sendMessage(_("flyMode", _(player.getAllowFlight() ? "true" : "false"), player.getDisplayName())); + } + } +} diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index 02598c9cb..aa32ad340 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -92,6 +92,7 @@ false=false feed=\u00a77Your appetite was sated. feedOther=\u00a77Satisfied {0}. fileRenameError=Renaming file {0} failed +flyMode=\u00a77Set fly mode {0} for {1}. foreverAlone=\u00a7cYou have nobody to whom you can reply. freedMemory=Freed {0} MB. gameMode=\u00a77Set game mode {0} for {1}. diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index fd4803d3f..9304c52df 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -92,6 +92,7 @@ false=false feed=\u00a77Your appetite was sated. feedOther=\u00a77Satisfied {0}. fileRenameError=Omd\u00c3\u00b8bning af fil {0} fejlede. +flyMode=\u00a77Set fly mode {0} for {1}. foreverAlone=\u00a7cDu har ingen til hvem du kan svare. freedMemory=Frigjorde {0} MB. gameMode=\u00a77Satte game mode {0} for {1}. diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index 767f028fd..9c7846008 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -92,6 +92,7 @@ false=false feed=\u00a77Your appetite was sated. feedOther=\u00a77Satisfied {0}. fileRenameError=Umbenennen von {0} gescheitert. +flyMode=\u00a77Set fly mode {0} for {1}. foreverAlone=\u00a7cDu hast niemanden, dem du antworten kannst. freedMemory={0} MB frei gemacht. gameMode=\u00a77Set game mode {0} for {1}. @@ -396,6 +397,7 @@ weatherStormFor=\u00a77In {0} st\u00fcrmt es nun f\u00fcr {1} Sekunden. weatherSun=\u00a77In {0} scheint nun die Sonne. weatherSunFor=\u00a77In {0} scheint nun f\u00fcr {1} Sekunden die Sonne. whoisBanned=\u00a79 - Banned: {0} +whoisExp=\u00a79 - Exp: {0} (Level {1}) whoisGamemode=\u00a79 - Gamemode: {0} whoisGeoLocation=\u00a79 - Herkunft: {0} whoisGod=\u00a79 - God mode: {0} @@ -415,4 +417,3 @@ year=Jahr years=Jahre youAreHealed=\u00a77Du wurdest geheilt. youHaveNewMail=\u00a7cDu hast {0} Nachrichten!\u00a7f Schreibe \u00a77/mail read\u00a7f um deine Nachrichten anzuzeigen. -whoisExp=\u00a79 - Exp: {0} (Level {1}) diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index 0a64b2308..5cb5b8792 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -92,6 +92,7 @@ false=false feed=\u00a77Your appetite was sated. feedOther=\u00a77Satisfied {0}. fileRenameError=Renaming file {0} failed +flyMode=\u00a77Set fly mode {0} for {1}. foreverAlone=\u00a7cYou have nobody to whom you can reply. freedMemory=Freed {0} MB. gameMode=\u00a77Set game mode {0} for {1}. diff --git a/Essentials/src/messages_es.properties b/Essentials/src/messages_es.properties index 6356bfbff..e1a256b40 100644 --- a/Essentials/src/messages_es.properties +++ b/Essentials/src/messages_es.properties @@ -92,6 +92,7 @@ false=false feed=\u00a77Your appetite was sated. feedOther=\u00a77Satisfied {0}. fileRenameError=Error al renombrar el archivo {0} +flyMode=\u00a77Set fly mode {0} for {1}. foreverAlone=\u00a7cNo tienes nadie a quien puedas responder. freedMemory= {0} MB libres. gameMode=\u00a77Set game mode {0} for {1}. diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index e92efb181..1766f4df3 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -92,6 +92,7 @@ false=non feed=\u00a77Vous avez \u00e9t\u00e9 rassasi\u00e9. feedOther=\u00a77 est rassasi\u00e9 {0}. fileRenameError=Echec du changement de nom de {0} +flyMode=\u00a77Set fly mode {0} for {1}. foreverAlone=\u00a7cVous n''avez personne \u00e0 qui r\u00e9pondre freedMemory=A lib\u00e9r\u00e9 {0} Mo. gameMode=\u00a77Mode de jeu {0} pour {1}. diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index 5ab703d99..c7f715e72 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -92,6 +92,7 @@ false=false feed=\u00a77Your appetite was sated. feedOther=\u00a77Satisfied {0}. fileRenameError=Hernoemen van {0} mislukt +flyMode=\u00a77Set fly mode {0} for {1}. foreverAlone=\u00a7cJe hebt niemand waarnaar je kan reageren. freedMemory={0} MB gelost. gameMode=\u00a77Set game mode {0} for {1}. diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index c54e79c12..7eaca70f4 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -98,6 +98,10 @@ commands: description: Satisfy the hunger. usage: / [player] aliases: [efeed,eat,eeat] + fly: + description: Take off, and soar! + usage: / [player] + aliases: [efly] itemdb: description: Searches for an item. usage: /