2015-10-19 17:43:46 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.commands;
|
2012-12-08 00:37:27 +00:00
|
|
|
|
2015-11-15 23:32:04 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.PlayerRank;
|
2012-12-08 00:37:27 +00:00
|
|
|
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;
|
2013-07-27 21:49:25 +00:00
|
|
|
import org.bukkit.scheduler.BukkitRunnable;
|
2012-12-08 00:37:27 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
@CommandPermissions(level = PlayerRank.SENIOR_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
2013-04-10 02:05:24 +00:00
|
|
|
@CommandParameters(description = "Make some noise.", usage = "/<command>")
|
2015-10-19 17:43:46 +00:00
|
|
|
public class Command_deafen extends FreedomCommand
|
2012-12-08 00:37:27 +00:00
|
|
|
{
|
2015-11-22 18:26:47 +00:00
|
|
|
|
2012-12-08 00:37:27 +00:00
|
|
|
private static final Random random = new Random();
|
|
|
|
public static final double STEPS = 10.0;
|
|
|
|
|
|
|
|
@Override
|
2015-11-22 18:26:47 +00:00
|
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
2012-12-08 00:37:27 +00:00
|
|
|
{
|
2013-08-14 14:01:42 +00:00
|
|
|
for (final Player player : server.getOnlinePlayers())
|
2012-12-08 00:37:27 +00:00
|
|
|
{
|
|
|
|
for (double percent = 0.0; percent <= 1.0; percent += (1.0 / STEPS))
|
|
|
|
{
|
|
|
|
final float pitch = (float) (percent * 2.0);
|
|
|
|
|
2013-07-27 21:49:25 +00:00
|
|
|
new BukkitRunnable()
|
2012-12-08 00:37:27 +00:00
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void run()
|
|
|
|
{
|
2013-08-14 14:01:42 +00:00
|
|
|
player.playSound(randomOffset(player.getLocation(), 5.0), Sound.values()[random.nextInt(Sound.values().length)], 100.0f, pitch);
|
2012-12-08 00:37:27 +00:00
|
|
|
}
|
2013-07-27 21:49:25 +00:00
|
|
|
}.runTaskLater(plugin, Math.round(20.0 * percent * 2.0));
|
2012-12-08 00:37:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
}
|