Refactor: clean up plugin.yml and main class to classic skeleton

This commit is contained in:
2026-08-18 21:51:23 +02:00
parent 9be2e2dccf
commit 115912603f
2 changed files with 6 additions and 82 deletions
@@ -1,87 +1,25 @@
package fr.luc.gamingcore;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import java.util.logging.Level;
public final class GamingCore extends JavaPlugin {
private static GamingCore instance;
private BukkitAudiences adventure;
private final MiniMessage miniMessage = MiniMessage.miniMessage();
@Override
public void onEnable() {
instance = this;
// Initialize Adventure audience platform
this.adventure = BukkitAudiences.create(this);
// Save default config if not exists
saveDefaultConfig();
getLogger().log(Level.INFO, "========================================");
getLogger().log(Level.INFO, " GamingCore v" + getDescription().getVersion() + " active avec succes !");
getLogger().log(Level.INFO, " Compatibilite: 1.16.5 - 1.20+");
getLogger().log(Level.INFO, "========================================");
getLogger().info("GamingCore a ete active avec succes !");
}
@Override
public void onDisable() {
if (this.adventure != null) {
this.adventure.close();
this.adventure = null;
}
getLogger().info("GamingCore désactivé.");
getLogger().info("GamingCore a ete desactive !");
}
public static GamingCore getInstance() {
return instance;
}
public BukkitAudiences getAdventure() {
if (this.adventure == null) {
throw new IllegalStateException("Adventure audience platform is not initialized!");
}
return this.adventure;
}
public MiniMessage getMiniMessage() {
return miniMessage;
}
/**
* Send a MiniMessage formatted message with the prefix to any CommandSender
*/
public void sendMessage(CommandSender sender, String message) {
String prefix = getConfig().getString("prefix", "");
Component component = miniMessage.deserialize(prefix + message);
adventure.sender(sender).sendMessage(component);
}
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (command.getName().equalsIgnoreCase("gamingcore")) {
if (args.length > 0 && args[0].equalsIgnoreCase("reload")) {
if (!sender.hasPermission("gamingcore.admin")) {
sendMessage(sender, getConfig().getString("messages.no-permission", "<red>Permission refusée.</red>"));
return true;
}
reloadConfig();
sendMessage(sender, getConfig().getString("messages.reload-success", "<green>Configuration rechargée !</green>"));
return true;
}
sendMessage(sender, "<yellow>GamingCore</yellow> <gray>version " + getDescription().getVersion() + "</gray>");
sendMessage(sender, "<gray>Utilise <white>/gcore reload</white> pour recharger la configuration.</gray>");
return true;
}
return false;
}
}
+3 -17
View File
@@ -1,20 +1,6 @@
name: ${name}
version: ${version}
name: GamingCore
version: 1.0.0
main: fr.luc.gamingcore.GamingCore
api-version: '1.16'
author: Luc
description: ${description}
commands:
gamingcore:
description: Main command for GamingCore
aliases: [gcore, core]
permission: gamingcore.use
permissions:
gamingcore.use:
description: Allows use of basic gamingcore commands
default: op
gamingcore.admin:
description: Allows administrative access to gamingcore
default: op
description: GamingCore Plugin