Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
SpraxDev committed Mar 18, 2022
2 parents 443aef2 + 958b6fd commit 4c4bb15
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.songoda</groupId>
<artifactId>EpicAnchors</artifactId>
<version>2.2.0</version>
<version>2.2.1</version>

<name>EpicAnchors</name>
<description>Allow your players to keep chunks loaded for a limited amount of time for a cost.</description>
Expand Down Expand Up @@ -149,7 +149,7 @@
<dependency>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore</artifactId>
<version>2.6.10</version>
<version>2.6.12</version>
<scope>compile</scope>
</dependency>

Expand Down
24 changes: 13 additions & 11 deletions src/main/java/com/songoda/epicanchors/AnchorManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import com.songoda.core.compatibility.CompatibleParticleHandler;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.hooks.HologramManager;
import com.songoda.core.nms.NmsManager;
import com.songoda.core.nms.nbt.NBTItem;
import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem;
import com.songoda.core.utils.TextUtils;
import com.songoda.core.utils.TimeUtils;
import com.songoda.epicanchors.api.AnchorAccessCheck;
Expand Down Expand Up @@ -358,24 +357,27 @@ public ItemStack createAnchorItem(int ticks, CompatibleMaterial material) {
meta.setLore(TextUtils.formatText(Settings.LORE.getString().split("\r?\n")));
item.setItemMeta(meta);

NBTItem nbtItem = NmsManager.getNbt().of(item);
nbtItem.set(NBT_TICKS_KEY, ticks);
NBTItem nbtItem = new NBTItem(item);
nbtItem.setInteger(NBT_TICKS_KEY, ticks);

return nbtItem.finish();
return nbtItem.getItem();
}

public static int getTicksFromItem(ItemStack item) {
NBTItem nbtItem = NmsManager.getNbt().of(item);
if (item == null || item.getType() == Material.AIR) {
return 0;
}

NBTItem nbtItem = new NBTItem(item);

if (nbtItem.has(NBT_TICKS_KEY)) {
return nbtItem.getInt(NBT_TICKS_KEY);
if (nbtItem.hasKey(NBT_TICKS_KEY)) {
return nbtItem.getInteger(NBT_TICKS_KEY);
}

// Legacy code (pre v2) to stay cross-version compatible
if (Settings.MATERIAL.getMaterial().getMaterial() == item.getType()) {

if (nbtItem.has("ticks")) {
int result = nbtItem.getInt("ticks");
if (nbtItem.hasKey("ticks")) {
int result = nbtItem.getInteger("ticks");

return result == -99 ? -1 : result;
}
Expand Down

0 comments on commit 4c4bb15

Please sign in to comment.