Files
src
build.gradle
Code
5 257
src/main/java/com/commandspy/CommandSpyPlugin.java
package com.commandspy;
import com.commandspy.commands.SpyCommand;
import com.commandspy.listeners.SpyListener;
import lombok.Getter;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class CommandSpyPlugin extends JavaPlugin {
@Getter
private static CommandSpyPlugin instance;
@Getter
private final Map<UUID, Boolean> toggleMap = new HashMap<>();
private final MiniMessage miniMessage = MiniMessage.miniMessage();
@Override
public void onEnable() {
instance = this;
getServer().getPluginManager().registerEvents(new SpyListener(this), this);
SpyCommand spyCommand = new SpyCommand(this);
getCommand("spy").setExecutor(spyCommand);
getCommand("spy").setTabCompleter(spyCommand);
startBroadcaster();
getLogger().info("CommandSpy enabled.");
}
@Override
public void onDisable() {
getLogger().info("CommandSpy disabled.");
}
private void startBroadcaster() {
long intervalTicks = 20L * 60 * 5;
Bukkit.getScheduler().runTaskTimer(this, () -> {
Component tip = miniMessage.deserialize(
"<gradient:#00c6ff:#0072ff><bold>Server Tip</bold></gradient> <grey>»</grey> <white>Use <aqua>/spy toggle</aqua> to manage your command spy alerts.</white>"
);
Bukkit.broadcast(tip);
}, intervalTicks, intervalTicks);
}
public MiniMessage getMiniMessage() {
return miniMessage;
}
}