More work on /fly command - Still incomplete

Updated and fixed messages files for missing keys.
This commit is contained in:
KHobbits 2012-08-26 17:12:18 +01:00
parent a4936355b5
commit 2b6d41ac5f
17 changed files with 131 additions and 46 deletions

View file

@ -159,7 +159,7 @@ public interface ISettings extends IConf
boolean getRepairEnchanted();
boolean isWorldTeleportPermissions();
boolean isWorldHomePermissions();
boolean registerBackInListener();
@ -177,8 +177,12 @@ public interface ISettings extends IConf
long getTeleportInvulnerability();
boolean isTeleportInvulnerability();
long getLoginAttackDelay();
int getSignUsePerSecond();
double getMaxFlySpeed();
double getMaxWalkSpeed();
}

View file

@ -912,4 +912,18 @@ public class Settings implements ISettings
{
return signUsePerSecond;
}
@Override
public double getMaxFlySpeed()
{
double maxSpeed = config.getDouble("max-fly-speed", 1.0);
return maxSpeed > 1.0 ? 1.0 : Math.abs(maxSpeed);
}
@Override
public double getMaxWalkSpeed()
{
double maxSpeed = config.getDouble("max-walk-speed", 0.8);
return maxSpeed > 1.0 ? 1.0 : Math.abs(maxSpeed);
}
}

View file

@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -21,7 +22,7 @@ public class Commandspeed extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
final boolean isFly = isFlyMode(args[0]);
final float speed = isMoveSpeed(args[1]);
final float speed = getMoveSpeed(args[1]);
speedOtherPlayers(server, sender, isFly, speed, args[2]);
}
@ -38,28 +39,30 @@ public class Commandspeed extends EssentialsCommand
if (args.length == 1)
{
isFly = user.isFlying();
speed = isMoveSpeed(args[0]);
speed = getMoveSpeed(args[0]);
}
else if (args.length == 2)
{
isFly = isFlyMode(args[0]);
speed = isMoveSpeed(args[1]);
speed = getMoveSpeed(args[1]);
}
else
{
isFly = isFlyMode(args[0]);
speed = isMoveSpeed(args[1]);
speed = getMoveSpeed(args[1]);
speedOtherPlayers(server, user, isFly, speed, args[2]);
return;
}
if (isFly)
{
user.setFlySpeed(speed);
user.setFlySpeed(getRealMoveSpeed(speed, isFly));
user.sendMessage(_("moveSpeed", _("flying"), speed, user.getDisplayName()));
}
else
{
user.setWalkSpeed(speed);
user.setWalkSpeed(getRealMoveSpeed(speed, isFly));
user.sendMessage(_("moveSpeed", _("walking"), speed, user.getDisplayName()));
}
}
@ -69,16 +72,18 @@ public class Commandspeed extends EssentialsCommand
{
if (isFly)
{
matchPlayer.setFlySpeed(speed);
matchPlayer.setFlySpeed(getRealMoveSpeed(speed, isFly));
sender.sendMessage(_("moveSpeed", _("flying"), speed, matchPlayer.getDisplayName()));
}
else
{
matchPlayer.setWalkSpeed(speed);
matchPlayer.setWalkSpeed(getRealMoveSpeed(speed, isFly));
sender.sendMessage(_("moveSpeed", _("walking"), speed, matchPlayer.getDisplayName()));
}
}
}
private boolean isFlyMode(String modeString) throws NotEnoughArgumentsException
private boolean isFlyMode(final String modeString) throws NotEnoughArgumentsException
{
boolean isFlyMode;
if (modeString.contains("fly") || modeString.equalsIgnoreCase("f"))
@ -97,17 +102,41 @@ public class Commandspeed extends EssentialsCommand
return isFlyMode;
}
private float isMoveSpeed(String moveSpeed) throws NotEnoughArgumentsException
private float getMoveSpeed(final String moveSpeed) throws NotEnoughArgumentsException
{
float speed;
float userSpeed;
try
{
speed = Float.parseFloat(moveSpeed);
userSpeed = Float.parseFloat(moveSpeed);
if (userSpeed > 10f)
{
userSpeed = 10f;
}
else if (userSpeed < 0f)
{
userSpeed = 0f;
}
}
catch (NumberFormatException e)
{
throw new NotEnoughArgumentsException();
}
return speed;
return userSpeed;
}
private float getRealMoveSpeed(final float userSpeed, final boolean isFly)
{
float maxSpeed = (float)(isFly ? ess.getSettings().getMaxFlySpeed() : ess.getSettings().getMaxWalkSpeed());
float defaultSpeed = isFly ? 0.1f : 0.2f;
if (userSpeed < 1f)
{
return defaultSpeed * userSpeed;
}
else
{
float ratio = ((userSpeed - 1) / 9) * (maxSpeed - defaultSpeed);
return ratio + defaultSpeed;
}
}
}

