replace folialib with morepaperlib
This commit is contained in:
parent
77ff0a8921
commit
d547628a55
18
pom.xml
18
pom.xml
@ -41,10 +41,6 @@
|
|||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<relocations>
|
<relocations>
|
||||||
<relocation>
|
|
||||||
<pattern>com.tcoded.folialib</pattern>
|
|
||||||
<shadedPattern>me.xginko.villageroptimizer.libs.folialib</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>com.github.benmanes.caffeine</pattern>
|
<pattern>com.github.benmanes.caffeine</pattern>
|
||||||
<shadedPattern>me.xginko.villageroptimizer.libs.caffeine</shadedPattern>
|
<shadedPattern>me.xginko.villageroptimizer.libs.caffeine</shadedPattern>
|
||||||
@ -69,6 +65,10 @@
|
|||||||
<pattern>com.cryptomorin.xseries</pattern>
|
<pattern>com.cryptomorin.xseries</pattern>
|
||||||
<shadedPattern>me.xginko.villageroptimizer.libs.xseries</shadedPattern>
|
<shadedPattern>me.xginko.villageroptimizer.libs.xseries</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>space.arim.morepaperlib</pattern>
|
||||||
|
<shadedPattern>me.xginko.villageroptimizer.libs.morepaperlib</shadedPattern>
|
||||||
|
</relocation>
|
||||||
</relocations>
|
</relocations>
|
||||||
<filters>
|
<filters>
|
||||||
<filter>
|
<filter>
|
||||||
@ -112,8 +112,8 @@
|
|||||||
<url>https://ci.pluginwiki.us/plugin/repository/everything/</url>
|
<url>https://ci.pluginwiki.us/plugin/repository/everything/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>folialib-repo</id>
|
<id>morepaperlib-repo</id>
|
||||||
<url>https://nexuslite.gcnt.net/repos/other/</url>
|
<url>https://mvn-repo.arim.space/lesser-gpl3/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
@ -179,9 +179,9 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<!-- Folia Support -->
|
<!-- Folia Support -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tcoded</groupId>
|
<groupId>space.arim.morepaperlib</groupId>
|
||||||
<artifactId>FoliaLib</artifactId>
|
<artifactId>morepaperlib</artifactId>
|
||||||
<version>0.3.1</version>
|
<version>0.4.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Cross-Version Support -->
|
<!-- Cross-Version Support -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package me.xginko.villageroptimizer;
|
package me.xginko.villageroptimizer;
|
||||||
|
|
||||||
import com.tcoded.folialib.FoliaLib;
|
|
||||||
import me.xginko.villageroptimizer.commands.VillagerOptimizerCommand;
|
import me.xginko.villageroptimizer.commands.VillagerOptimizerCommand;
|
||||||
import me.xginko.villageroptimizer.config.Config;
|
import me.xginko.villageroptimizer.config.Config;
|
||||||
import me.xginko.villageroptimizer.config.LanguageCache;
|
import me.xginko.villageroptimizer.config.LanguageCache;
|
||||||
@ -19,6 +18,8 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import space.arim.morepaperlib.MorePaperLib;
|
||||||
|
import space.arim.morepaperlib.scheduling.GracefulScheduling;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@ -40,7 +41,7 @@ public final class VillagerOptimizer extends JavaPlugin {
|
|||||||
|
|
||||||
private static VillagerOptimizer instance;
|
private static VillagerOptimizer instance;
|
||||||
private static VillagerCache villagerCache;
|
private static VillagerCache villagerCache;
|
||||||
private static FoliaLib foliaLib;
|
private static GracefulScheduling scheduling;
|
||||||
private static Map<String, LanguageCache> languageCacheMap;
|
private static Map<String, LanguageCache> languageCacheMap;
|
||||||
private static Config config;
|
private static Config config;
|
||||||
private static BukkitAudiences audiences;
|
private static BukkitAudiences audiences;
|
||||||
@ -57,7 +58,7 @@ public final class VillagerOptimizer extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
instance = this;
|
instance = this;
|
||||||
foliaLib = new FoliaLib(this);
|
scheduling = new MorePaperLib(this).scheduling();
|
||||||
audiences = BukkitAudiences.create(this);
|
audiences = BukkitAudiences.create(this);
|
||||||
logger = ComponentLogger.logger(getLogger().getName());
|
logger = ComponentLogger.logger(getLogger().getName());
|
||||||
bStats = new Metrics(this, 19954);
|
bStats = new Metrics(this, 19954);
|
||||||
@ -112,9 +113,9 @@ public final class VillagerOptimizer extends JavaPlugin {
|
|||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
VillagerOptimizerModule.ENABLED_MODULES.forEach(VillagerOptimizerModule::disable);
|
VillagerOptimizerModule.ENABLED_MODULES.forEach(VillagerOptimizerModule::disable);
|
||||||
VillagerOptimizerModule.ENABLED_MODULES.clear();
|
VillagerOptimizerModule.ENABLED_MODULES.clear();
|
||||||
if (foliaLib != null) {
|
if (scheduling != null) {
|
||||||
foliaLib.getImpl().cancelAllTasks();
|
scheduling.cancelGlobalTasks();
|
||||||
foliaLib = null;
|
scheduling = null;
|
||||||
}
|
}
|
||||||
if (villagerCache != null) {
|
if (villagerCache != null) {
|
||||||
villagerCache.clear();
|
villagerCache.clear();
|
||||||
@ -143,8 +144,8 @@ public final class VillagerOptimizer extends JavaPlugin {
|
|||||||
public static @NotNull VillagerCache getCache() {
|
public static @NotNull VillagerCache getCache() {
|
||||||
return villagerCache;
|
return villagerCache;
|
||||||
}
|
}
|
||||||
public static @NotNull FoliaLib getFoliaLib() {
|
public static @NotNull GracefulScheduling scheduling() {
|
||||||
return foliaLib;
|
return scheduling;
|
||||||
}
|
}
|
||||||
public static @NotNull ComponentLogger logger() {
|
public static @NotNull ComponentLogger logger() {
|
||||||
return logger;
|
return logger;
|
||||||
|
@ -35,7 +35,7 @@ public class ReloadSubCmd extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
KyoriUtil.sendMessage(sender, Component.text("Reloading VillagerOptimizer...").color(NamedTextColor.WHITE));
|
KyoriUtil.sendMessage(sender, Component.text("Reloading VillagerOptimizer...").color(NamedTextColor.WHITE));
|
||||||
VillagerOptimizer.getFoliaLib().getImpl().runNextTick(reload -> { // Reload in sync with the server
|
VillagerOptimizer.scheduling().asyncScheduler().run(reload -> {
|
||||||
VillagerOptimizer.getInstance().reloadPlugin();
|
VillagerOptimizer.getInstance().reloadPlugin();
|
||||||
KyoriUtil.sendMessage(sender, Component.text("Reload complete.").color(NamedTextColor.GREEN));
|
KyoriUtil.sendMessage(sender, Component.text("Reload complete.").color(NamedTextColor.GREEN));
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package me.xginko.villageroptimizer.modules;
|
package me.xginko.villageroptimizer.modules;
|
||||||
|
|
||||||
import com.cryptomorin.xseries.XEntityType;
|
import com.cryptomorin.xseries.XEntityType;
|
||||||
import com.tcoded.folialib.wrapper.task.WrappedTask;
|
|
||||||
import me.xginko.villageroptimizer.utils.LocationUtil;
|
import me.xginko.villageroptimizer.utils.LocationUtil;
|
||||||
import me.xginko.villageroptimizer.utils.Util;
|
import me.xginko.villageroptimizer.utils.Util;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
@ -15,6 +14,7 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import space.arim.morepaperlib.scheduling.ScheduledTask;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -25,7 +25,7 @@ import java.util.stream.Stream;
|
|||||||
|
|
||||||
public class VillagerChunkLimit extends VillagerOptimizerModule implements Runnable, Listener {
|
public class VillagerChunkLimit extends VillagerOptimizerModule implements Runnable, Listener {
|
||||||
|
|
||||||
private WrappedTask periodic_chunk_check;
|
private ScheduledTask periodic_chunk_check;
|
||||||
private final List<Villager.Profession> non_optimized_removal_priority, optimized_removal_priority;
|
private final List<Villager.Profession> non_optimized_removal_priority, optimized_removal_priority;
|
||||||
private final long check_period;
|
private final long check_period;
|
||||||
private final int non_optimized_max_per_chunk, optimized_max_per_chunk;
|
private final int non_optimized_max_per_chunk, optimized_max_per_chunk;
|
||||||
@ -93,7 +93,7 @@ public class VillagerChunkLimit extends VillagerOptimizerModule implements Runna
|
|||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
periodic_chunk_check = scheduler.runTimer(this, check_period, check_period);
|
periodic_chunk_check = scheduling.globalRegionalScheduler().runAtFixedRate(this, check_period, check_period);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -160,11 +160,11 @@ public class VillagerChunkLimit extends VillagerOptimizerModule implements Runna
|
|||||||
// Remove prioritized villagers that are too many
|
// Remove prioritized villagers that are too many
|
||||||
for (int i = 0; i < not_optimized_villagers_too_many; i++) {
|
for (int i = 0; i < not_optimized_villagers_too_many; i++) {
|
||||||
Villager villager = not_optimized_villagers.get(i);
|
Villager villager = not_optimized_villagers.get(i);
|
||||||
scheduler.runAtEntity(villager, kill -> {
|
scheduling.entitySpecificScheduler(villager).run(kill -> {
|
||||||
villager.remove();
|
villager.remove();
|
||||||
if (log_enabled) info("Removed unoptimized villager with profession '" +
|
if (log_enabled) info("Removed unoptimized villager with profession '" +
|
||||||
Util.formatEnum(villager.getProfession()) + "' at " + LocationUtil.toString(villager.getLocation()));
|
Util.formatEnum(villager.getProfession()) + "' at " + LocationUtil.toString(villager.getLocation()));
|
||||||
});
|
}, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,11 +179,11 @@ public class VillagerChunkLimit extends VillagerOptimizerModule implements Runna
|
|||||||
// Remove prioritized villagers that are too many
|
// Remove prioritized villagers that are too many
|
||||||
for (int i = 0; i < optimized_villagers_too_many; i++) {
|
for (int i = 0; i < optimized_villagers_too_many; i++) {
|
||||||
Villager villager = optimized_villagers.get(i);
|
Villager villager = optimized_villagers.get(i);
|
||||||
scheduler.runAtEntity(villager, kill -> {
|
scheduling.entitySpecificScheduler(villager).run(kill -> {
|
||||||
villager.remove();
|
villager.remove();
|
||||||
if (log_enabled) info("Removed optimized villager with profession '" +
|
if (log_enabled) info("Removed unoptimized villager with profession '" +
|
||||||
Util.formatEnum(villager.getProfession()) + "' at " + LocationUtil.toString(villager.getLocation()));
|
Util.formatEnum(villager.getProfession()) + "' at " + LocationUtil.toString(villager.getLocation()));
|
||||||
});
|
}, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package me.xginko.villageroptimizer.modules;
|
package me.xginko.villageroptimizer.modules;
|
||||||
|
|
||||||
import com.tcoded.folialib.impl.ServerImplementation;
|
|
||||||
import me.xginko.villageroptimizer.VillagerCache;
|
import me.xginko.villageroptimizer.VillagerCache;
|
||||||
import me.xginko.villageroptimizer.VillagerOptimizer;
|
import me.xginko.villageroptimizer.VillagerOptimizer;
|
||||||
import me.xginko.villageroptimizer.config.Config;
|
import me.xginko.villageroptimizer.config.Config;
|
||||||
import org.reflections.Reflections;
|
import org.reflections.Reflections;
|
||||||
import org.reflections.scanners.Scanners;
|
import org.reflections.scanners.Scanners;
|
||||||
|
import space.arim.morepaperlib.scheduling.GracefulScheduling;
|
||||||
|
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -23,7 +23,7 @@ public abstract class VillagerOptimizerModule {
|
|||||||
protected final VillagerOptimizer plugin;
|
protected final VillagerOptimizer plugin;
|
||||||
protected final Config config;
|
protected final Config config;
|
||||||
protected final VillagerCache villagerCache;
|
protected final VillagerCache villagerCache;
|
||||||
protected final ServerImplementation scheduler;
|
protected final GracefulScheduling scheduling;
|
||||||
public final String configPath;
|
public final String configPath;
|
||||||
private final String logFormat;
|
private final String logFormat;
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ public abstract class VillagerOptimizerModule {
|
|||||||
this.plugin = VillagerOptimizer.getInstance();
|
this.plugin = VillagerOptimizer.getInstance();
|
||||||
this.config = VillagerOptimizer.config();
|
this.config = VillagerOptimizer.config();
|
||||||
this.villagerCache = VillagerOptimizer.getCache();
|
this.villagerCache = VillagerOptimizer.getCache();
|
||||||
this.scheduler = VillagerOptimizer.getFoliaLib().getImpl();
|
this.scheduling = VillagerOptimizer.scheduling();
|
||||||
this.configPath = configPath;
|
this.configPath = configPath;
|
||||||
shouldEnable(); // Ensure enable option is always first
|
shouldEnable(); // Ensure enable option is always first
|
||||||
String[] paths = configPath.split("\\.");
|
String[] paths = configPath.split("\\.");
|
||||||
|
@ -68,7 +68,7 @@ public class EnableLeashingVillagers extends VillagerOptimizerModule implements
|
|||||||
// If canceled by any plugin, do nothing
|
// If canceled by any plugin, do nothing
|
||||||
if (!leashEvent.callEvent()) return;
|
if (!leashEvent.callEvent()) return;
|
||||||
|
|
||||||
scheduler.runAtEntity(villager, leash -> {
|
scheduling.entitySpecificScheduler(villager).run(leash -> {
|
||||||
// Legitimate to not use entities from the event object since they are final in PlayerLeashEntityEvent
|
// Legitimate to not use entities from the event object since they are final in PlayerLeashEntityEvent
|
||||||
if (!villager.setLeashHolder(player)) return;
|
if (!villager.setLeashHolder(player)) return;
|
||||||
if (player.getGameMode().equals(GameMode.SURVIVAL))
|
if (player.getGameMode().equals(GameMode.SURVIVAL))
|
||||||
@ -77,6 +77,6 @@ public class EnableLeashingVillagers extends VillagerOptimizerModule implements
|
|||||||
if (log_enabled) {
|
if (log_enabled) {
|
||||||
info(player.getName() + " leashed a villager at " + LocationUtil.toString(villager.getLocation()));
|
info(player.getName() + " leashed a villager at " + LocationUtil.toString(villager.getLocation()));
|
||||||
}
|
}
|
||||||
});
|
}, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,6 @@ import org.bukkit.event.HandlerList;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityTransformEvent;
|
import org.bukkit.event.entity.EntityTransformEvent;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
public class FixOptimisationAfterCure extends VillagerOptimizerModule implements Listener {
|
public class FixOptimisationAfterCure extends VillagerOptimizerModule implements Listener {
|
||||||
|
|
||||||
public FixOptimisationAfterCure() {
|
public FixOptimisationAfterCure() {
|
||||||
@ -40,10 +38,10 @@ public class FixOptimisationAfterCure extends VillagerOptimizerModule implements
|
|||||||
&& event.getTransformedEntity().getType() == XEntityType.VILLAGER.get()
|
&& event.getTransformedEntity().getType() == XEntityType.VILLAGER.get()
|
||||||
) {
|
) {
|
||||||
Villager villager = (Villager) event.getTransformedEntity();
|
Villager villager = (Villager) event.getTransformedEntity();
|
||||||
scheduler.runAtEntityLater(villager, () -> {
|
scheduling.entitySpecificScheduler(villager).runDelayed(() -> {
|
||||||
WrappedVillager wVillager = villagerCache.createIfAbsent(villager);
|
WrappedVillager wVillager = villagerCache.createIfAbsent(villager);
|
||||||
wVillager.setOptimizationType(wVillager.getOptimizationType());
|
wVillager.setOptimizationType(wVillager.getOptimizationType());
|
||||||
}, 2, TimeUnit.SECONDS);
|
}, null, 40L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -71,14 +71,14 @@ public class LevelOptimizedProfession extends VillagerOptimizerModule implements
|
|||||||
if (wVillager.canLevelUp(cooldown_millis)) {
|
if (wVillager.canLevelUp(cooldown_millis)) {
|
||||||
if (wVillager.calculateLevel() <= villager.getVillagerLevel()) return;
|
if (wVillager.calculateLevel() <= villager.getVillagerLevel()) return;
|
||||||
|
|
||||||
scheduler.runAtEntity(villager, enableAI -> {
|
scheduling.entitySpecificScheduler(villager).run(enableAI -> {
|
||||||
villager.addPotionEffect(SUPER_SLOWNESS);
|
villager.addPotionEffect(SUPER_SLOWNESS);
|
||||||
villager.setAware(true);
|
villager.setAware(true);
|
||||||
scheduler.runAtEntityLater(villager, disableAI -> {
|
scheduling.entitySpecificScheduler(villager).runDelayed(disableAI -> {
|
||||||
villager.setAware(false);
|
villager.setAware(false);
|
||||||
wVillager.saveLastLevelUp();
|
wVillager.saveLastLevelUp();
|
||||||
}, 5, TimeUnit.SECONDS);
|
}, null, 100L);
|
||||||
});
|
}, null);
|
||||||
} else {
|
} else {
|
||||||
if (notify_player) {
|
if (notify_player) {
|
||||||
Player player = (Player) event.getPlayer();
|
Player player = (Player) event.getPlayer();
|
||||||
|
@ -35,16 +35,16 @@ public class VisuallyHighlightOptimized extends VillagerOptimizerModule implemen
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
private void onOptimize(VillagerOptimizeEvent event) {
|
private void onOptimize(VillagerOptimizeEvent event) {
|
||||||
Villager villager = event.getWrappedVillager().villager();
|
Villager villager = event.getWrappedVillager().villager();
|
||||||
scheduler.runAtEntity(villager, glow -> {
|
scheduling.entitySpecificScheduler(villager).run(glow -> {
|
||||||
if (!villager.isGlowing()) villager.setGlowing(true);
|
if (!villager.isGlowing()) villager.setGlowing(true);
|
||||||
});
|
}, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
private void onUnOptimize(VillagerUnoptimizeEvent event) {
|
private void onUnOptimize(VillagerUnoptimizeEvent event) {
|
||||||
Villager villager = event.getWrappedVillager().villager();
|
Villager villager = event.getWrappedVillager().villager();
|
||||||
scheduler.runAtEntity(villager, unGlow -> {
|
scheduling.entitySpecificScheduler(villager).run(unGlow -> {
|
||||||
if (villager.isGlowing()) villager.setGlowing(false);
|
if (villager.isGlowing()) villager.setGlowing(false);
|
||||||
});
|
}, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -85,7 +85,7 @@ public class OptimizeByWorkstation extends VillagerOptimizerModule implements Li
|
|||||||
final AtomicBoolean taskComplete = new AtomicBoolean();
|
final AtomicBoolean taskComplete = new AtomicBoolean();
|
||||||
final AtomicInteger taskAliveTicks = new AtomicInteger();
|
final AtomicInteger taskAliveTicks = new AtomicInteger();
|
||||||
|
|
||||||
scheduler.runAtLocationTimer(workstationLoc, repeatingTask -> {
|
scheduling.regionSpecificScheduler(workstationLoc).runAtFixedRate(repeatingTask -> {
|
||||||
if (taskComplete.get() || taskAliveTicks.getAndAdd(10) > check_duration_ticks) {
|
if (taskComplete.get() || taskAliveTicks.getAndAdd(10) > check_duration_ticks) {
|
||||||
repeatingTask.cancel();
|
repeatingTask.cancel();
|
||||||
return;
|
return;
|
||||||
|
@ -40,7 +40,7 @@ public class AVLVillagerDataHandlerImpl implements VillagerDataHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setOptimizationType(OptimizationType type) {
|
public void setOptimizationType(OptimizationType type) {
|
||||||
VillagerOptimizer.getFoliaLib().getImpl().runAtEntityTimer(villager, setOptimization -> {
|
VillagerOptimizer.scheduling().entitySpecificScheduler(villager).runAtFixedRate(setOptimization -> {
|
||||||
// Keep repeating task until villager is no longer trading with a player
|
// Keep repeating task until villager is no longer trading with a player
|
||||||
if (villager.isTrading()) return;
|
if (villager.isTrading()) return;
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ public class AVLVillagerDataHandlerImpl implements VillagerDataHandler {
|
|||||||
|
|
||||||
// End repeating task once logic is finished
|
// End repeating task once logic is finished
|
||||||
setOptimization.cancel();
|
setOptimization.cancel();
|
||||||
}, 1L, 1L, TimeUnit.SECONDS);
|
}, null, 1L, 20L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -8,8 +8,6 @@ import org.bukkit.persistence.PersistentDataContainer;
|
|||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
public class MainVillagerDataHandlerImpl implements VillagerDataHandler {
|
public class MainVillagerDataHandlerImpl implements VillagerDataHandler {
|
||||||
|
|
||||||
private final @NotNull Villager villager;
|
private final @NotNull Villager villager;
|
||||||
@ -37,7 +35,7 @@ public class MainVillagerDataHandlerImpl implements VillagerDataHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setOptimizationType(OptimizationType type) {
|
public void setOptimizationType(OptimizationType type) {
|
||||||
VillagerOptimizer.getFoliaLib().getImpl().runAtEntityTimer(villager, setOptimization -> {
|
VillagerOptimizer.scheduling().entitySpecificScheduler(villager).runAtFixedRate(setOptimization -> {
|
||||||
// Keep repeating task until villager is no longer trading with a player
|
// Keep repeating task until villager is no longer trading with a player
|
||||||
if (villager.isTrading()) return;
|
if (villager.isTrading()) return;
|
||||||
|
|
||||||
@ -53,7 +51,7 @@ public class MainVillagerDataHandlerImpl implements VillagerDataHandler {
|
|||||||
|
|
||||||
// End repeating task once logic is finished
|
// End repeating task once logic is finished
|
||||||
setOptimization.cancel();
|
setOptimization.cancel();
|
||||||
}, 1L, 1L, TimeUnit.SECONDS);
|
}, null, 1L, 20L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user