mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-11-15 22:55:24 +01:00
Major performance improvements.
This commit is contained in:
parent
80a81a1cb8
commit
7a1cede33b
@ -25,7 +25,7 @@ public class EntityStackManager {
|
||||
|
||||
public EntityStack addStack(UUID uuid, int amount) {
|
||||
EntityStack stack = new EntityStack(uuid, amount);
|
||||
stacks.put(uuid, new EntityStack(uuid, amount));
|
||||
stacks.put(uuid, stack);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ public class EntityStackManager {
|
||||
if (!name.contains(":")) return null;
|
||||
String split = name.split(":")[0];
|
||||
int amount = Methods.isInt(split) ? Integer.parseInt(split) : 0;
|
||||
addStack(entity, amount);
|
||||
return addStack(entity, amount);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -2,7 +2,9 @@ package com.songoda.ultimatestacker.utils;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@ -16,6 +18,10 @@ public class CachedChunk {
|
||||
this(chunk.getWorld().getName(), chunk.getX(), chunk.getZ());
|
||||
}
|
||||
|
||||
public CachedChunk(Location location) {
|
||||
this(location.getWorld().getName(), (int)location.getX() >> 4, (int)location.getZ() >> 4);
|
||||
}
|
||||
|
||||
public CachedChunk(String world, int x, int z) {
|
||||
this.world = world;
|
||||
this.x = x;
|
||||
@ -41,6 +47,13 @@ public class CachedChunk {
|
||||
return world.getChunkAt(this.x, this.z);
|
||||
}
|
||||
|
||||
public Entity[] getEntities() {
|
||||
if (!Bukkit.getWorld(world).isChunkLoaded(x, z)) {
|
||||
return new Entity[0];
|
||||
}
|
||||
return getChunk().getEntities();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof Chunk) {
|
||||
|
Loading…
Reference in New Issue
Block a user