Compare commits

...

2 Commits

Author SHA1 Message Date
Brianna O'Keefe cb8a7dc505 version 3.1.7 2024-03-29 12:34:45 -05:00
Brianna O'Keefe 02818099ba Gotta hide all the 1.14+ stuff if you want all versions to be supported. 2024-03-29 12:34:41 -05:00
4 changed files with 13 additions and 12 deletions

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>com.craftaro</groupId> <groupId>com.craftaro</groupId>
<artifactId>UltimateStacker-Parent</artifactId> <artifactId>UltimateStacker-Parent</artifactId>
<version>3.1.6</version> <version>3.1.7</version>
</parent> </parent>
<artifactId>UltimateStacker-API</artifactId> <artifactId>UltimateStacker-API</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>com.craftaro</groupId> <groupId>com.craftaro</groupId>
<artifactId>UltimateStacker-Parent</artifactId> <artifactId>UltimateStacker-Parent</artifactId>
<version>3.1.6</version> <version>3.1.7</version>
</parent> </parent>
<artifactId>UltimateStacker-Plugin</artifactId> <artifactId>UltimateStacker-Plugin</artifactId>

View File

@ -12,7 +12,6 @@ import com.craftaro.ultimatestacker.utils.Async;
import com.craftaro.ultimatestacker.utils.Methods; import com.craftaro.ultimatestacker.utils.Methods;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.ExperienceOrb; import org.bukkit.entity.ExperienceOrb;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -31,7 +30,7 @@ import java.util.UUID;
public class EntityStackImpl implements EntityStack { public class EntityStackImpl implements EntityStack {
private final UltimateStacker plugin = UltimateStacker.getInstance(); private final UltimateStacker plugin = UltimateStacker.getInstance();
private final NamespacedKey STACKED_ENTITY_KEY = new NamespacedKey(plugin, "US_AMOUNT"); private Object STACKED_ENTITY_KEY;
private int amount; private int amount;
private LivingEntity hostEntity; private LivingEntity hostEntity;
@ -41,12 +40,14 @@ public class EntityStackImpl implements EntityStack {
* @param entity The entity to get the stack from. * @param entity The entity to get the stack from.
*/ */
public EntityStackImpl(LivingEntity entity) { public EntityStackImpl(LivingEntity entity) {
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14))
this.STACKED_ENTITY_KEY = new org.bukkit.NamespacedKey(plugin, "US_AMOUNT");
if (entity == null) return; if (entity == null) return;
if (!UltimateStacker.getInstance().getEntityStackManager().isStackedEntity(entity)) { if (!UltimateStacker.getInstance().getEntityStackManager().isStackedEntity(entity)) {
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14)) { if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14)) {
PersistentDataContainer container = entity.getPersistentDataContainer(); PersistentDataContainer container = entity.getPersistentDataContainer();
if (container.has(STACKED_ENTITY_KEY, PersistentDataType.INTEGER)) { if (container.has((org.bukkit.NamespacedKey) STACKED_ENTITY_KEY, PersistentDataType.INTEGER)) {
this.amount = container.get(STACKED_ENTITY_KEY, PersistentDataType.INTEGER); this.amount = container.get((org.bukkit.NamespacedKey) STACKED_ENTITY_KEY, PersistentDataType.INTEGER);
entity.setMetadata("US_AMOUNT", new FixedMetadataValue(UltimateStacker.getInstance(), amount)); entity.setMetadata("US_AMOUNT", new FixedMetadataValue(UltimateStacker.getInstance(), amount));
} else { } else {
entity.setMetadata("US_AMOUNT", new FixedMetadataValue(UltimateStacker.getInstance(), 1)); entity.setMetadata("US_AMOUNT", new FixedMetadataValue(UltimateStacker.getInstance(), 1));
@ -59,8 +60,8 @@ public class EntityStackImpl implements EntityStack {
} else { } else {
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14)) { if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14)) {
PersistentDataContainer container = entity.getPersistentDataContainer(); PersistentDataContainer container = entity.getPersistentDataContainer();
if (container.has(STACKED_ENTITY_KEY, PersistentDataType.INTEGER)) { if (container.has((org.bukkit.NamespacedKey) STACKED_ENTITY_KEY, PersistentDataType.INTEGER)) {
this.amount = container.get(STACKED_ENTITY_KEY, PersistentDataType.INTEGER); this.amount = container.get((org.bukkit.NamespacedKey) STACKED_ENTITY_KEY, PersistentDataType.INTEGER);
} else { } else {
this.amount = getMetaCount(entity); this.amount = getMetaCount(entity);
} }
@ -94,7 +95,7 @@ public class EntityStackImpl implements EntityStack {
this.amount = amount; this.amount = amount;
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14)) { if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14)) {
PersistentDataContainer container = entity.getPersistentDataContainer(); PersistentDataContainer container = entity.getPersistentDataContainer();
container.set(STACKED_ENTITY_KEY, PersistentDataType.INTEGER, amount); container.set((org.bukkit.NamespacedKey) STACKED_ENTITY_KEY, PersistentDataType.INTEGER, amount);
} else { } else {
entity.setMetadata("US_AMOUNT", new FixedMetadataValue(UltimateStacker.getInstance(), amount)); entity.setMetadata("US_AMOUNT", new FixedMetadataValue(UltimateStacker.getInstance(), amount));
} }
@ -116,7 +117,7 @@ public class EntityStackImpl implements EntityStack {
this.amount = amount; this.amount = amount;
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14)) { if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14)) {
PersistentDataContainer container = hostEntity.getPersistentDataContainer(); PersistentDataContainer container = hostEntity.getPersistentDataContainer();
container.set(STACKED_ENTITY_KEY, PersistentDataType.INTEGER, amount); container.set((org.bukkit.NamespacedKey) STACKED_ENTITY_KEY, PersistentDataType.INTEGER, amount);
} else { } else {
hostEntity.setMetadata("US_AMOUNT", new FixedMetadataValue(UltimateStacker.getInstance(), amount)); hostEntity.setMetadata("US_AMOUNT", new FixedMetadataValue(UltimateStacker.getInstance(), amount));
} }
@ -267,7 +268,7 @@ public class EntityStackImpl implements EntityStack {
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14)) { if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14)) {
PersistentDataContainer container = hostEntity.getPersistentDataContainer(); PersistentDataContainer container = hostEntity.getPersistentDataContainer();
container.remove(STACKED_ENTITY_KEY); container.remove((org.bukkit.NamespacedKey) STACKED_ENTITY_KEY);
} else { } else {
hostEntity.removeMetadata("US_AMOUNT", plugin); hostEntity.removeMetadata("US_AMOUNT", plugin);
} }

View File

@ -7,7 +7,7 @@
<groupId>com.craftaro</groupId> <groupId>com.craftaro</groupId>
<artifactId>UltimateStacker-Parent</artifactId> <artifactId>UltimateStacker-Parent</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>3.1.6</version> <version>3.1.7</version>
<modules> <modules>
<module>UltimateStacker-API</module> <module>UltimateStacker-API</module>