Add folia support

This commit is contained in:
ceze88 2023-05-17 12:57:17 +02:00
parent 549a1ce9f4
commit 06041b8780
12 changed files with 120 additions and 97 deletions

31
pom.xml
View File

@ -112,17 +112,17 @@
</repositories> </repositories>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.apache.commons</groupId>
<artifactId>spigot-api</artifactId> <artifactId>commons-lang3</artifactId>
<version>1.18-R0.1-SNAPSHOT</version> <version>3.12.0</version>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>SongodaCore</artifactId> <artifactId>SongodaCore</artifactId>
<version>2.6.21</version> <version>2.6.22</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
@ -140,18 +140,25 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>me.minebuilders</groupId>
<artifactId>Clearlag</artifactId>
<version>3.0.6</version>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>io.lumine</groupId> <groupId>io.lumine</groupId>
<artifactId>Mythic-Dist</artifactId> <artifactId>Mythic-Dist</artifactId>
<version>5.2.0</version> <version>5.2.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>dev.folia</groupId>
<artifactId>folia-api</artifactId>
<version>1.19.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.19.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -32,7 +32,6 @@ import com.songoda.ultimatestacker.hook.StackerHook;
import com.songoda.ultimatestacker.hook.hooks.JobsHook; import com.songoda.ultimatestacker.hook.hooks.JobsHook;
import com.songoda.ultimatestacker.listeners.BlockListeners; import com.songoda.ultimatestacker.listeners.BlockListeners;
import com.songoda.ultimatestacker.listeners.BreedListeners; import com.songoda.ultimatestacker.listeners.BreedListeners;
import com.songoda.ultimatestacker.listeners.ClearLagListeners;
import com.songoda.ultimatestacker.listeners.DeathListeners; import com.songoda.ultimatestacker.listeners.DeathListeners;
import com.songoda.ultimatestacker.listeners.InteractListeners; import com.songoda.ultimatestacker.listeners.InteractListeners;
import com.songoda.ultimatestacker.listeners.ShearListeners; import com.songoda.ultimatestacker.listeners.ShearListeners;
@ -57,7 +56,7 @@ import com.songoda.ultimatestacker.stackable.spawner.SpawnerStackManager;
import com.songoda.ultimatestacker.tasks.StackingTask; import com.songoda.ultimatestacker.tasks.StackingTask;
import com.songoda.ultimatestacker.utils.Async; import com.songoda.ultimatestacker.utils.Async;
import com.songoda.ultimatestacker.utils.Methods; import com.songoda.ultimatestacker.utils.Methods;
import org.apache.commons.lang.WordUtils; import org.apache.commons.lang3.text.WordUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -210,8 +209,8 @@ public class UltimateStacker extends SongodaPlugin {
pluginManager.registerEvents(new SpawnerListeners(this), this); pluginManager.registerEvents(new SpawnerListeners(this), this);
pluginManager.registerEvents(new SheepDyeListeners(this), this); pluginManager.registerEvents(new SheepDyeListeners(this), this);
if (Settings.CLEAR_LAG.getBoolean() && pluginManager.isPluginEnabled("ClearLag")) // if (Settings.CLEAR_LAG.getBoolean() && pluginManager.isPluginEnabled("ClearLag"))
pluginManager.registerEvents(new ClearLagListeners(this), this); // pluginManager.registerEvents(new ClearLagListeners(this), this);
// Register Hooks // Register Hooks
if (pluginManager.isPluginEnabled("Jobs")) if (pluginManager.isPluginEnabled("Jobs"))

View File

@ -12,7 +12,7 @@ import com.songoda.ultimatestacker.stackable.block.BlockStack;
import com.songoda.ultimatestacker.stackable.block.BlockStackManager; import com.songoda.ultimatestacker.stackable.block.BlockStackManager;
import com.songoda.ultimatestacker.stackable.spawner.SpawnerStack; import com.songoda.ultimatestacker.stackable.spawner.SpawnerStack;
import com.songoda.ultimatestacker.utils.Methods; import com.songoda.ultimatestacker.utils.Methods;
import org.apache.commons.lang.math.NumberUtils; import org.apache.commons.lang3.math.NumberUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material; import org.bukkit.Material;

View File

@ -1,5 +1,6 @@
package com.songoda.ultimatestacker.listeners; package com.songoda.ultimatestacker.listeners;
import com.songoda.SchedulerUtils;
import com.songoda.ultimatestacker.UltimateStacker; import com.songoda.ultimatestacker.UltimateStacker;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -17,7 +18,7 @@ public class BreedListeners implements Listener {
@EventHandler @EventHandler
public void onBread(EntityBreedEvent event) { public void onBread(EntityBreedEvent event) {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> { SchedulerUtils.runEntityTask(plugin, event.getEntity(), () -> {
event.getFather().removeMetadata("breedCooldown", plugin); event.getFather().removeMetadata("breedCooldown", plugin);
event.getMother().removeMetadata("breedCooldown", plugin); event.getMother().removeMetadata("breedCooldown", plugin);
}, 5 * 20 * 60); }, 5 * 20 * 60);

View File

@ -1,27 +0,0 @@
package com.songoda.ultimatestacker.listeners;
import com.songoda.ultimatestacker.UltimateStacker;
import me.minebuilders.clearlag.events.EntityRemoveEvent;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class ClearLagListeners implements Listener {
private final UltimateStacker plugin;
public ClearLagListeners(UltimateStacker plugin) {
this.plugin = plugin;
}
@EventHandler
public void onClearLaggTask(EntityRemoveEvent event) {
for (Entity entity : event.getWorld().getEntities()) {
if (entity instanceof LivingEntity && plugin.getEntityStackManager().isStackedEntity(entity)) {
plugin.getEntityStackManager().getStack((LivingEntity) entity).destroy();
event.addEntity(entity);
}
}
}
}

View File

@ -1,5 +1,6 @@
package com.songoda.ultimatestacker.listeners; package com.songoda.ultimatestacker.listeners;
import com.songoda.SchedulerUtils;
import com.songoda.core.compatibility.ServerProject; import com.songoda.core.compatibility.ServerProject;
import com.songoda.core.compatibility.ServerVersion; import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.lootables.loot.Drop; import com.songoda.core.lootables.loot.Drop;
@ -108,7 +109,7 @@ public class DeathListeners implements Listener {
commands.add(command); commands.add(command);
} }
}); });
Bukkit.getScheduler().runTask(plugin, () -> { SchedulerUtils.runTask(plugin, () -> {
for (String command : commands) { for (String command : commands) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
} }

View File

@ -1,5 +1,6 @@
package com.songoda.ultimatestacker.listeners; package com.songoda.ultimatestacker.listeners;
import com.songoda.SchedulerUtils;
import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.ServerVersion; import com.songoda.core.compatibility.ServerVersion;
import com.songoda.ultimatestacker.UltimateStacker; import com.songoda.ultimatestacker.UltimateStacker;
@ -66,7 +67,7 @@ public class InteractListeners implements Listener {
} }
entity.setMetadata("inLove", new FixedMetadataValue(plugin, true)); entity.setMetadata("inLove", new FixedMetadataValue(plugin, true));
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, () -> { SchedulerUtils.runEntityTask(plugin, entity, () -> {
if (entity.isDead()) return; if (entity.isDead()) return;
entity.removeMetadata("inLove", plugin); entity.removeMetadata("inLove", plugin);
}, 20 * 20); }, 20 * 20);

View File

@ -1,5 +1,6 @@
package com.songoda.ultimatestacker.listeners.entity; package com.songoda.ultimatestacker.listeners.entity;
import com.songoda.SchedulerUtils;
import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.ultimatestacker.UltimateStacker; import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.settings.Settings; import com.songoda.ultimatestacker.settings.Settings;
@ -89,7 +90,7 @@ public class EntityListeners implements Listener {
if (plugin.getEntityStackManager().isStackedEntity(entity) if (plugin.getEntityStackManager().isStackedEntity(entity)
&& Settings.DISABLE_KNOCKBACK.getBoolean() && Settings.DISABLE_KNOCKBACK.getBoolean()
&& ((Player) event.getDamager()).getItemInHand().getEnchantmentLevel(Enchantment.KNOCKBACK) == 0) { && ((Player) event.getDamager()).getItemInHand().getEnchantmentLevel(Enchantment.KNOCKBACK) == 0) {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> { SchedulerUtils.runEntityTask(plugin, entity, () -> {
event.getEntity().setVelocity(new Vector()); event.getEntity().setVelocity(new Vector());
}, 0L); }, 0L);
} }

View File

@ -4,7 +4,7 @@ import com.songoda.core.nms.NmsManager;
import com.songoda.ultimatestacker.UltimateStacker; import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.settings.Settings; import com.songoda.ultimatestacker.settings.Settings;
import com.songoda.ultimatestacker.utils.Methods; import com.songoda.ultimatestacker.utils.Methods;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;

View File

@ -1,5 +1,6 @@
package com.songoda.ultimatestacker.stackable.entity; package com.songoda.ultimatestacker.stackable.entity;
import com.songoda.SchedulerUtils;
import com.songoda.core.compatibility.ServerVersion; import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.lootables.loot.Drop; import com.songoda.core.lootables.loot.Drop;
import com.songoda.core.lootables.loot.DropUtils; import com.songoda.core.lootables.loot.DropUtils;
@ -62,15 +63,26 @@ public class EntityStack extends StackedEntity {
event.setDroppedExp(droppedExp * getAmount()); event.setDroppedExp(droppedExp * getAmount());
} }
if (plugin.getCustomEntityManager().getCustomEntity(killed) == null) { if (plugin.getCustomEntityManager().getCustomEntity(killed) == null) {
Async.run(() -> { Async.run(() -> {
drops.removeIf(it -> it.getItemStack() != null if (ServerVersion.isFolia()) {
&& it.getItemStack().isSimilar(killed.getEquipment().getItemInHand())); killed.getScheduler().run(plugin, scheduledTask -> {
for (ItemStack item : killed.getEquipment().getArmorContents()) { drops.removeIf(it -> it.getItemStack() != null
drops.removeIf(it -> it.getItemStack() != null && it.getItemStack().isSimilar(item)); && it.getItemStack().isSimilar(killed.getEquipment().getItemInHand()));
for (ItemStack item : killed.getEquipment().getArmorContents()) {
drops.removeIf(it -> it.getItemStack() != null && it.getItemStack().isSimilar(item));
}
}, () -> DropUtils.processStackedDrop(killed, plugin.getLootablesManager().getDrops(killed, getAmount()), event));
} else {
drops.removeIf(it -> it.getItemStack() != null
&& it.getItemStack().isSimilar(killed.getEquipment().getItemInHand()));
for (ItemStack item : killed.getEquipment().getArmorContents()) {
drops.removeIf(it -> it.getItemStack() != null && it.getItemStack().isSimilar(item));
}
DropUtils.processStackedDrop(killed, plugin.getLootablesManager().getDrops(killed, getAmount()), event);
} }
DropUtils.processStackedDrop(killed, plugin.getLootablesManager().getDrops(killed, getAmount()), event);
}); });
} }
@ -155,7 +167,7 @@ public class EntityStack extends StackedEntity {
public synchronized void destroy() { public synchronized void destroy() {
if (hostEntity == null) return; if (hostEntity == null) return;
Bukkit.getScheduler().runTask(plugin, hostEntity::remove); SchedulerUtils.runEntityTask(plugin, hostEntity, hostEntity::remove);
hostEntity = null; hostEntity = null;
} }

View File

@ -1,5 +1,6 @@
package com.songoda.ultimatestacker.tasks; package com.songoda.ultimatestacker.tasks;
import com.songoda.SchedulerUtils;
import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.ServerVersion; import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.hooks.WorldGuardHook; import com.songoda.core.hooks.WorldGuardHook;
@ -11,6 +12,9 @@ import com.songoda.ultimatestacker.stackable.entity.EntityStack;
import com.songoda.ultimatestacker.stackable.entity.EntityStackManager; import com.songoda.ultimatestacker.stackable.entity.EntityStackManager;
import com.songoda.ultimatestacker.stackable.entity.custom.CustomEntity; import com.songoda.ultimatestacker.stackable.entity.custom.CustomEntity;
import com.songoda.ultimatestacker.utils.CachedChunk; import com.songoda.ultimatestacker.utils.CachedChunk;
import io.papermc.paper.threadedregions.RegionizedServerInitEvent;
import io.papermc.paper.threadedregions.scheduler.EntityScheduler;
import io.papermc.paper.threadedregions.scheduler.RegionScheduler;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -63,29 +67,29 @@ import java.util.concurrent.TimeUnit;
public class StackingTask extends TimerTask { public class StackingTask extends TimerTask {
private final UltimateStacker plugin; protected final UltimateStacker plugin;
private final ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor(); protected final ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
private final EntityStackManager stackManager; protected final EntityStackManager stackManager;
private final ConfigurationSection configurationSection = UltimateStacker.getInstance().getMobFile(); protected final ConfigurationSection configurationSection = UltimateStacker.getInstance().getMobFile();
private final List<UUID> processed = new ArrayList<>(); protected final List<UUID> processed = new ArrayList<>();
private final Map<EntityType, Integer> entityStackSizes = new HashMap<>(); protected final Map<EntityType, Integer> entityStackSizes = new HashMap<>();
private final int maxEntityStackSize = Settings.MAX_STACK_ENTITIES.getInt(), protected final int maxEntityStackSize = Settings.MAX_STACK_ENTITIES.getInt(),
minEntityStackSize = Settings.MIN_STACK_ENTITIES.getInt(), minEntityStackSize = Settings.MIN_STACK_ENTITIES.getInt(),
searchRadius = Settings.SEARCH_RADIUS.getInt(), searchRadius = Settings.SEARCH_RADIUS.getInt(),
maxPerTypeStacksPerChunk = Settings.MAX_PER_TYPE_STACKS_PER_CHUNK.getInt(); maxPerTypeStacksPerChunk = Settings.MAX_PER_TYPE_STACKS_PER_CHUNK.getInt();
private final List<String> disabledWorlds = Settings.DISABLED_WORLDS.getStringList(), protected final List<String> disabledWorlds = Settings.DISABLED_WORLDS.getStringList(),
stackReasons = Settings.STACK_REASONS.getStringList(); stackReasons = Settings.STACK_REASONS.getStringList();
private final List<Check> checks = Check.getChecks(Settings.STACK_CHECKS.getStringList()); protected final List<Check> checks = Check.getChecks(Settings.STACK_CHECKS.getStringList());
private final boolean stackFlyingDown = Settings.ONLY_STACK_FLYING_DOWN.getBoolean(), protected final boolean stackFlyingDown = Settings.ONLY_STACK_FLYING_DOWN.getBoolean(),
stackWholeChunk = Settings.STACK_WHOLE_CHUNK.getBoolean(), stackWholeChunk = Settings.STACK_WHOLE_CHUNK.getBoolean(),
weaponsArentEquipment = Settings.WEAPONS_ARENT_EQUIPMENT.getBoolean(), weaponsArentEquipment = Settings.WEAPONS_ARENT_EQUIPMENT.getBoolean(),
onlyStackFromSpawners = Settings.ONLY_STACK_FROM_SPAWNERS.getBoolean(), onlyStackFromSpawners = Settings.ONLY_STACK_FROM_SPAWNERS.getBoolean(),
onlyStackOnSurface = Settings.ONLY_STACK_ON_SURFACE.getBoolean(); onlyStackOnSurface = Settings.ONLY_STACK_ON_SURFACE.getBoolean();
Set<SWorld> loadedWorlds = new HashSet<>(); protected Set<SWorld> loadedWorlds = new HashSet<>();
public StackingTask(UltimateStacker plugin) { public StackingTask(UltimateStacker plugin) {
this.plugin = plugin; this.plugin = plugin;
@ -125,49 +129,72 @@ public class StackingTask extends TimerTask {
} }
Collections.reverse(entities); Collections.reverse(entities);
Bukkit.getScheduler().runTask(plugin, () -> { if (ServerVersion.isFolia()) {
// Loop through the entities. SchedulerUtils.runTask(plugin, () -> {
for (LivingEntity entity : entities) { Map<EntityScheduler, List<LivingEntity>> entitySchedulerMap = sWorld.getRegionizedEntities();
// Make sure our entity has not already been processed. for (EntityScheduler scheduler : entitySchedulerMap.keySet()) {
// Skip it if it has been. List<LivingEntity> livingEntities = entitySchedulerMap.get(scheduler);
if (this.processed.contains(entity.getUniqueId())) continue; if (livingEntities == null) continue;
scheduler.run(plugin, scheduledTask -> {
// Loop through the entities.
for (LivingEntity entity : livingEntities) {
// Make sure our entity has not already been processed.
// Skip it if it has been.
if (this.processed.contains(entity.getUniqueId())) continue;
// Check to see if entity is not stackable. // Check to see if entity is not stackable.
if (!isEntityStackable(entity)) { if (!isEntityStackable(entity)) {
continue; continue;
}
// Get entity location to pass around as its faster this way.
Location location = entity.getLocation();
// Process the entity.
this.processEntity(entity, sWorld, location);
}
}, null);
} }
});
} else {
SchedulerUtils.runTask(plugin, () -> {
// Loop through the entities.
for (LivingEntity entity : entities) {
// Make sure our entity has not already been processed.
// Skip it if it has been.
if (this.processed.contains(entity.getUniqueId())) continue;
// Get entity location to pass around as its faster this way. // Check to see if entity is not stackable.
Location location = entity.getLocation(); if (!isEntityStackable(entity)) {
continue;
}
// Process the entity. // Get entity location to pass around as its faster this way.
this.processEntity(entity, sWorld, location); Location location = entity.getLocation();
}
}); // Process the entity.
this.processEntity(entity, sWorld, location);
}
});
}
} }
// Clear caches in preparation for the next run. // Clear caches in preparation for the next run.
this.processed.clear(); this.processed.clear();
} catch (Exception ignored) {} } catch (Exception ignored) {}
} }
private Future<List<LivingEntity>> getLivingEntitiesSync(SWorld sWorld) { protected Future<List<LivingEntity>> getLivingEntitiesSync(SWorld sWorld) {
CompletableFuture<List<LivingEntity>> future = new CompletableFuture<>(); CompletableFuture<List<LivingEntity>> future = new CompletableFuture<>();
Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, () -> future.complete(sWorld.getLivingEntities())); SchedulerUtils.runTask(this.plugin, () -> future.complete(sWorld.getLivingEntities()));
return future; return future;
} }
private Future<Entity[]> getEntitiesInChunkSync(CachedChunk cachedChunk) {
CompletableFuture<Entity[]> future = new CompletableFuture<>();
Bukkit.getScheduler().runTask(this.plugin, () -> future.complete(cachedChunk.getEntities()));
return future;
}
public boolean isWorldDisabled(World world) { public boolean isWorldDisabled(World world) {
return disabledWorlds.stream().anyMatch(worldStr -> world.getName().equalsIgnoreCase(worldStr)); return disabledWorlds.stream().anyMatch(worldStr -> world.getName().equalsIgnoreCase(worldStr));
} }
private boolean isEntityStackable(Entity entity) { protected boolean isEntityStackable(Entity entity) {
// Make sure we have the correct entity type and that it is valid. // Make sure we have the correct entity type and that it is valid.
if (!entity.isValid() if (!entity.isValid()
|| entity instanceof HumanEntity || entity instanceof HumanEntity
@ -210,7 +237,7 @@ public class StackingTask extends TimerTask {
} }
private void processEntity(LivingEntity baseEntity, SWorld sWorld, Location location) { protected void processEntity(LivingEntity baseEntity, SWorld sWorld, Location location) {
// Check our WorldGuard flag. // Check our WorldGuard flag.
Boolean flag = WorldGuardHook.isEnabled() ? WorldGuardHook.getBooleanFlag(baseEntity.getLocation(), "mob-stacking") : null; Boolean flag = WorldGuardHook.isEnabled() ? WorldGuardHook.getBooleanFlag(baseEntity.getLocation(), "mob-stacking") : null;
@ -278,7 +305,7 @@ public class StackingTask extends TimerTask {
stackManager.createStack(friendlyEntity, amount + amountToStack); stackManager.createStack(friendlyEntity, amount + amountToStack);
processed.add(baseEntity.getUniqueId()); processed.add(baseEntity.getUniqueId());
Bukkit.getScheduler().runTask(plugin, () -> { SchedulerUtils.runEntityTask(plugin, baseEntity, () -> {
if (baseEntity.isLeashed()) { if (baseEntity.isLeashed()) {
baseEntity.getWorld().dropItemNaturally(baseEntity.getLocation(), CompatibleMaterial.LEAD.getItem()); baseEntity.getWorld().dropItemNaturally(baseEntity.getLocation(), CompatibleMaterial.LEAD.getItem());
} }
@ -297,7 +324,7 @@ public class StackingTask extends TimerTask {
baseStack.setAmount(maxEntityStackAmount); baseStack.setAmount(maxEntityStackAmount);
Bukkit.getScheduler().runTask(plugin, () -> { SchedulerUtils.runLocationTask(plugin, baseStack.getHostEntity().getLocation(), () -> {
int finalStackSize = stackSize - maxEntityStackAmount; int finalStackSize = stackSize - maxEntityStackAmount;
do { do {
// Create a new stack, summon entity and add to stack. // Create a new stack, summon entity and add to stack.
@ -314,7 +341,7 @@ public class StackingTask extends TimerTask {
return true; return true;
} }
private Set<CachedChunk> getNearbyChunks(SWorld sWorld, Location location, double radius, boolean singleChunk) { protected Set<CachedChunk> getNearbyChunks(SWorld sWorld, Location location, double radius, boolean singleChunk) {
//get current chunk //get current chunk
if (radius == -1) { if (radius == -1) {
return new HashSet<>(Collections.singletonList(new CachedChunk(sWorld, location.getChunk().getX(), location.getChunk().getZ()))); return new HashSet<>(Collections.singletonList(new CachedChunk(sWorld, location.getChunk().getX(), location.getChunk().getZ())));
@ -349,7 +376,7 @@ public class StackingTask extends TimerTask {
* @param singleChunk Whether to only get entities in the same chunk as the entity. * @param singleChunk Whether to only get entities in the same chunk as the entity.
* @return A list of similar entities around the entity. * @return A list of similar entities around the entity.
*/ */
private List<LivingEntity> getFriendlyStacksNearby(LivingEntity entity, double radius, boolean singleChunk) { protected List<LivingEntity> getFriendlyStacksNearby(LivingEntity entity, double radius, boolean singleChunk) {
List<LivingEntity> entities = new ArrayList<>(); List<LivingEntity> entities = new ArrayList<>();
try { try {
Set<CachedChunk> chunks = getNearbyChunks(new SWorld(entity.getWorld()), entity.getLocation(), radius, singleChunk); Set<CachedChunk> chunks = getNearbyChunks(new SWorld(entity.getWorld()), entity.getLocation(), radius, singleChunk);
@ -639,7 +666,7 @@ public class StackingTask extends TimerTask {
|| (equipment.getBoots() != null && equipment.getBoots().getType() != Material.AIR)); || (equipment.getBoots() != null && equipment.getBoots().getType() != Material.AIR));
} }
private int getEntityStackSize(LivingEntity initialEntity) { protected int getEntityStackSize(LivingEntity initialEntity) {
Integer max = entityStackSizes.get(initialEntity.getType()); Integer max = entityStackSizes.get(initialEntity.getType());
if (max == null) { if (max == null) {
max = configurationSection.getInt("Mobs." + initialEntity.getType().name() + ".Max Stack Size"); max = configurationSection.getInt("Mobs." + initialEntity.getType().name() + ".Max Stack Size");

View File

@ -6,6 +6,7 @@ loadbefore: [WorldGuard]
main: com.songoda.ultimatestacker.UltimateStacker main: com.songoda.ultimatestacker.UltimateStacker
author: songoda author: songoda
api-version: 1.13 api-version: 1.13
folia-supported: true
commands: commands:
us: us:
description: Reloads the configuration file description: Reloads the configuration file