mirror of
https://github.com/songoda/EpicAnchors.git
synced 2024-09-29 06:27:28 +02:00
faster
This commit is contained in:
parent
39a19ee8d4
commit
5d5851c3a0
@ -10,6 +10,7 @@ import org.bukkit.block.Block;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class AnchorHandler {
|
public class AnchorHandler {
|
||||||
|
|
||||||
@ -52,12 +53,8 @@ public class AnchorHandler {
|
|||||||
|
|
||||||
Location location = anchor.getLocation();
|
Location location = anchor.getLocation();
|
||||||
|
|
||||||
location.getChunk().load();
|
|
||||||
|
|
||||||
Chunk chunk = location.getChunk();
|
Chunk chunk = location.getChunk();
|
||||||
|
chunk.load();
|
||||||
int cx = chunk.getX() << 4;
|
|
||||||
int cz = chunk.getZ() << 4;
|
|
||||||
|
|
||||||
int ticksLeft = anchor.getTicksLeft();
|
int ticksLeft = anchor.getTicksLeft();
|
||||||
anchor.setTicksLeft(ticksLeft - 20);
|
anchor.setTicksLeft(ticksLeft - 20);
|
||||||
@ -71,30 +68,27 @@ public class AnchorHandler {
|
|||||||
chunk.unload();
|
chunk.unload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!epicSpawners) continue;
|
if (!epicSpawners) continue;
|
||||||
|
|
||||||
for (int x = cx; x < cx + 16; x++) {
|
EpicSpawnersAPI.getSpawnerManager().getSpawners().stream()
|
||||||
for (int z = cz; z < cz + 16; z++) {
|
.filter(spawner -> spawner.getWorld().isChunkLoaded(spawner.getX() >> 4, spawner.getZ() >> 4)
|
||||||
for (int y = 0; y < location.getWorld().getMaxHeight(); y++) {
|
&& chunk == spawner.getLocation().getChunk()).forEach(spawner -> {
|
||||||
Block block = location.getWorld().getBlockAt(x, y, z);
|
Block block = spawner.getLocation().getBlock();
|
||||||
if (block.getType() != Material.SPAWNER) continue;
|
|
||||||
Spawner spawner = EpicSpawnersAPI.getSpawnerManager().getSpawnerFromWorld(block.getLocation());
|
if (!delays.containsKey(block.getLocation())) {
|
||||||
if (!delays.containsKey(block.getLocation())) {
|
if (block.getLocation() == null) return;
|
||||||
if (block == null || block.getLocation() == null || spawner == null) continue;
|
delays.put(block.getLocation(), spawner.updateDelay());
|
||||||
delays.put(block.getLocation(), spawner.updateDelay());
|
return;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
int delay = delays.get(block.getLocation());
|
|
||||||
delay -= 20;
|
|
||||||
delays.put(block.getLocation(), delay);
|
|
||||||
if (delay <= 0) {
|
|
||||||
spawner.spawn();
|
|
||||||
delays.remove(block.getLocation());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
int delay = delays.get(block.getLocation());
|
||||||
|
delay -= 20;
|
||||||
|
delays.put(block.getLocation(), delay);
|
||||||
|
if (delay <= 0) {
|
||||||
|
spawner.spawn();
|
||||||
|
delays.remove(block.getLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: EpicAnchors
|
name: EpicAnchors
|
||||||
description: EpicAnchors
|
description: EpicAnchors
|
||||||
version: 1.1.11
|
version: 1.1.12
|
||||||
softdepend: [EpicSpawners, Towny, RedProtect, Kingdoms, PlotsSquared, GriefPrevention, USkyBlock, ASkyBlock, WorldGuard, Factions, Vault]
|
softdepend: [EpicSpawners, Towny, RedProtect, Kingdoms, PlotsSquared, GriefPrevention, USkyBlock, ASkyBlock, WorldGuard, Factions, Vault]
|
||||||
main: com.songoda.epicanchors.EpicAnchorsPlugin
|
main: com.songoda.epicanchors.EpicAnchorsPlugin
|
||||||
author: songoda
|
author: songoda
|
||||||
|
14
pom.xml
14
pom.xml
@ -2,7 +2,7 @@
|
|||||||
<groupId>com.songoda</groupId>
|
<groupId>com.songoda</groupId>
|
||||||
<artifactId>EpicAnchors</artifactId>
|
<artifactId>EpicAnchors</artifactId>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<version>1.1.10</version>
|
<version>1.1.12</version>
|
||||||
<build>
|
<build>
|
||||||
<defaultGoal>clean package</defaultGoal>
|
<defaultGoal>clean package</defaultGoal>
|
||||||
<plugins>
|
<plugins>
|
||||||
@ -58,22 +58,22 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org</groupId>
|
<groupId>org</groupId>
|
||||||
<artifactId>kingdoms</artifactId>
|
<artifactId>kingdoms</artifactId>
|
||||||
<version>LATEST</version>
|
<version>13.0.9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.milkbowl</groupId>
|
<groupId>net.milkbowl</groupId>
|
||||||
<artifactId>vault</artifactId>
|
<artifactId>vault</artifactId>
|
||||||
<version>LATEST</version>
|
<version>1.7.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.ryanhamshire</groupId>
|
<groupId>me.ryanhamshire</groupId>
|
||||||
<artifactId>GriefPrevention</artifactId>
|
<artifactId>GriefPrevention</artifactId>
|
||||||
<version>LATEST</version>
|
<version>16.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q</groupId>
|
<groupId>com.sk89q</groupId>
|
||||||
<artifactId>worldedit</artifactId>
|
<artifactId>worldedit</artifactId>
|
||||||
<version>LATEST</version>
|
<version>7.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q</groupId>
|
<groupId>com.sk89q</groupId>
|
||||||
@ -88,7 +88,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.palmergames.bukkit</groupId>
|
<groupId>com.palmergames.bukkit</groupId>
|
||||||
<artifactId>towny</artifactId>
|
<artifactId>towny</artifactId>
|
||||||
<version>LATEST</version>
|
<version>0.93.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.wasteofplastic</groupId>
|
<groupId>com.wasteofplastic</groupId>
|
||||||
@ -98,7 +98,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>us.talabrek</groupId>
|
<groupId>us.talabrek</groupId>
|
||||||
<artifactId>ultimateskyblock</artifactId>
|
<artifactId>ultimateskyblock</artifactId>
|
||||||
<version>LATEST</version>
|
<version>2.7.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.markeh</groupId>
|
<groupId>me.markeh</groupId>
|
||||||
|
Loading…
Reference in New Issue
Block a user