Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
18 changes: 14 additions & 4 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

181 changes: 92 additions & 89 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions spigot/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
`java-library`
id("com.github.johnrengelman.shadow") version "7.1.2"
id("net.minecrell.plugin-yml.bukkit") version "0.5.2"
id("net.minecrell.plugin-yml.bukkit") version "0.6.0" // lowest version with folia-compatible in the plugin-yml is 0.6.0
}

val versionStr = (System.getenv("VERSION")?: "v1.0.0").removePrefix("v")
val versionStr = (System.getenv("VERSION")?: "v1.19.0").removePrefix("v")

group = "com.funniray.minimap"
version = versionStr
Expand Down Expand Up @@ -76,7 +76,8 @@ tasks {
bukkit {
name = "MinimapControl"
main = "com.funniray.minimap.spigot.SpigotMinimap"
authors = listOf("funniray")
authors = listOf("funniray", "Thowan")
foliaSupported = true
description = "Control minimap settings from server-side software"

apiVersion = "1.13"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public void onPluginMessageReceived(@NotNull String channel, @NotNull Player pla
public void onJoin(PlayerJoinEvent event) {
// The player join event is slightly too early. I unfortunately don't know an event that fires late enough for Xaeros to recognize the packet
// If anyone knows, please let me know
plugin.getServer().getScheduler().runTaskLater(plugin, ()->this.handlePlayerJoined(new SpigotPlayer(event.getPlayer())), 40L);
Player player = event.getPlayer();
plugin.getScheduler().runTaskLater(player, 40L, () -> this.handlePlayerJoined(new SpigotPlayer(player)));
}

@EventHandler
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.funniray.minimap.spigot;

import com.funniray.minimap.spigot.scheduler.SchedulerAdapter;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import org.bukkit.plugin.java.JavaPlugin;

public final class SpigotMinimap extends JavaPlugin {
private static SpigotMinimap instance;
private final SpigotMain main = new SpigotMain(this);
private final SchedulerAdapter scheduler = SchedulerAdapter.create(this);

public ViaHook viaHook;
public boolean viaHooked;
Expand Down Expand Up @@ -48,4 +50,5 @@ public void onDisable() {
public static SpigotMinimap getInstance() {
return instance;
}
public SchedulerAdapter getScheduler() {return scheduler;}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.kyori.adventure.platform.bukkit.MinecraftComponentSerializer;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent;

Expand All @@ -23,7 +22,8 @@ public SpigotPlayer(Player player) {

@Override
public void sendPluginMessage(byte[] message, String channel) {
Bukkit.getScheduler().runTask(SpigotMinimap.getInstance(), ()->nativePlayer.sendPluginMessage(SpigotMinimap.getInstance(), channel, message));
SpigotMinimap plugin = SpigotMinimap.getInstance();
plugin.getScheduler().runTask(nativePlayer, ()->nativePlayer.sendPluginMessage(plugin, channel, message));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.funniray.minimap.spigot.scheduler;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;

public final class BukkitSchedulerAdapter implements SchedulerAdapter {
private final Plugin plugin;

public BukkitSchedulerAdapter(Plugin plugin) {
this.plugin = plugin;
}

@Override
public void runTask(Player player, Runnable task) {
Bukkit.getScheduler().runTask(plugin, task);
}

@Override
public void runTaskLater(Player player, long delayTicks, Runnable task) {
Bukkit.getScheduler().runTaskLater(plugin, task, delayTicks);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.funniray.minimap.spigot.scheduler;

import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public final class FoliaSchedulerAdapter implements SchedulerAdapter {
private final Plugin plugin;

public FoliaSchedulerAdapter(Plugin plugin) {
this.plugin = plugin;
}

@Override
public void runTask(Player player, Runnable task) {
schedule(player, task, 1L);
}

@Override
public void runTaskLater(Player player, long delayTicks, Runnable task) {
schedule(player, task, delayTicks);
}

private void schedule(Player player, Runnable task, long delayTicks) {
try {
Method getScheduler = player.getClass().getMethod("getScheduler");
Object entityScheduler = getScheduler.invoke(player);

Method execute = entityScheduler.getClass().getMethod(
"execute",
Plugin.class,
Runnable.class,
Runnable.class,
long.class
);

execute.invoke(entityScheduler, plugin, task, null, delayTicks);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException exception) {
throw new IllegalStateException("Unable to schedule a task on Folia", exception);
}
}
}
Loading