This commit is contained in:
parent
6af48441a4
commit
acc7f076e0
7 changed files with 262 additions and 3 deletions
|
@ -18,6 +18,18 @@ public class Treasure {
|
|||
|
||||
public Treasure() {}
|
||||
|
||||
public Treasure(Location location) {
|
||||
this.location = location;
|
||||
this.items = new HashMap<>();
|
||||
this.permission = "";
|
||||
}
|
||||
|
||||
public Treasure(Location location, String permission) {
|
||||
this.location = location;
|
||||
this.items = new HashMap<>();
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
public Treasure(Location location, Map<Integer, ItemStack> items, String permission) {
|
||||
this.location = location;
|
||||
this.items = items;
|
||||
|
@ -46,7 +58,7 @@ public class Treasure {
|
|||
return items;
|
||||
}
|
||||
|
||||
public void setItems(HashMap<Integer, ItemStack> items) {
|
||||
public void setItems(Map<Integer, ItemStack> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,12 @@ import com.google.gson.Gson;
|
|||
import com.google.gson.GsonBuilder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import me.unurled.sacredrealms.sr.data.DataHandler;
|
||||
import me.unurled.sacredrealms.sr.data.DataManager;
|
||||
import me.unurled.sacredrealms.sr.managers.Manager;
|
||||
import org.bukkit.Location;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TreasureManager extends Manager {
|
||||
private final List<Treasure> treasures = new ArrayList<>();
|
||||
|
@ -36,4 +39,27 @@ public class TreasureManager extends Manager {
|
|||
treasures.add(gson.fromJson(dh.get("treasures." + key), Treasure.class));
|
||||
}
|
||||
}
|
||||
|
||||
public void addTreasure(Treasure treasure) {
|
||||
treasures.add(treasure);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Treasure findByLocation(@NotNull Location loc) {
|
||||
for (Treasure treasure : treasures) {
|
||||
if (treasure.getLocation().equals(loc)) {
|
||||
return treasure;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<Treasure> getTreasures() {
|
||||
return treasures;
|
||||
}
|
||||
|
||||
public void removeTreasure(@NotNull Treasure treasure) {
|
||||
treasures.remove(treasure);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue