mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-11-13 05:44:19 +01:00
Improve performance
This commit is contained in:
parent
084d2c8348
commit
5d41e6ea36
@ -21,4 +21,6 @@ public interface EntityStack extends Stackable {
|
||||
void releaseHost();
|
||||
|
||||
void destroy();
|
||||
|
||||
void updateNameTag();
|
||||
}
|
||||
|
@ -50,7 +50,6 @@ public class EntityStackImpl implements EntityStack {
|
||||
this.amount = entity.getMetadata("US_AMOUNT").get(0).asInt();
|
||||
}
|
||||
this.hostEntity = entity;
|
||||
updateNameTag();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -226,7 +225,7 @@ public class EntityStackImpl implements EntityStack {
|
||||
hostEntity = null;
|
||||
}
|
||||
|
||||
private void updateNameTag() {
|
||||
public void updateNameTag() {
|
||||
if (hostEntity == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import uk.antiperson.stackmob.api.StackedEntity;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -21,7 +22,9 @@ public class EntityStackManagerImpl implements EntityStackManager {
|
||||
|
||||
@Override
|
||||
public EntityStack createStackedEntity(LivingEntity entity, int amount) {
|
||||
return new EntityStackImpl(entity, amount);
|
||||
EntityStackImpl stackedEntity = new EntityStackImpl(entity, amount);
|
||||
stackedEntity.updateNameTag();
|
||||
return stackedEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -74,6 +77,7 @@ public class EntityStackManagerImpl implements EntityStackManager {
|
||||
EntityStack stack = getStackedEntity(oldEntity);
|
||||
if (stack == null) return null;
|
||||
EntityStack newStack = new EntityStackImpl(newEntity, takeOne ? stack.getAmount()-1 : stack.getAmount());
|
||||
newStack.updateNameTag();
|
||||
stack.destroy();
|
||||
return newStack;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user