Skip to content

这是一个包装库,提供各种方法来让你的插件同时适配bukkit和folia核心(This is a wrapper library that provides various ways to adapt your plugin to both the bukkit and folia cores.)

License

Notifications You must be signed in to change notification settings

handyplus/FoliaLib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FoliaLib

同时适配Folia和bukkit核心

使用方法(本jar已经发布到maven中央仓库)

Maven Central

首先: Folia要求 在plugin.yml 中添加配置 folia-supported: true

  1. maven引入

     <dependency>
         <groupId>cn.handyplus.lib.adapter</groupId>
         <artifactId>FoliaLib</artifactId>
         <version>最新版本</version>
     </dependency>
  2. 初始化;

    public class MyPlugin extends JavaPlugin {
        @Override
        public void onEnable() {
            // 初始化
            HandySchedulerUtil.init(this);
        }
    }

使用示例

// 同步方法
public void test1(Player player) {
HandySchedulerUtil.runTask(() -> {
   // 执行方法
});
}

// 异步方法
public void test2() {
HandySchedulerUtil.runTaskAsynchronously(() -> {
   // 执行方法
});
}

// 定时方法
public void test3() {
HandyRunnable handyRunnable = new HandyRunnable() {
   @Override
   public void run() {
      try {
         // 执行逻辑
      } catch (Exception ignored) {
         this.cancel();
      }
   }
};
HandySchedulerUtil.runTaskTimerAsynchronously(handyRunnable, 20 * 2, 20 * 60);
}

// TP方法
public void test4(Player player, Location location) {
PlayerSchedulerUtil.teleport(player, location);
}

// 执行命令
public void test5(Player player, String command) {
// 执行命令
PlayerSchedulerUtil.performCommand(player, command);
// 执行命令 指定同步
PlayerSchedulerUtil.syncPerformCommand(player, command);
// op身份执行命令
PlayerSchedulerUtil.performOpCommand(player, command);
// op身份执行命令 指定同步
PlayerSchedulerUtil.syncPerformOpCommand(player, command);
}

// 打开gui
public void test6(Player player, Inventory inv) {
PlayerSchedulerUtil.syncOpenInventory(player, inv);
}

// 关闭gui
public void test7(Player player, Inventory inv) {
PlayerSchedulerUtil.syncOpenInventory(player, inv);
}

javadoc

点击查看

建议

可以在issues提出

贡献者

Contrib

Star History

Star History Chart

About

这是一个包装库,提供各种方法来让你的插件同时适配bukkit和folia核心(This is a wrapper library that provides various ways to adapt your plugin to both the bukkit and folia cores.)

Topics

Resources

License

Stars

Watchers

Forks

Languages