Files
src
build.gradle
settings.gradle
Code
4 86
src/main/java/me/example/lplugin/LPlugin.java
package me.example.lplugin;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.title.Title;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import java.time.Duration;
public class LPlugin extends JavaPlugin implements CommandExecutor {
@Override
public void onEnable() {
getCommand("l").setExecutor(this);
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length < 1) {
sender.sendMessage(Component.text("Usage: /L <player>", NamedTextColor.RED));
return true;
}
Player target = Bukkit.getPlayerExact(args[0]);
if (target == null) {
sender.sendMessage(Component.text("Player not found.", NamedTextColor.RED));
return true;
}
Title title = Title.title(
Component.text("L", NamedTextColor.RED),
Component.text("NOOB", NamedTextColor.RED),
Title.Times.times(Duration.ZERO, Duration.ofMillis(700), Duration.ZERO)
);
new BukkitRunnable() {
int ticks = 0;
@Override
public void run() {
if (!target.isOnline() || ticks >= 2400) {
target.clearTitle();
cancel();
return;
}
target.showTitle(title);
ticks += 10;
}
}.runTaskTimer(this, 0L, 10L);
return true;
}
}