mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Added /deafen
This commit is contained in:
parent
88000cd504
commit
0589ebcf48
@ -0,0 +1,48 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import java.util.Random;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = ADMIN_LEVEL.SENIOR, source = SOURCE_TYPE_ALLOWED.BOTH, block_host_console = true, ignore_permissions = false)
|
||||
public class Command_deafen extends TFM_Command
|
||||
{
|
||||
private static final Random random = new Random();
|
||||
public static final double STEPS = 10.0;
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
for (final Player p : server.getOnlinePlayers())
|
||||
{
|
||||
for (double percent = 0.0; percent <= 1.0; percent += (1.0 / STEPS))
|
||||
{
|
||||
final float pitch = (float) (percent * 2.0);
|
||||
|
||||
server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
p.playSound(randomOffset(p.getLocation(), 5.0), Sound.values()[random.nextInt(Sound.values().length)], 100.0f, pitch);
|
||||
}
|
||||
}, Math.round(20.0 * percent * 2.0));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Location randomOffset(Location a, double magnitude)
|
||||
{
|
||||
return a.clone().add(randomDoubleRange(-1.0, 1.0) * magnitude, randomDoubleRange(-1.0, 1.0) * magnitude, randomDoubleRange(-1.0, 1.0) * magnitude);
|
||||
}
|
||||
|
||||
private static Double randomDoubleRange(double min, double max)
|
||||
{
|
||||
return min + (random.nextDouble() * ((max - min) + 1.0));
|
||||
}
|
||||
}
|
@ -31,6 +31,9 @@ commands:
|
||||
csay:
|
||||
description: Telnet command - Send a chat message with chat formatting over telnet.
|
||||
usage: /<command> <message...>
|
||||
deafen:
|
||||
description: Senior Command - Make some noise.
|
||||
usage: /<command>
|
||||
deop:
|
||||
description: Superadmin command - Deop a player
|
||||
usage: /<command> <playername>
|
||||
|
Loading…
Reference in New Issue
Block a user