mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-12-31 21:07:47 +01:00
Fixed stacking support for 1.11-
This commit is contained in:
parent
a293c75fd2
commit
6ebf983692
@ -2,11 +2,12 @@ package com.songoda.ultimatestacker.entity;
|
|||||||
|
|
||||||
import com.songoda.ultimatestacker.UltimateStacker;
|
import com.songoda.ultimatestacker.UltimateStacker;
|
||||||
import com.songoda.ultimatestacker.utils.Methods;
|
import com.songoda.ultimatestacker.utils.Methods;
|
||||||
|
import com.songoda.ultimatestacker.utils.ServerVersion;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class EntityStack {
|
public class EntityStack {
|
||||||
|
|
||||||
private UUID entity;
|
private UUID entity;
|
||||||
@ -23,7 +24,7 @@ public class EntityStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateStack() {
|
public void updateStack() {
|
||||||
Entity entity = Bukkit.getEntity(this.entity);
|
Entity entity = getEntityByUniqueId(this.entity);
|
||||||
if (entity == null) return;
|
if (entity == null) return;
|
||||||
|
|
||||||
entity.setCustomNameVisible(true);
|
entity.setCustomNameVisible(true);
|
||||||
@ -31,7 +32,7 @@ public class EntityStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Entity getEntity() {
|
public Entity getEntity() {
|
||||||
Entity entity = Bukkit.getEntity(this.entity);
|
Entity entity = getEntityByUniqueId(this.entity);
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
UltimateStacker.getInstance().getEntityStackManager().removeStack(this.entity);
|
UltimateStacker.getInstance().getEntityStackManager().removeStack(this.entity);
|
||||||
return null;
|
return null;
|
||||||
@ -58,7 +59,7 @@ public class EntityStack {
|
|||||||
|
|
||||||
public void setAmount(int amount) {
|
public void setAmount(int amount) {
|
||||||
if (amount == 1) {
|
if (amount == 1) {
|
||||||
Entity entity = Bukkit.getEntity(this.entity);
|
Entity entity = getEntityByUniqueId(this.entity);
|
||||||
if (entity == null) return;
|
if (entity == null) return;
|
||||||
|
|
||||||
UltimateStacker.getInstance().getEntityStackManager().removeStack(this.entity);
|
UltimateStacker.getInstance().getEntityStackManager().removeStack(this.entity);
|
||||||
@ -71,6 +72,20 @@ public class EntityStack {
|
|||||||
updateStack();
|
updateStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Entity getEntityByUniqueId(UUID uniqueId) {
|
||||||
|
if (UltimateStacker.getInstance().isServerVersionAtLeast(ServerVersion.V1_12))
|
||||||
|
return Bukkit.getEntity(uniqueId);
|
||||||
|
|
||||||
|
for (World world : Bukkit.getWorlds()) {
|
||||||
|
for (Entity entity : world.getEntities()) {
|
||||||
|
if (entity.getUniqueId().equals(uniqueId))
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "EntityStack:{"
|
return "EntityStack:{"
|
||||||
|
Loading…
Reference in New Issue
Block a user