mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-09-27 14:12:59 +02:00
Merge branch 'development'
This commit is contained in:
commit
d5b16af85f
@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.craftaro</groupId>
|
<groupId>com.craftaro</groupId>
|
||||||
<artifactId>UltimateStacker-Parent</artifactId>
|
<artifactId>UltimateStacker-Parent</artifactId>
|
||||||
<version>3.1.2</version>
|
<version>3.1.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>UltimateStacker-API</artifactId>
|
<artifactId>UltimateStacker-API</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.craftaro</groupId>
|
<groupId>com.craftaro</groupId>
|
||||||
<artifactId>UltimateStacker-Parent</artifactId>
|
<artifactId>UltimateStacker-Parent</artifactId>
|
||||||
<version>3.1.2</version>
|
<version>3.1.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>UltimateStacker-Plugin</artifactId>
|
<artifactId>UltimateStacker-Plugin</artifactId>
|
||||||
|
|
||||||
|
@ -11,15 +11,19 @@ import com.craftaro.ultimatestacker.settings.Settings;
|
|||||||
import com.craftaro.ultimatestacker.stackable.entity.Check;
|
import com.craftaro.ultimatestacker.stackable.entity.Check;
|
||||||
import com.craftaro.ultimatestacker.stackable.entity.custom.CustomEntity;
|
import com.craftaro.ultimatestacker.stackable.entity.custom.CustomEntity;
|
||||||
import com.craftaro.ultimatestacker.utils.CachedChunk;
|
import com.craftaro.ultimatestacker.utils.CachedChunk;
|
||||||
import org.bukkit.*;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.inventory.EntityEquipment;
|
import org.bukkit.inventory.EntityEquipment;
|
||||||
import org.bukkit.persistence.PersistentDataContainer;
|
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.craftaro.ultimatestacker.stackable.entity.Check.getChecks;
|
import static com.craftaro.ultimatestacker.stackable.entity.Check.getChecks;
|
||||||
@ -64,7 +68,7 @@ public class StackingTask extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int tickRate = Settings.STACK_SEARCH_TICK_SPEED.getInt();
|
int tickRate = Settings.STACK_SEARCH_TICK_SPEED.getInt();
|
||||||
runTaskTimer(plugin, tickRate, tickRate);
|
runTaskTimerAsynchronously(plugin, tickRate, tickRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -75,7 +79,12 @@ public class StackingTask extends BukkitRunnable {
|
|||||||
for (SWorld sWorld : loadedWorlds) {
|
for (SWorld sWorld : loadedWorlds) {
|
||||||
List<LivingEntity> entities;
|
List<LivingEntity> entities;
|
||||||
// Get the loaded entities from the current world and reverse them.
|
// Get the loaded entities from the current world and reverse them.
|
||||||
entities = sWorld.getLivingEntities();
|
try {
|
||||||
|
entities = getLivingEntitiesSync(sWorld).get();
|
||||||
|
} catch (ExecutionException | InterruptedException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//Filter non-stackable entities to improve performance on main thread
|
//Filter non-stackable entities to improve performance on main thread
|
||||||
entities.removeIf(this::isEntityNotStackable);
|
entities.removeIf(this::isEntityNotStackable);
|
||||||
@ -87,6 +96,7 @@ public class StackingTask extends BukkitRunnable {
|
|||||||
entities.removeIf(entity1 -> entity1.getUniqueId().equals(entity.getUniqueId()));
|
entities.removeIf(entity1 -> entity1.getUniqueId().equals(entity.getUniqueId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||||
// Loop through the entities.
|
// Loop through the entities.
|
||||||
for (LivingEntity entity : entities) {
|
for (LivingEntity entity : entities) {
|
||||||
// Make sure our entity has not already been processed.
|
// Make sure our entity has not already been processed.
|
||||||
@ -99,16 +109,22 @@ public class StackingTask extends BukkitRunnable {
|
|||||||
// Process the entity.
|
// Process the entity.
|
||||||
processEntity(entity, location, entities);
|
processEntity(entity, location, entities);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
// Make sure we clear the processed list.
|
// Make sure we clear the processed list.
|
||||||
this.processed.clear();
|
this.processed.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Future<List<LivingEntity>> getLivingEntitiesSync(SWorld sWorld) {
|
||||||
|
CompletableFuture<List<LivingEntity>> future = new CompletableFuture<>();
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, () -> future.complete(sWorld.getLivingEntities()));
|
||||||
|
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));
|
||||||
}
|
}
|
||||||
|
2
pom.xml
2
pom.xml
@ -7,7 +7,7 @@
|
|||||||
<groupId>com.craftaro</groupId>
|
<groupId>com.craftaro</groupId>
|
||||||
<artifactId>UltimateStacker-Parent</artifactId>
|
<artifactId>UltimateStacker-Parent</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>3.1.2</version>
|
<version>3.1.3</version>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>UltimateStacker-API</module>
|
<module>UltimateStacker-API</module>
|
||||||
|
Loading…
Reference in New Issue
Block a user