Skip to content

Commit

Permalink
Version Increment
Browse files Browse the repository at this point in the history
  • Loading branch information
PeachesMLG committed May 4, 2024
1 parent 1d930f9 commit 7b22ffe
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = "com.iridium"
version = "1.0.0"
version = "1.0.1"
description = "MockNBTApi"

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
public class FakeNBTApiFactory implements NBTApiFactory{
@Override
public NBTItem getNBTItem(ItemStack itemStack) {
return new FakeNBTItem();
return FakeNBTItem.getFakeNBTItem(itemStack);
}
}
20 changes: 20 additions & 0 deletions src/main/java/com/iridium/mocknbtapi/FakeNBTItem.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
package com.iridium.mocknbtapi;

import org.bukkit.inventory.ItemStack;

import java.util.HashMap;

public class FakeNBTItem implements NBTItem {
private final ItemStack itemStack;
private final HashMap<String, Object> nbtData = new HashMap<>();
private final static HashMap<ItemStack, FakeNBTItem> fakeNBTItemHashMap = new HashMap<>();

public FakeNBTItem(ItemStack itemStack){
this.itemStack = itemStack;
}

public static FakeNBTItem getFakeNBTItem(ItemStack itemStack){
if(!fakeNBTItemHashMap.containsKey(itemStack)){
fakeNBTItemHashMap.put(itemStack, new FakeNBTItem(itemStack));
}
return fakeNBTItemHashMap.get(itemStack);
}

@Override
public void setString(String key, String value) {
Expand Down Expand Up @@ -44,4 +59,9 @@ public double getDouble(String key) {
public boolean getBoolean(String key) {
return (boolean) nbtData.get(key);
}

@Override
public ItemStack getItem() {
return itemStack;
}
}
4 changes: 4 additions & 0 deletions src/main/java/com/iridium/mocknbtapi/NBTItem.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.iridium.mocknbtapi;

import org.bukkit.inventory.ItemStack;

public interface NBTItem {
void setString(String key, String value);

Expand All @@ -16,4 +18,6 @@ public interface NBTItem {
double getDouble(String key);

boolean getBoolean(String key);

ItemStack getItem();
}
9 changes: 7 additions & 2 deletions src/main/java/com/iridium/mocknbtapi/RealNBTItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import org.bukkit.inventory.ItemStack;

public class RealNBTItem implements NBTItem{
public class RealNBTItem implements NBTItem {

private de.tr7zw.changeme.nbtapi.NBTItem nbtItem;

public RealNBTItem(ItemStack itemStack){
public RealNBTItem(ItemStack itemStack) {
nbtItem = new de.tr7zw.changeme.nbtapi.NBTItem(itemStack);
}

Expand Down Expand Up @@ -49,4 +49,9 @@ public double getDouble(String key) {
public boolean getBoolean(String key) {
return nbtItem.getBoolean(key);
}

@Override
public ItemStack getItem() {
return nbtItem.getItem();
}
}

0 comments on commit 7b22ffe

Please sign in to comment.