New command: /fly

New perm: essentials.fly.others
This commit is contained in:
KHobbits 2012-03-22 22:59:52 +00:00
parent 284fef00e7
commit 71358629f4
11 changed files with 88 additions and 3 deletions

View File

@ -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);

View File

@ -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.");
}
}

View File

@ -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()));
}
}
}

View File

@ -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}.

View File

@ -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}.

View File

@ -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})

View File

@ -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}.

View File

@ -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}.

View File

@ -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}.

View File

@ -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}.

View File

@ -98,6 +98,10 @@ commands:
description: Satisfy the hunger.
usage: /<command> [player]
aliases: [efeed,eat,eeat]
fly:
description: Take off, and soar!
usage: /<command> [player]
aliases: [efly]
itemdb:
description: Searches for an item.
usage: /<command> <item>