This commit is contained in:
Brianna O'Keefe 2019-03-14 18:53:28 -04:00
parent 39a19ee8d4
commit 5d5851c3a0
3 changed files with 28 additions and 34 deletions

View File

@ -10,6 +10,7 @@ import org.bukkit.block.Block;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
public class AnchorHandler {
@ -52,12 +53,8 @@ public class AnchorHandler {
Location location = anchor.getLocation();
location.getChunk().load();
Chunk chunk = location.getChunk();
int cx = chunk.getX() << 4;
int cz = chunk.getZ() << 4;
chunk.load();
int ticksLeft = anchor.getTicksLeft();
anchor.setTicksLeft(ticksLeft - 20);
@ -71,30 +68,27 @@ public class AnchorHandler {
chunk.unload();
}
if (!epicSpawners) continue;
for (int x = cx; x < cx + 16; x++) {
for (int z = cz; z < cz + 16; z++) {
for (int y = 0; y < location.getWorld().getMaxHeight(); y++) {
Block block = location.getWorld().getBlockAt(x, y, z);
if (block.getType() != Material.SPAWNER) continue;
Spawner spawner = EpicSpawnersAPI.getSpawnerManager().getSpawnerFromWorld(block.getLocation());
if (!delays.containsKey(block.getLocation())) {
if (block == null || block.getLocation() == null || spawner == null) continue;
delays.put(block.getLocation(), spawner.updateDelay());
continue;
}
int delay = delays.get(block.getLocation());
delay -= 20;
delays.put(block.getLocation(), delay);
if (delay <= 0) {
spawner.spawn();
delays.remove(block.getLocation());
}
}
EpicSpawnersAPI.getSpawnerManager().getSpawners().stream()
.filter(spawner -> spawner.getWorld().isChunkLoaded(spawner.getX() >> 4, spawner.getZ() >> 4)
&& chunk == spawner.getLocation().getChunk()).forEach(spawner -> {
Block block = spawner.getLocation().getBlock();
if (!delays.containsKey(block.getLocation())) {
if (block.getLocation() == null) return;
delays.put(block.getLocation(), spawner.updateDelay());
return;
}
}
int delay = delays.get(block.getLocation());
delay -= 20;
delays.put(block.getLocation(), delay);
if (delay <= 0) {
spawner.spawn();
delays.remove(block.getLocation());
}
});
}
}
}

View File

@ -1,6 +1,6 @@
name: EpicAnchors
description: EpicAnchors
version: 1.1.11
version: 1.1.12
softdepend: [EpicSpawners, Towny, RedProtect, Kingdoms, PlotsSquared, GriefPrevention, USkyBlock, ASkyBlock, WorldGuard, Factions, Vault]
main: com.songoda.epicanchors.EpicAnchorsPlugin
author: songoda

14
pom.xml
View File

@ -2,7 +2,7 @@
<groupId>com.songoda</groupId>
<artifactId>EpicAnchors</artifactId>
<modelVersion>4.0.0</modelVersion>
<version>1.1.10</version>
<version>1.1.12</version>
<build>
<defaultGoal>clean package</defaultGoal>
<plugins>
@ -58,22 +58,22 @@
<dependency>
<groupId>org</groupId>
<artifactId>kingdoms</artifactId>
<version>LATEST</version>
<version>13.0.9</version>
</dependency>
<dependency>
<groupId>net.milkbowl</groupId>
<artifactId>vault</artifactId>
<version>LATEST</version>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>me.ryanhamshire</groupId>
<artifactId>GriefPrevention</artifactId>
<version>LATEST</version>
<version>16.6</version>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldedit</artifactId>
<version>LATEST</version>
<version>7.0.0</version>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
@ -88,7 +88,7 @@
<dependency>
<groupId>com.palmergames.bukkit</groupId>
<artifactId>towny</artifactId>
<version>LATEST</version>
<version>0.93.0.0</version>
</dependency>
<dependency>
<groupId>com.wasteofplastic</groupId>
@ -98,7 +98,7 @@
<dependency>
<groupId>us.talabrek</groupId>
<artifactId>ultimateskyblock</artifactId>
<version>LATEST</version>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>me.markeh</groupId>