forked from SteamWar/SteamWar
Add @LinkedTimer
A method of a linked class annotated with @LinkedTimer(delay, period) is run repeatedly by the linker, on Spigot and Velocity. The method must not have parameters, its return value is ignored. It is called through a MethodHandle bound once when linking instead of reflection; LambdaMetafactory cannot be used as the linker and the linked classes are in different class loaders. The unit defaults to ticks and can be set to milliseconds up to hours; the Unit enum converts it to ticks for Spigot and to a TimeUnit for Velocity. HullHiderCommand uses it for its tick task.
This commit is contained in:
+2
-2
@@ -32,6 +32,7 @@ import de.steamwar.hullhider.HullRegion;
|
||||
import de.steamwar.hullhider.Viewers;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
import de.steamwar.linkage.LinkedTimer;
|
||||
import de.steamwar.techhider.ObfuscationConfig;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -55,8 +56,6 @@ public class HullHiderCommand extends SWCommand implements Listener {
|
||||
|
||||
public HullHiderCommand() {
|
||||
super("hullhider");
|
||||
|
||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), this::onTick, 1, 1);
|
||||
}
|
||||
|
||||
@Linked
|
||||
@@ -140,6 +139,7 @@ public class HullHiderCommand extends SWCommand implements Listener {
|
||||
});
|
||||
}
|
||||
|
||||
@LinkedTimer(delay = 1, period = 1)
|
||||
private void onTick() {
|
||||
if (hidden.isEmpty()) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user