View file

@ -233,7 +233,7 @@ enabledSigns:
# Lower numbers will reduce the possibility of lag, but may annoy players.
sign-use-per-second: 4
# Backup runs a command while saving is disabled
# Backup runs a batch/bash command while saving is disabled
backup:
# Interval in minutes
interval: 30
@ -321,6 +321,12 @@ register-back-in-listener: false
#Delay to wait before people can cause attack damage after logging in
login-attack-delay: 5
#Set the max fly speed, values range from 0.1 to 1.0
max-fly-speed: 1.0
#Set the max walk speed, values range from 0.1 to 1.0
max-walk-speed: 0.8
############################################################
# +------------------------------------------------------+ #
# | EssentialsHome | #

View file

@ -443,3 +443,5 @@ youAreHealed=\u00a77You have been healed.
youHaveNewMail=\u00a7cYou have {0} messages!\u00a7f Type \u00a77/mail read\u00a7f to view your mail.
hatRemoved=\u00a7eYour hat has been removed.
banFormat=Banned: {0}
moveSpeed=\u00a77Set {0} speed to {1} for {2}.
walking=walking

View file

@ -446,3 +446,5 @@ year=rok
years=roky
youAreHealed=\u00a77Byl jsi uzdraven.
youHaveNewMail=\u00a7cMas {0} zprav!\u00a7f Napis \u00a77/mail read\u00a7f aby jsi si precetl sve zpravy.
moveSpeed=\u00a77Set {0} speed to {1} for {2}.
walking=walking

View file

@ -443,3 +443,5 @@ youAreHealed=\u00a77Du er blevet healed. Halleluja!
youHaveNewMail=\u00a7cDu har {0} flaskeposter!\u00a7f Type \u00a77/mail read for at se din flaskepost.
hatRemoved=\u00a7eYour hat has been removed.
banFormat=Banned: {0}
moveSpeed=\u00a77Set {0} speed to {1} for {2}.
walking=walking

View file

@ -443,3 +443,5 @@ youAreHealed=\u00a77Du wurdest geheilt.
youHaveNewMail=\u00a7cDu hast {0} Nachrichten!\u00a7f Schreibe \u00a77/mail read\u00a7f um deine Nachrichten anzuzeigen.
hatRemoved=\u00a7eYour hat has been removed.
banFormat=Banned: {0}
moveSpeed=\u00a77Set {0} speed to {1} for {2}.
walking=walking

View file

@ -443,3 +443,5 @@ youAreHealed=\u00a77You have been healed.
youHaveNewMail=\u00a7cYou have {0} messages!\u00a7f Type \u00a77/mail read\u00a7f to view your mail.
hatRemoved=\u00a7eYour hat has been removed.
banFormat=Banned: {0}
moveSpeed=\u00a77Set {0} speed to {1} for {2}.
walking=walking

View file

@ -443,3 +443,5 @@ youAreHealed=\u00a77Has sido curado.
youHaveNewMail=\u00a7cTienes {0} mensajes!\u00a7f Pon \u00a77/mail read\u00a7f para ver tus emails no leidos!.
hatRemoved=\u00a7eYour hat has been removed.
banFormat=Banned: {0}
moveSpeed=\u00a77Set {0} speed to {1} for {2}.
walking=walking

View file

@ -414,20 +414,16 @@ weatherStorm=\u00a77Laitoit myrskyn maailmaan {0}
weatherStormFor=\u00a77Laitoit myrskyn maailmaan {0} {1} sekunniksi
weatherSun=\u00a77Laitoit auringon paistamaan maailmaan {0}
weatherSunFor=\u00a77Laitoit auringon paistamaan maailmaan {0} {1} sekunniksi
whoisBanned=\u00a79 - Bannattu: {0}
whoisExp=\u00a79 - Exp: {0} (Taso {1})
whoisGamemode=\u00a79 - Pelimuoto: {0}
whoisGeoLocation=\u00a79 - Sijainti: {0}
whoisGod=\u00a79 - God muoto: {0}
whoisHealth=\u00a79 - Terveys: {0}/20
whoisIPAddress=\u00a79 - IP Osoite: {0}
whoisIs={0} on {1}
whoisJail=\u00a79 - Vankila: {0}
whoisLocation=\u00a79 - Sijainti: ({0}, {1}, {2}, {3})
whoisMoney=\u00a79 - Raha: {0}
whoisOP=\u00a79 - OP: {0}
whoisStatusAvailable=\u00a79 - Tilanne: Saatavilla
whoisStatusAway=\u00a79 - Tilanne: \u00a7cPoissa\u00a7f
whoisBanned=\u00a76 - Banned:\u00a7f {0}
whoisExp=\u00a76 - Exp:\u00a7f {0} (Level {1})
whoisGamemode=\u00a76 - Gamemode:\u00a7f {0}
whoisGeoLocation=\u00a76 - Location:\u00a7f {0}
whoisGod=\u00a76 - God mode:\u00a7f {0}
whoisHealth=\u00a76 - Health:\u00a7f {0}/20
whoisIPAddress=\u00a76 - IP Address:\u00a7f {0}
whoisJail=\u00a76 - Jail:\u00a7f {0}
whoisLocation=\u00a76 - Location:\u00a7f ({0}, {1}, {2}, {3})
whoisMoney=\u00a76 - Money:\u00a7f {0}
worth=\u00a77Pino tavaraa "{0}" on arvoltaan \u00a7c{1}\u00a77 ({2} tavara(a) = {3} kappale)
worthMeta=\u00a77Pino tavaraa "{0}" metadatan kanssa {1} on arvoltaan \u00a7c{2}\u00a77 ({3} tavara(a) = {4} kappale)
worthSet=Arvo asetettu
@ -437,3 +433,11 @@ youAreHealed=\u00a77Sinut on parannettu.
youHaveNewMail=\u00a7cSinulla on {0} viesti(\u00e4)!\u00a7f Kirjoita \u00a77/mail read\u00a7f lukeaksesi viestit.
hatRemoved=\u00a7eYour hat has been removed.
banFormat=Banned: {0}
moveSpeed=\u00a77Set {0} speed to {1} for {2}.
whoisAFK=\u00a76 - AFK:\u00a7f {0}
whoisFly=\u00a76 - Fly mode:\u00a7f {0} ({1})
whoisMuted=\u00a76 - Muted:\u00a7f {0}
whoisNick=\u00a76 - Nick:\u00a7f {0}
whoisOp=\u00a76 - OP:\u00a7f {0}
whoisTop=\u00a76 ====== WhoIs:\u00a7f {0} \u00a76======
walking=walking

View file

@ -443,3 +443,5 @@ youAreHealed=\u00a77Vous avez \u00e9t\u00e9 soign\u00e9.
youHaveNewMail=\u00a7cVous avez {0} messages ! \u00a7fEntrez \u00a77/mail read\u00a7f pour voir votre courrier.
hatRemoved=\u00a7eYour hat has been removed.
banFormat=Banned: {0}
moveSpeed=\u00a77Set {0} speed to {1} for {2}.
walking=walking

View file

@ -443,3 +443,5 @@ youAreHealed=\u00a77Sei stato curato.
youHaveNewMail=\u00a7cHai {0} messaggi!\u00a7f digita \u00a77/mail read\u00a7f per consultare la tua mail.
hatRemoved=\u00a7eYour hat has been removed.
banFormat=Banned: {0}
moveSpeed=\u00a77Set {0} speed to {1} for {2}.
walking=walking

View file

@ -443,3 +443,5 @@ youAreHealed=\u00a77Je bent genezen.
youHaveNewMail=\u00a7cJe hebt {0} berichten!\u00a7f Type \u00a77/mail read\u00a7f om je berichten te bekijken.
hatRemoved=\u00a7eYour hat has been removed.
banFormat=Banned: {0}
moveSpeed=\u00a77Set {0} speed to {1} for {2}.
walking=walking

View file

@ -443,3 +443,5 @@ youAreHealed=\u00a77Zostales/as uleczony/na.
youHaveNewMail=\u00a7cMasz {0} wiadomosci!\u00a7f napisz \u00a77/mail read\u00a7f aby je przeczytac.
hatRemoved=\u00a7eYour hat has been removed.
banFormat=Banned: {0}
moveSpeed=\u00a77Set {0} speed to {1} for {2}.
walking=walking

