summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-08-26 19:35:39 +0100
committerKHobbits <rob@khobbits.co.uk>2012-08-26 19:35:39 +0100
commit65741403e01db3b92d0bf7625c0b096b1ddfdaf6 (patch)
tree334a6a83bc6b3ce503d5507b60b4e3bd48507166
parent2b6d41ac5fbfbf6e2f114c302545abff89a35938 (diff)
downloadEssentials-65741403e01db3b92d0bf7625c0b096b1ddfdaf6.tar
Essentials-65741403e01db3b92d0bf7625c0b096b1ddfdaf6.tar.gz
Essentials-65741403e01db3b92d0bf7625c0b096b1ddfdaf6.tar.lz
Essentials-65741403e01db3b92d0bf7625c0b096b1ddfdaf6.tar.xz
Essentials-65741403e01db3b92d0bf7625c0b096b1ddfdaf6.zip
New command /speed [walk|fly] <speed> [player]
New permissions: essentials.speed = access to the command essentials.speed.others = ability to change the speed of another player essentials.speed.bypass = override max speed limits in config.yml New config options: max-fly-speed max-walk-speed
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandspeed.java35
-rw-r--r--Essentials/src/plugin.yml4
2 files changed, 23 insertions, 16 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspeed.java b/Essentials/src/com/earth2me/essentials/commands/Commandspeed.java
index 31911ca6c..c7b44dc68 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandspeed.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandspeed.java
@@ -23,7 +23,7 @@ public class Commandspeed extends EssentialsCommand
}
final boolean isFly = isFlyMode(args[0]);
final float speed = getMoveSpeed(args[1]);
- speedOtherPlayers(server, sender, isFly, speed, args[2]);
+ speedOtherPlayers(server, sender, isFly, true, speed, args[2]);
}
@Override
@@ -36,48 +36,47 @@ public class Commandspeed extends EssentialsCommand
boolean isFly;
float speed;
+ boolean isBypass = user.isAuthorized("essentials.speed.bypass");
if (args.length == 1)
{
isFly = user.isFlying();
speed = getMoveSpeed(args[0]);
}
- else if (args.length == 2)
- {
- isFly = isFlyMode(args[0]);
- speed = getMoveSpeed(args[1]);
- }
else
{
isFly = isFlyMode(args[0]);
speed = getMoveSpeed(args[1]);
- speedOtherPlayers(server, user, isFly, speed, args[2]);
- return;
+ if (args.length > 2 && user.isAuthorized("essentials.speed.others"))
+ {
+ speedOtherPlayers(server, user, isFly, isBypass, speed, args[2]);
+ return;
+ }
}
if (isFly)
{
- user.setFlySpeed(getRealMoveSpeed(speed, isFly));
+ user.setFlySpeed(getRealMoveSpeed(speed, isFly, isBypass));
user.sendMessage(_("moveSpeed", _("flying"), speed, user.getDisplayName()));
}
else
{
- user.setWalkSpeed(getRealMoveSpeed(speed, isFly));
+ user.setWalkSpeed(getRealMoveSpeed(speed, isFly, isBypass));
user.sendMessage(_("moveSpeed", _("walking"), speed, user.getDisplayName()));
}
}
- private void speedOtherPlayers(final Server server, final CommandSender sender, final boolean isFly, final float speed, final String target)
+ private void speedOtherPlayers(final Server server, final CommandSender sender, final boolean isFly, final boolean isBypass, final float speed, final String target)
{
for (Player matchPlayer : server.matchPlayer(target))
{
if (isFly)
{
- matchPlayer.setFlySpeed(getRealMoveSpeed(speed, isFly));
+ matchPlayer.setFlySpeed(getRealMoveSpeed(speed, isFly, isBypass));
sender.sendMessage(_("moveSpeed", _("flying"), speed, matchPlayer.getDisplayName()));
}
else
{
- matchPlayer.setWalkSpeed(getRealMoveSpeed(speed, isFly));
+ matchPlayer.setWalkSpeed(getRealMoveSpeed(speed, isFly, isBypass));
sender.sendMessage(_("moveSpeed", _("walking"), speed, matchPlayer.getDisplayName()));
}
}
@@ -124,10 +123,14 @@ public class Commandspeed extends EssentialsCommand
return userSpeed;
}
- private float getRealMoveSpeed(final float userSpeed, final boolean isFly)
+ private float getRealMoveSpeed(final float userSpeed, final boolean isFly, final boolean isBypass)
{
- float maxSpeed = (float)(isFly ? ess.getSettings().getMaxFlySpeed() : ess.getSettings().getMaxWalkSpeed());
- float defaultSpeed = isFly ? 0.1f : 0.2f;
+ final float defaultSpeed = isFly ? 0.1f : 0.2f;
+ float maxSpeed = 1f;
+ if (!isBypass)
+ {
+ maxSpeed = (float)(isFly ? ess.getSettings().getMaxFlySpeed() : ess.getSettings().getMaxWalkSpeed());
+ }
if (userSpeed < 1f)
{
diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml
index aa16a80f1..b04d59fa7 100644
--- a/Essentials/src/plugin.yml
+++ b/Essentials/src/plugin.yml
@@ -326,6 +326,10 @@ commands:
description: Spawns a mob.
usage: /<command> <mob>[:data][,<mount>[:data]] [amount] [player]
aliases: [espawnmob,mob,emob]
+ speed:
+ description: Change your speed limits
+ usage: /<command> [fly|walk] [speed] [player]
+ aliases: [flyspeed,walkspeed,fspeed,wspeed,eflyspeed,ewalkspeed,efspeed,ewspeed,espeed]
sudo:
description: Make another user perform a command.
usage: /<command> <player> <command [args]>