mirror of
https://github.com/BG-Software-LLC/WildLoaders.git
synced 2024-11-27 12:46:07 +01:00
Adds support to EpicSpawners 8
This commit is contained in:
parent
acafffd6a8
commit
6d1adf07cc
13
Hooks/EpicSpawners8/build.gradle
Normal file
13
Hooks/EpicSpawners8/build.gradle
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
group 'Hooks:EpicSpawners8'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnly "com.songoda:EpicSpawners:8.1.0"
|
||||||
|
compileOnly "org.spigotmc:v1_8_R3-Taco:latest"
|
||||||
|
compileOnly project(":API")
|
||||||
|
compileOnly rootProject
|
||||||
|
}
|
||||||
|
|
||||||
|
if (project.hasProperty('hook.compile_epicspawners8') &&
|
||||||
|
!Boolean.valueOf(project.findProperty("hook.compile_epicspawners8").toString())) {
|
||||||
|
project.tasks.all { task -> task.enabled = false }
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package com.bgsoftware.wildloaders.hooks;
|
||||||
|
|
||||||
|
import com.bgsoftware.wildloaders.api.hooks.TickableProvider;
|
||||||
|
import com.craftaro.epicspawners.api.EpicSpawnersApi;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
public final class TickableProvider_EpicSpawners8 implements TickableProvider {
|
||||||
|
|
||||||
|
private final Map<Location, TickDelay> spawnerDelays = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tick(Chunk[] chunks) {
|
||||||
|
if (EpicSpawnersApi.getSpawnerManager() == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
List<Long> chunkList = Stream.of(chunks).map(chunk -> pair(chunk.getX(), chunk.getZ())).collect(Collectors.toList());
|
||||||
|
|
||||||
|
EpicSpawnersApi.getSpawnerManager().getSpawners().stream()
|
||||||
|
.filter(spawner -> chunkList.contains(pair(spawner.getX() >> 4, spawner.getZ() >> 4)))
|
||||||
|
.forEach(spawner -> {
|
||||||
|
Location location = spawner.getLocation();
|
||||||
|
TickDelay tickDelay = spawnerDelays.get(location);
|
||||||
|
|
||||||
|
if (tickDelay == null) {
|
||||||
|
spawnerDelays.put(location, new TickDelay(spawner.updateDelay()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tickDelay.delay -= 1;
|
||||||
|
|
||||||
|
if (tickDelay.delay <= 0) {
|
||||||
|
spawner.spawn();
|
||||||
|
spawnerDelays.remove(location);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private long pair(int x, int z) {
|
||||||
|
return (x & 0xFFFFFFFFL) | (z & 0xFFFFFFFFL) << 32;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class TickDelay {
|
||||||
|
|
||||||
|
private int delay;
|
||||||
|
|
||||||
|
TickDelay(int delay) {
|
||||||
|
this.delay = delay;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -11,6 +11,7 @@ include 'API'
|
|||||||
include 'Hooks'
|
include 'Hooks'
|
||||||
include 'Hooks:EpicSpawners6'
|
include 'Hooks:EpicSpawners6'
|
||||||
include 'Hooks:EpicSpawners7'
|
include 'Hooks:EpicSpawners7'
|
||||||
|
include 'Hooks:EpicSpawners8'
|
||||||
include 'Hooks:FactionsUUID'
|
include 'Hooks:FactionsUUID'
|
||||||
include 'Hooks:FactionsX'
|
include 'Hooks:FactionsX'
|
||||||
include 'Hooks:Lands'
|
include 'Hooks:Lands'
|
||||||
@ -26,5 +27,4 @@ include 'NMS:v1_18'
|
|||||||
include 'NMS:v1_19'
|
include 'NMS:v1_19'
|
||||||
include 'NMS:v1_20_1'
|
include 'NMS:v1_20_1'
|
||||||
include 'NMS:v1_20_2'
|
include 'NMS:v1_20_2'
|
||||||
include 'NMS:v1_20_3'
|
include 'NMS:v1_20_3'
|
||||||
|
|
@ -60,12 +60,16 @@ public final class ProvidersHandler implements ProvidersManager {
|
|||||||
// Loading the tickable providers
|
// Loading the tickable providers
|
||||||
if (Bukkit.getPluginManager().isPluginEnabled("EpicSpawners")) {
|
if (Bukkit.getPluginManager().isPluginEnabled("EpicSpawners")) {
|
||||||
Plugin epicSpawners = Bukkit.getPluginManager().getPlugin("EpicSpawners");
|
Plugin epicSpawners = Bukkit.getPluginManager().getPlugin("EpicSpawners");
|
||||||
if (epicSpawners.getDescription().getVersion().startsWith("6")) {
|
String version = epicSpawners.getDescription().getVersion();
|
||||||
|
if (version.startsWith("6")) {
|
||||||
Optional<TickableProvider> tickableProvider = createInstance("TickableProvider_EpicSpawners6");
|
Optional<TickableProvider> tickableProvider = createInstance("TickableProvider_EpicSpawners6");
|
||||||
tickableProvider.ifPresent(this::addTickableProvider);
|
tickableProvider.ifPresent(this::addTickableProvider);
|
||||||
} else {
|
} else if(version.startsWith("7")) {
|
||||||
Optional<TickableProvider> tickableProvider = createInstance("TickableProvider_EpicSpawners7");
|
Optional<TickableProvider> tickableProvider = createInstance("TickableProvider_EpicSpawners7");
|
||||||
tickableProvider.ifPresent(this::addTickableProvider);
|
tickableProvider.ifPresent(this::addTickableProvider);
|
||||||
|
} else {
|
||||||
|
Optional<TickableProvider> tickableProvider = createInstance("TickableProvider_EpicSpawners8");
|
||||||
|
tickableProvider.ifPresent(this::addTickableProvider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user