code refactoring
This commit is contained in:
parent
abd733fd09
commit
57ddb6ca01
1 changed files with 11 additions and 8 deletions
|
@ -7,6 +7,7 @@ import com.google.gson.annotations.Expose;
|
|||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import me.unurled.sacredrealms.sr.components.attributes.Attribute;
|
||||
import me.unurled.sacredrealms.sr.components.item.Item;
|
||||
|
@ -40,10 +41,6 @@ public class SRPlayer {
|
|||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public SRPlayer(@NotNull Player player) {
|
||||
this.uuid = player.getUniqueId();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
|
@ -59,7 +56,7 @@ public class SRPlayer {
|
|||
}
|
||||
|
||||
@NotNull
|
||||
public HashMap<Attribute, Double> getAttributes() {
|
||||
public Map<Attribute, Double> getAttributes() {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
|
@ -151,14 +148,17 @@ public class SRPlayer {
|
|||
i.setItemMeta(im);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void addPotionEffect(@NotNull PotionEffect effect) {
|
||||
potionEffects.add(effect);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void removePotionEffect(@NotNull PotionEffect effect) {
|
||||
potionEffects.remove(effect);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void clearPotionEffects() {
|
||||
potionEffects.clear();
|
||||
}
|
||||
|
@ -193,6 +193,7 @@ public class SRPlayer {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public @Nullable Double getItemAttributes(@NotNull Attribute attribute, @NotNull ItemStack item) {
|
||||
if (itemAttributes == null) itemAttributes = new HashMap<>();
|
||||
if (itemAttributes.containsKey(attribute)) {
|
||||
|
@ -201,15 +202,17 @@ public class SRPlayer {
|
|||
return null;
|
||||
}
|
||||
|
||||
public @NotNull HashMap<ItemStack, Double> getItemAttributes(@NotNull Attribute attribute) {
|
||||
@SuppressWarnings("unused")
|
||||
public @NotNull Map<ItemStack, Double> getItemAttributes(@NotNull Attribute attribute) {
|
||||
if (itemAttributes == null) itemAttributes = new HashMap<>();
|
||||
return itemAttributes.getOrDefault(attribute, new HashMap<>());
|
||||
}
|
||||
|
||||
public @NotNull HashMap<Attribute, Double> getItemAttributes(Item item) {
|
||||
@SuppressWarnings("unused")
|
||||
public @NotNull Map<Attribute, Double> getItemAttributes(Item item) {
|
||||
if (itemAttributes == null) itemAttributes = new HashMap<>();
|
||||
HashMap<Attribute, Double> map = new HashMap<>();
|
||||
itemAttributes.forEach((k, v) -> map.put(k, v.get(item)));
|
||||
itemAttributes.forEach((k, v) -> map.put(k, v.getOrDefault(item.toItemStack(), 0d)));
|
||||
return map;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue