Go to file
2024-10-12 15:22:35 +08:00
.idea 修复了cui在1.21下的报错问题 2024-10-09 14:17:36 +08:00
core 修复了在1.21+版本下无法打开铁砧文本UI的问题 2024-10-12 15:22:35 +08:00
v1_20_1 修复了在1.21+版本下无法打开铁砧文本UI的问题 2024-10-12 15:22:35 +08:00
v1_21 修复了在1.21+版本下无法打开铁砧文本UI的问题 2024-10-12 15:22:35 +08:00
.gitignore
build.gradle.kts 修复了在1.21+版本下无法打开铁砧文本UI的问题 2024-10-12 15:22:35 +08:00
gradle.properties prepare basic 2024-10-08 18:13:18 +08:00
gradlew 完成基础功能迁移 2024-10-08 21:27:19 +08:00
gradlew.bat 完成基础功能迁移 2024-10-08 21:27:19 +08:00
README.md 更新 readme 2024-07-04 14:10:24 +08:00
settings.gradle.kts 完成基础功能迁移 2024-10-08 21:27:19 +08:00

MinecraftPluginUtils

Usage

Maven

<repositories>
    <repository>
        <id>lunadeer-repo</id>
        <url>https://ssl.lunadeer.cn:14454/repository/maven-snapshots/</url>
    </repository>
</repositories>

<dependencies>
<dependency>
    <groupId>cn.lunadeer</groupId>
    <artifactId>MinecraftPluginUtils</artifactId>
    <version>1.3.4-SNAPSHOT</version>
</dependency>
</dependencies>

Gradle

repositories {
    maven {
        url 'https://ssl.lunadeer.cn:14454/repository/maven-snapshots/'
    }
}

dependencies {
    implementation 'cn.lunadeer:MinecraftPluginUtils:1.3.0-SNAPSHOT'
}
import cn.lunadeer.MinecraftPluginUtils

Example

Logger

import cn.lunadeer.minecraftpluginutils.XLogger;

public final class YourPlugin extends JavaPlugin {
    @Override
    public void onEnable() {
        new XLogger(this);      // Initialize the logger with the plugin instance once

        XLogger.setDebug(true); // Enable debug mode if needed

        XLogger.info("Hello, world!");  // Call the static method
        XLogger.warn("This is a %s", "warning");    // Call the static method with format
    }
}

Notification

import cn.lunadeer.minecraftpluginutils.Notification;

public final class YourPlugin extends JavaPlugin {
    @Override
    public void onEnable() {
        new Notification(this); // Initialize the notification with the plugin instance once

        Bukkit.getPluginManager().registerEvents(new PlayerEvents(), this);
    }


    public class PlayerEvents implements Listener {
        @EventHandler
        public void onPlayerJoin(PlayerJoinEvent event) {
            Notification.info(event.getPlayer(), "Welcome to the server!"); // Send a notification to the player
            Notification.all("Greetings from %s!", event.getPlayer().getName()); // Send a notification to all players
        }
    }
}

Scheduler

import cn.lunadeer.minecraftpluginutils.Scheduler;

public final class YourPlugin extends JavaPlugin {
    @Override
    public void onEnable() {
        new Scheduler(this); // Initialize the scheduler with the plugin instance once

        Scheduler.runTaskLater(() -> {
            XLogger.info("Hello, world!");  // Call the static method
        }, 20L);    // Delay 20 ticks
    }
    
    @Override
    public void onDisable() {
        Scheduler.cancelAll(); // Cancel all tasks to prevent memory leaks
    }
}