mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-12-04 07:53:22 +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 releaseHost();
|
||||||
|
|
||||||
void destroy();
|
void destroy();
|
||||||
|
|
||||||
|
void updateNameTag();
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,6 @@ public class EntityStackImpl implements EntityStack {
|
|||||||
this.amount = entity.getMetadata("US_AMOUNT").get(0).asInt();
|
this.amount = entity.getMetadata("US_AMOUNT").get(0).asInt();
|
||||||
}
|
}
|
||||||
this.hostEntity = entity;
|
this.hostEntity = entity;
|
||||||
updateNameTag();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -226,7 +225,7 @@ public class EntityStackImpl implements EntityStack {
|
|||||||
hostEntity = null;
|
hostEntity = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateNameTag() {
|
public void updateNameTag() {
|
||||||
if (hostEntity == null) {
|
if (hostEntity == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
import uk.antiperson.stackmob.api.StackedEntity;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -21,7 +22,9 @@ public class EntityStackManagerImpl implements EntityStackManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityStack createStackedEntity(LivingEntity entity, int amount) {
|
public EntityStack createStackedEntity(LivingEntity entity, int amount) {
|
||||||
return new EntityStackImpl(entity, amount);
|
EntityStackImpl stackedEntity = new EntityStackImpl(entity, amount);
|
||||||
|
stackedEntity.updateNameTag();
|
||||||
|
return stackedEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -74,6 +77,7 @@ public class EntityStackManagerImpl implements EntityStackManager {
|
|||||||
EntityStack stack = getStackedEntity(oldEntity);
|
EntityStack stack = getStackedEntity(oldEntity);
|
||||||
if (stack == null) return null;
|
if (stack == null) return null;
|
||||||
EntityStack newStack = new EntityStackImpl(newEntity, takeOne ? stack.getAmount()-1 : stack.getAmount());
|
EntityStack newStack = new EntityStackImpl(newEntity, takeOne ? stack.getAmount()-1 : stack.getAmount());
|
||||||
|
newStack.updateNameTag();
|
||||||
stack.destroy();
|
stack.destroy();
|
||||||
return newStack;
|
return newStack;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user