HikariLib 图标

HikariLib

作者:rebot | 分类:模组

价格:0 墨喵币 下载量:0 点赞:0 版本 1.3.1
本资源为搬运资源,原资源地址: https://modrinth.com/mod/hikarilib
资源信息

Minecraft 版本: 1.20 1.20.1 1.20.2 1.20.3 1.20.4 1.20.5 1.20.6 1.21 1.21.1 1.21.2 1.21.3 1.21.4 1.21.5 1.21.6 1.21.7 1.21.8 1.21.9 1.21.10 1.21.11 26.1 26.1.1 26.1.2

平台: folia paper purpur

标签: library management utility

资源介绍

A utility library extracted from Paper plugin development — so you don't rewrite the same boilerplate in every plugin.

Repository

<repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
</repository>

Dependency

<dependency>
    <groupId>com.github.Hikari16665</groupId>
    <artifactId>HikariLib</artifactId>
    <version>master-SNAPSHOT</version>
</dependency>

Requires Paper 1.21.1, Java 21.

What's inside

Menu system

Define menu layouts with a character matrix:

HikariMatrixDrawer drawer = new HikariMatrixDrawer(9)
    .addLine("XXX  XXXX")
    .addLine("  X  X  X")
    .addExplain('X', new ItemStack(Material.STONE), (event, slot, menu) -> {
        event.getWhoClicked().sendMessage("Clicked stone!");
    });

HikariMenu menu = new HikariMatrixDrawer.Builder()
    .withTitle("&6Example Menu")
    .withRows(3)
    .withDrawer(drawer)
    .build();

menu.open(player);

Implement HikariMenuDrawer if you need custom drawing logic.

Chat input

Ask a player a question and wait for their reply, with configurable timeout:

// Default 30-second timeout
ChatAsk.ask(player, "Enter your name:", name -> {
    player.sendMessage("Hello, " + name);
});

// 10-second timeout
ChatAsk.ask(player, "Enter the code:", code -> {
    // ...
}, 10000);

Database

Common DataBaseConnection interface. Both MySQL and SQLite come with HikariCP pooling built in:

DataBaseConnection db = new MySQLConnection("localhost", 3306, "mydb", "root", "pass", false);
// or new SQLiteConnection("plugins/xxx/data.db")

db.query("SELECT * FROM users WHERE age > ?", 18);
db.insert("users", null, "Alice", 25);

db.transaction(() -> {
    db.execute("UPDATE accounts SET balance = balance - 100 WHERE id = ?", 1);
    db.execute("UPDATE accounts SET balance = balance + 100 WHERE id = ?", 2);
    return null;
});

Scheduler

Write once, runs on both Bukkit and Folia:

HikariScheduler.addTimedTask(20, () -> player.sendMessage("Hello"), false);
HikariScheduler.addRepeatingTask(20, () -> player.sendMessage("Tick"), false);

ItemStack builder

Chainable item construction:

HikariItemStack item = new HikariItemStack(Material.DIAMOND_SWORD)
    .setName("&6Legendary Sword")
    .setLore(List.of("&7A sword of legend"))
    .setCustomModelData(1001);

player.getInventory().addItem(item.getItem());

Reflection

One-liner reflection calls:

ReflectionUtil.setField(obj, "someField", newValue);
String result = ReflectionUtil.callMethod(String.class, obj, "methodName", arg1, arg2);

Location & teleport

// Get the chunk a location belongs to
Chunk chunk = LocationUtils.getChunk(location);

// Get a block position within a chunk (0-15 offsets)
Location loc = LocationUtils.getChunkOffsetLocation(chunk, 5, 64, 5);

// Teleport a player (always async on Folia, configurable on Bukkit)
LocationUtils.teleportPlayer(player, targetLocation);       // sync
LocationUtils.teleportPlayer(player, targetLocation, true);  // async on Bukkit

Entity utilities

Run a task on an entity's scheduler. On Folia it goes through the entity scheduler automatically:

EntityUtil.runAsEntity(player, () -> {
    player.openInventory(menu);
});

Expiring HashMap

Entries auto-expire after the configured duration — no manual cleanup needed:

// 60-second TTL
ExpiringHashMap<UUID, String> cache = new ExpiringHashMap<>(60000);
cache.put(playerId, "some data");

String data = cache.get(playerId);  // not expired yet — returns the data

String gone = cache.get(playerId);  // 60 seconds later — returns null

// Shut down the background cleanup thread when done
cache.close();

Server environment

Detect the server platform so downstream code doesn't have to branch:

if (ServerEnvironment.isFolia()) {
    // use Folia-specific scheduling
} else {
    // use Bukkit scheduling
}

String version = ServerEnvironment.getMinecraftVersion();
String bukkitVersion = ServerEnvironment.getBukkitVersion();
String name = ServerEnvironment.getName();

// Full server metadata
ServerEnvironment.ServerMeta meta = ServerEnvironment.getMeta();
System.out.println(meta.getMotd());
System.out.println(meta.getMaxPlayers());

Build

mvn clean package

Install locally

mvn install

Then drop the jar into your Paper server's plugins/ directory.

License

MIT

下载太慢?试试 墨喵加速站,支持 Modrinth 和外网直链高速下载! 用的人越多,下载的越快!
下载与版本
评论(0)
登录 后发表评论。

暂无评论,抢个沙发吧~

举报此资源

请登录后举报

🔥 相关推荐
A&S Wither Skeleton - Emissive Eyes

价格:0 墨喵币
下载量:0

查看详情
[SCP] | Secure Craft Protect

价格:0 墨喵币
下载量:0

查看详情
Vykket’s Zombie Mobs

价格:0 墨喵币
下载量:0

查看详情
ExtendedHotbarRebared

价格:0 墨喵币
下载量:0

查看详情