Skip to content

Commit

Permalink
Ver 0.7.0-Beta1: Add support for Folia
Browse files Browse the repository at this point in the history
  • Loading branch information
Shiroiame-Kusu committed Aug 16, 2023
1 parent 17f9f9f commit 6daefd8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>icu.nyat.Kusunoki</groupId>
<artifactId>NyatLib</artifactId>
<version>0.6.0-Beta.1</version>
<version>0.7.0-Beta.1</version>

<packaging>jar</packaging>

Expand Down
27 changes: 25 additions & 2 deletions src/main/java/icu/nyat/kusunoki/NyatLibCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import io.papermc.lib.PaperLib;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
Expand All @@ -23,7 +25,7 @@
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

public class NyatLibCore {
public class NyatLibCore extends BukkitRunnable{
private final NyatLib plugin;
private final List<String> brand;
private final long period;
Expand All @@ -36,6 +38,7 @@ public class NyatLibCore {
private int index = 0;
private BukkitTask task;


public NyatLibCore(NyatLib plugin, List<String> brand, long period, ProtocolManager manager) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
this.plugin = plugin;

Expand All @@ -49,12 +52,32 @@ public NyatLibCore(NyatLib plugin, List<String> brand, long period, ProtocolMana
this.constructor_PacketPlayOutCustomPayload = class_PacketPlayOutCustomPayload.getConstructors()[0];
this.instance_MinecraftKey_Brand = class_PacketPlayOutCustomPayload.getField("a").get(null);


}

@Override
public void run() {
this.broadcast();
this.start();
}

public void start() {
task = Bukkit.getServer().getScheduler().runTaskTimer(this.plugin, new UpdateBrandTask(), period, period);
System.out.println(Bukkit.getServer().getName());
if(Bukkit.getServer().getName().equals("Folia")){
BukkitRunnable runnable = new BukkitRunnable() {
@Override
public void run() {
new UpdateBrandTask();
}
};
runnable.runTaskTimer(this.plugin,period,period);

}else{
task = Bukkit.getServer().getScheduler().runTaskTimer(this.plugin, new UpdateBrandTask(), period, period);
}



}

public void stop() {
Expand Down
17 changes: 10 additions & 7 deletions src/main/java/icu/nyat/kusunoki/NyatLibOnEnable.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,23 @@ public void Fetch(){
isProtocolLibInstalled = getServer().getPluginManager().isPluginEnabled("ProtocolLib");
String ProtocolLibVersionDescription = getServer().getPluginManager().getPlugin("ProtocolLib").toString();
String ProtocolLibVersion = ProtocolLibVersionDescription.substring(ProtocolLibVersionDescription.length() - 5);
if(ProtocolLibVersion.equals("5.0.0")){
if(ProtocolLibVersion.equals("5.1.0")){
Logger.logINFO("Seems that you have installed correct ProtocolLib version, continue...");
}else{
Logger.logWARN("You are using an untested ProtocolLib version!");
}
InputStream subversion = plugin.getResource("subversion.yml");
String SubMCVersion = getStringByInputStream(subversion);
Logger.logINFO("Check for network access......");
String Hitokoto = new HttpUtil().get("https://v1.hitokoto.cn/?encode=text&charset=utf-8&max_length=20");
if(Hitokoto == null){
Logger.logWARN("Cannot connect to Internet, Please check your network connection!");
}else{
Logger.logINFO("Daily Saying from Hitokoto: " + Hitokoto);
}
Thread FetchHitokoto = new Thread(() -> {
String Hitokoto = new HttpUtil().get("https://v1.hitokoto.cn/?encode=text&charset=utf-8&max_length=20");
if(Hitokoto == null){
Logger.logWARN("Cannot connect to Internet, Please check your network connection!");
}else{
Logger.logINFO("Daily Saying from Hitokoto: " + Hitokoto);
}
});

Logger.logINFO("§3Current NyatWork Version is: " + SubMCVersion);
}
}

0 comments on commit 6daefd8

Please sign in to comment.