refactor: reset to minimal Main class with start/stop logs
This commit is contained in:
@@ -1,44 +0,0 @@
|
||||
package fr.luc.gamingcore;
|
||||
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import fr.luc.gamingcore.util.TextUtil;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public final class GamingCore extends JavaPlugin {
|
||||
|
||||
private static GamingCore instance;
|
||||
private RegionContainer regionContainer;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
saveDefaultConfig();
|
||||
|
||||
// Initialize Text Util prefix from config
|
||||
TextUtil.setPrefix(getConfig().getString("prefix", "<gradient:#00C9FF:#92FE9D>[GamingCore]</gradient> <dark_gray>»</dark_gray> <gray>"));
|
||||
|
||||
// Hook into WorldGuard
|
||||
try {
|
||||
this.regionContainer = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
getLogger().info("Connexion avec WorldGuard 7 etablie avec succes !");
|
||||
} catch (Throwable t) {
|
||||
getLogger().severe("Impossible de se connecter a WorldGuard : " + t.getMessage());
|
||||
}
|
||||
|
||||
getLogger().info("GamingCore a ete active avec succes !");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getLogger().info("GamingCore a ete desactive !");
|
||||
}
|
||||
|
||||
public static GamingCore getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public RegionContainer getRegionContainer() {
|
||||
return regionContainer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package fr.luc.gamingcore;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public final class Main extends JavaPlugin {
|
||||
|
||||
private static Main instance;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
getLogger().info("GamingCore a ete active avec succes !");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getLogger().info("GamingCore a ete desactive !");
|
||||
}
|
||||
|
||||
public static Main getInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package fr.luc.gamingcore.util;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public final class TextUtil {
|
||||
|
||||
private static final MiniMessage MINI_MESSAGE = MiniMessage.miniMessage();
|
||||
private static final LegacyComponentSerializer AMPERSAND_SERIALIZER = LegacyComponentSerializer.legacyAmpersand();
|
||||
|
||||
private static String prefix = "<gradient:#00C9FF:#92FE9D>[GamingCore]</gradient> <dark_gray>»</dark_gray> <gray>";
|
||||
|
||||
private TextUtil() {}
|
||||
|
||||
public static void setPrefix(String newPrefix) {
|
||||
if (newPrefix != null) {
|
||||
prefix = newPrefix;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a string formatted with MiniMessage or legacy & color codes into a Component.
|
||||
*/
|
||||
public static Component parse(String input) {
|
||||
if (input == null || input.isEmpty()) {
|
||||
return Component.empty();
|
||||
}
|
||||
String formatted = input.replace('§', '&');
|
||||
if (formatted.contains("&")) {
|
||||
return AMPERSAND_SERIALIZER.deserialize(formatted);
|
||||
}
|
||||
return MINI_MESSAGE.deserialize(input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a parsed message with prefix to a CommandSender (or Player).
|
||||
*/
|
||||
public static void sendMessage(CommandSender sender, String message) {
|
||||
if (sender == null || message == null) return;
|
||||
sender.sendMessage(parse(prefix + message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a parsed raw message without prefix to a CommandSender.
|
||||
*/
|
||||
public static void sendRawMessage(CommandSender sender, String message) {
|
||||
if (sender == null || message == null) return;
|
||||
sender.sendMessage(parse(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends an action bar message to a player.
|
||||
*/
|
||||
public static void sendActionBar(Player player, String message) {
|
||||
if (player == null || message == null) return;
|
||||
player.sendActionBar(parse(message));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
name: GamingCore
|
||||
version: 1.0.0
|
||||
main: fr.luc.gamingcore.GamingCore
|
||||
main: fr.luc.gamingcore.Main
|
||||
api-version: '1.16'
|
||||
author: Luc
|
||||
description: GamingCore Plugin
|
||||
@@ -10,3 +10,4 @@ softdepend:
|
||||
- WorldEdit
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user