Skip to content

Commit

Permalink
Merge pull request #1 from LemonGamingLtd/LC-960
Browse files Browse the repository at this point in the history
Add support for Folia
  • Loading branch information
NahuLD authored Jul 19, 2023
2 parents 03dabdf + d06f390 commit 33e8f06
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
24 changes: 24 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>devmart-other</id>
<url>https://nexuslite.gcnt.net/repos/other/</url>
</repository>
</repositories>

<dependencies>
Expand Down Expand Up @@ -138,6 +142,12 @@
<version>1.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.tcoded</groupId>
<artifactId>FoliaLib</artifactId>
<version>0.2.3</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -207,6 +217,20 @@
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
8 changes: 5 additions & 3 deletions src/main/java/org/kitteh/vanish/VanishManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import java.util.Random;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

import org.kitteh.vanish.nms.EntityCollideAlterer;
import org.kitteh.vanish.nms.ModernEntityCollideAlterer;
import org.kitteh.vanish.nms.v1_8_8_EntityCollideAlterer;
Expand Down Expand Up @@ -105,7 +107,7 @@ public VanishManager(final @NonNull VanishPlugin plugin) {
this.announceManipulator = new VanishAnnounceManipulator(this.plugin);

this.showPlayer = new ShowPlayerHandler(this.plugin);
this.plugin.getServer().getScheduler().scheduleSyncRepeatingTask(this.plugin, this.showPlayer, 4, 4);
plugin.getScheduler().getImpl().runTimer(this.showPlayer, 250L, 250L, TimeUnit.MILLISECONDS);

try {
Class.forName("org.bukkit.NamespacedKey");
Expand Down Expand Up @@ -399,10 +401,10 @@ private void effectBats(final @NonNull Location location) {
batty.add(location.getWorld().spawnEntity(location, EntityType.BAT).getUniqueId());
}
this.bats.addAll(batty);
this.plugin.getServer().getScheduler().runTaskLater(this.plugin, () -> {
this.plugin.getScheduler().getImpl().runAtLocationLater(location, () -> {
VanishManager.this.effectBatsCleanup(location.getWorld(), batty);
VanishManager.this.bats.removeAll(batty);
}, 3 * 20);
}, 3L, TimeUnit.SECONDS);
}

private void effectBatsCleanup(@NonNull World world, @NonNull Set<UUID> bats) {
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/org/kitteh/vanish/VanishPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package org.kitteh.vanish;

import com.tcoded.folialib.FoliaLib;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand All @@ -42,6 +43,9 @@
import java.util.HashSet;

public final class VanishPlugin extends JavaPlugin implements Listener {

private FoliaLib scheduler;

private final HashSet<String> haveInventoriesOpen = new HashSet<>();
private final HookManager hookManager = new HookManager(this);
private VanishManager manager;
Expand Down Expand Up @@ -205,6 +209,8 @@ public void onDisable() {

@Override
public void onEnable() {
scheduler = new FoliaLib(this);

this.setInstance(this);

// Thanks, PaperLib
Expand Down Expand Up @@ -303,4 +309,13 @@ public void reload() {
private void setInstance(@Nullable VanishPlugin plugin) {
org.kitteh.vanish.staticaccess.VanishNoPacket.setInstance(plugin);
}

/**
* Get the scheduler instance.
*
* @return {@link FoliaLib} instance.
*/
public FoliaLib getScheduler() {
return scheduler;
}
}
1 change: 1 addition & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ author: mbaxter
description: Vanish for the distinguished admin
dev-url: https://dev.bukkit.org/projects/vanish
api-version: 1.13
folia-supported: true
commands:
vanish:
description: poof
Expand Down

0 comments on commit 33e8f06

Please sign in to comment.