Skip to content

Commit

Permalink
Add Folia Support
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreeam-qwq committed Oct 26, 2023
1 parent 5081d51 commit 91a7e89
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
26 changes: 19 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@
</dependencyReducedPomLocation>
<relocations>
<relocation>
<pattern>io.papermc.lib</pattern>
<shadedPattern>org.surf.shade.paperlib</shadedPattern>
<pattern>org.bstats</pattern>
<shadedPattern>org.surf.libs.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>com.tcoded.folialib</pattern>
<shadedPattern>org.surf.libs.folialib</shadedPattern>
</relocation>
</relocations>
</configuration>
Expand All @@ -64,20 +68,22 @@
</build>

<repositories>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<!-- PaperMC -->
<repository>
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<!-- CodeMC -->
<!-- NBT-API -->
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.org/repository/maven-public/</url>
<layout>default</layout>
</repository>
<!-- FoliaLib -->
<repository>
<id>devmart-other</id>
<url>https://nexuslite.gcnt.net/repos/other/</url>
</repository>
</repositories>
<dependencies>
<dependency>
Expand All @@ -98,6 +104,12 @@
<version>3.0.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.tcoded</groupId>
<artifactId>FoliaLib</artifactId>
<version>0.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api-plugin</artifactId>
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/org/surf/Main.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.surf;

import com.tcoded.folialib.FoliaLib;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.Material;
Expand All @@ -26,8 +27,6 @@
import org.surf.util.SecondPassEvent;
import org.surf.util.TenSecondPassEvent;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class Main extends JavaPlugin {
Expand All @@ -40,7 +39,7 @@ public static Main getInstance() {

private final PluginManager pluginManager = getServer().getPluginManager();

private final ScheduledExecutorService service = Executors.newScheduledThreadPool(4);
public FoliaLib foliaLib = new FoliaLib(this);

private final CommandHandler commandHandler = new CommandHandler(this);

Expand All @@ -59,12 +58,12 @@ public void onEnable() {
// register event
this.registerEvents();
if (ConfigCache.AntiillegalDeleteStackedTotem) {
Bukkit.getServer().getScheduler().runTaskTimer(this, () -> Bukkit.getWorlds().forEach(b -> b.getPlayers().forEach(e -> e.getInventory().forEach(this::revert))), 0L, 20L);
foliaLib.getImpl().runTimer(() -> Bukkit.getWorlds().forEach(b -> b.getPlayers().forEach(e -> e.getInventory().forEach(this::revert))), 0L, 20L);
}
// Server specific events
service.scheduleAtFixedRate(() -> pluginManager.callEvent(new SecondPassEvent()), 1, 1, TimeUnit.SECONDS);
service.scheduleAtFixedRate(() -> pluginManager.callEvent(new TenSecondPassEvent()), 1, 10, TimeUnit.SECONDS);
getLogger().info("Surf enabled. By Dreeam.");
foliaLib.getImpl().runTimerAsync(() -> pluginManager.callEvent(new SecondPassEvent()), 1, 1, TimeUnit.SECONDS);
foliaLib.getImpl().runTimerAsync(() -> pluginManager.callEvent(new TenSecondPassEvent()), 1, 10, TimeUnit.SECONDS);
getLogger().info("Surf Enabled. By Dreeam.");
}

public void registerEvents() {
Expand All @@ -81,7 +80,7 @@ public void registerEvents() {
}
pluginManager.registerEvents(new BucketEvent(), this);
pluginManager.registerEvents(new MinecartLag(this), this);
// pluginManager.registerEvents(new ChestLagFix(this), this);
//pluginManager.registerEvents(new ChestLagFix(this), this);
pluginManager.registerEvents(new DispenserCrash(), this);
pluginManager.registerEvents(new ConnectionEvent(), this);
// AntiIllegal events
Expand Down

0 comments on commit 91a7e89

Please sign in to comment.