mirror of
https://github.com/kaboomserver/extras.git
synced 2024-05-16 01:41:18 +00:00
a1007853dd
* Replace string concatenation with appending text
* Fix inconsistent indentation
oops
* indentation
i forgor 💀
66 lines
2.2 KiB
Java
66 lines
2.2 KiB
Java
package pw.kaboom.extras.commands;
|
|
|
|
import net.kyori.adventure.text.Component;
|
|
import net.kyori.adventure.text.format.NamedTextColor;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.Particle;
|
|
import org.bukkit.Sound;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandExecutor;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
public final class CommandJumpscare implements CommandExecutor {
|
|
private void createJumpscare(final Player player) {
|
|
final int count = 4;
|
|
player.spawnParticle(Particle.MOB_APPEARANCE, player.getLocation(), count);
|
|
|
|
final int maxIterator = 10;
|
|
for (int i = 0; i <= maxIterator; i++) {
|
|
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_SCREAM, 1, 0);
|
|
}
|
|
}
|
|
|
|
public boolean onCommand(final @Nonnull CommandSender sender,
|
|
final @Nonnull Command command,
|
|
final @Nonnull String label,
|
|
final String[] args) {
|
|
if (args.length == 0) {
|
|
sender.sendMessage(Component
|
|
.text("Usage: /" + label + " <player>",
|
|
NamedTextColor.RED));
|
|
return true;
|
|
}
|
|
|
|
if (args[0].equals("*") || args[0].equals("**")) {
|
|
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
|
createJumpscare(onlinePlayer);
|
|
}
|
|
sender.sendMessage(Component
|
|
.text("Successfully created jumpscare for every player"));
|
|
return true;
|
|
}
|
|
|
|
final Player target = Bukkit.getPlayer(args[0]);
|
|
|
|
if (target == null) {
|
|
sender.sendMessage(
|
|
Component.text("Player \"")
|
|
.append(Component.text(args[0]))
|
|
.append(Component.text("\" not found"))
|
|
);
|
|
return true;
|
|
}
|
|
|
|
createJumpscare(target);
|
|
sender.sendMessage(
|
|
Component.text("Successfully created jumpscare for player \"")
|
|
.append(Component.text(target.getName()))
|
|
.append(Component.text("\""))
|
|
);
|
|
return true;
|
|
}
|
|
}
|