View file

@ -443,3 +443,5 @@ youAreHealed=\u00a77Voc\u00ea foi curado.
youHaveNewMail=\u00a7cVoc\u00ea tem {0} mensagens!\u00a7f Digite \u00a77/mail read\u00a7f para ver seu email.
hatRemoved=\u00a7eYour hat has been removed.
banFormat=Banned: {0}
moveSpeed=\u00a77Set {0} speed to {1} for {2}.
walking=walking

View file

@ -414,24 +414,30 @@ weatherStorm=\u00a77Du har st\u00e4llt in v\u00e4dret till storm i {0}
weatherStormFor=\u00a77Du har st\u00e4llt in v\u00e4dret till storm i {0} f\u00f6r {1} sekunder
weatherSun=\u00a77Du har st\u00e4llt in v\u00e4dret till sol i {0}
weatherSunFor=\u00a77Du har st\u00e4llt in v\u00e4dret till sol i {0} f\u00f6r {1} sekunder
whoisBanned=\u00a79 - Bannade spelare: {0}
whoisExp=\u00a79 - Erfarenhet: {0} (Niv\u00e5 {1})
whoisGamemode=\u00a79 - Spell\u00e4ge: {0}
whoisGeoLocation=\u00a79 - Plats: {0}
whoisGod=\u00a79 - Od\u00f6dlighet: {0}
whoisHealth=\u00a79 - H\u00e4lsa: {0}/20
whoisIPAddress=\u00a79 - IP-Adress: {0}
whoisIs={0} \u00e4r {1}
whoisJail=\u00a79 - F\u00e4ngelse: {0}
whoisLocation=\u00a79 - Plats: ({0}, {1}, {2}, {3})
whoisMoney=\u00a79 - Pengar: {0}
whoisOP=\u00a79 - Operat\u00f6rer: {0}
whoisStatusAvailable=\u00a79 - Status: Tillg\u00e4nglig
whoisStatusAway=\u00a79 - Status: \u00a7cBorta\u00a7f
whoisBanned=\u00a76 - Banned:\u00a7f {0}
whoisExp=\u00a76 - Exp:\u00a7f {0} (Level {1})
whoisGamemode=\u00a76 - Gamemode:\u00a7f {0}
whoisGeoLocation=\u00a76 - Location:\u00a7f {0}
whoisGod=\u00a76 - God mode:\u00a7f {0}
whoisHealth=\u00a76 - Health:\u00a7f {0}/20
whoisIPAddress=\u00a76 - IP Address:\u00a7f {0}
whoisJail=\u00a76 - Jail:\u00a7f {0}
whoisLocation=\u00a76 - Location:\u00a7f ({0}, {1}, {2}, {3})
whoisMoney=\u00a76 - Money:\u00a7f {0}
worth=\u00a77Stapeln med {0} ({2} objekt) \u00e4r v\u00e4rd \u00a7c{1}\u00a77 ({3} styck)
worthMeta=\u00a77Stapeln med {0} av typ {1} ({3} objekt) \u00e4r v\u00e4rd \u00a7c{2}\u00a77 ({4} styck)
worthSet=V\u00e4rdet inst\u00e4llt
year=\u00e5r
years=\u00e5r
youAreHealed=\u00a77Du har blivit l\u00e4kt.
youHaveNewMail=\u00a7cDu har {0} meddelanden!\u00a7f Skriv \u00a77/mail read\u00a7f f\u00f6r att l\u00e4sa dina meddelanden.
youHaveNewMail=\u00a7cDu har {0} meddelanden!\u00a7f Skriv \u00a77/mail read\u00a7f f\u00f6r att l\u00e4sa dina meddelanden.
moveSpeed=\u00a77Set {0} speed to {1} for {2}.
whoisMuted=\u00a76 - Muted:\u00a7f {0}
whoisNick=\u00a76 - Nick:\u00a7f {0}
whoisOp=\u00a76 - OP:\u00a7f {0}
whoisTop=\u00a76 ====== WhoIs:\u00a7f {0} \u00a76======
whoisAFK=\u00a76 - AFK:\u00a7f {0}
whoisFly=\u00a76 - Fly mode:\u00a7f {0} ({1})
hatRemoved=\u00a7eYour hat has been removed.
banFormat=Banned: {0}
walking=walking