Refactor: clean up plugin.yml and main class to classic skeleton
This commit is contained in:
@@ -1,87 +1,25 @@
|
|||||||
package fr.luc.gamingcore;
|
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.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
public final class GamingCore extends JavaPlugin {
|
public final class GamingCore extends JavaPlugin {
|
||||||
|
|
||||||
private static GamingCore instance;
|
private static GamingCore instance;
|
||||||
private BukkitAudiences adventure;
|
|
||||||
private final MiniMessage miniMessage = MiniMessage.miniMessage();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
// Initialize Adventure audience platform
|
|
||||||
this.adventure = BukkitAudiences.create(this);
|
|
||||||
|
|
||||||
// Save default config if not exists
|
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
|
|
||||||
getLogger().log(Level.INFO, "========================================");
|
getLogger().info("GamingCore a ete active avec succes !");
|
||||||
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, "========================================");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
if (this.adventure != null) {
|
getLogger().info("GamingCore a ete desactive !");
|
||||||
this.adventure.close();
|
|
||||||
this.adventure = null;
|
|
||||||
}
|
|
||||||
getLogger().info("GamingCore désactivé.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GamingCore getInstance() {
|
public static GamingCore getInstance() {
|
||||||
return instance;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,6 @@
|
|||||||
name: ${name}
|
name: GamingCore
|
||||||
version: ${version}
|
version: 1.0.0
|
||||||
main: fr.luc.gamingcore.GamingCore
|
main: fr.luc.gamingcore.GamingCore
|
||||||
api-version: '1.16'
|
api-version: '1.16'
|
||||||
author: Luc
|
author: Luc
|
||||||
description: ${description}
|
description: GamingCore Plugin
|
||||||
|
|
||||||
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
|
|
||||||
|
|||||||
Reference in New Issue
Block a user