optimize import and code reformat
This commit is contained in:
parent
36f8e3f6f0
commit
64ef73f7e0
15 changed files with 379 additions and 371 deletions
|
@ -19,17 +19,10 @@ import org.jetbrains.annotations.Nullable;
|
|||
|
||||
public class SRPlayer {
|
||||
|
||||
@Expose
|
||||
private final UUID uuid;
|
||||
|
||||
@Expose
|
||||
private Inventory inventory;
|
||||
|
||||
@Expose
|
||||
private final HashMap<Attribute, Double> attributes;
|
||||
|
||||
@Expose
|
||||
private final List<PotionEffect> potionEffects;
|
||||
@Expose private final UUID uuid;
|
||||
@Expose private final HashMap<Attribute, Double> attributes;
|
||||
@Expose private final List<PotionEffect> potionEffects;
|
||||
@Expose private Inventory inventory;
|
||||
|
||||
public SRPlayer(@NotNull Player player) {
|
||||
this.uuid = player.getUniqueId();
|
||||
|
@ -43,15 +36,15 @@ public class SRPlayer {
|
|||
return uuid;
|
||||
}
|
||||
|
||||
public void setInventory(Inventory inventory) {
|
||||
this.inventory = inventory;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public void setInventory(Inventory inventory) {
|
||||
this.inventory = inventory;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public HashMap<Attribute, Double> getAttributes() {
|
||||
return attributes;
|
||||
|
@ -80,11 +73,12 @@ public class SRPlayer {
|
|||
if (p == null) {
|
||||
return null;
|
||||
}
|
||||
Object o = p.getInventory()
|
||||
.getItemInMainHand()
|
||||
.getItemMeta()
|
||||
.getPersistentDataContainer()
|
||||
.get(attribute.getKey(), attribute.getType());
|
||||
Object o =
|
||||
p.getInventory()
|
||||
.getItemInMainHand()
|
||||
.getItemMeta()
|
||||
.getPersistentDataContainer()
|
||||
.get(attribute.getKey(), attribute.getType());
|
||||
if (o == null) {
|
||||
setHandItemAttribute(attribute, attribute.getDefaultValue());
|
||||
return attribute.getDefaultValue();
|
||||
|
@ -97,23 +91,20 @@ public class SRPlayer {
|
|||
if (p == null) {
|
||||
return;
|
||||
}
|
||||
if (checkIfValueIsOutOfBoundsForAttribute(attribute, value, p))
|
||||
return;
|
||||
if (checkIfValueIsOutOfBoundsForAttribute(attribute, value, p)) return;
|
||||
ItemStack i = p.getInventory().getItemInMainHand();
|
||||
ItemMeta im = i.getItemMeta();
|
||||
im.getPersistentDataContainer()
|
||||
.set(attribute.getKey(), PersistentDataType.DOUBLE, value);
|
||||
im.getPersistentDataContainer().set(attribute.getKey(), PersistentDataType.DOUBLE, value);
|
||||
im.lore();
|
||||
}
|
||||
|
||||
private boolean checkIfValueIsOutOfBoundsForAttribute(@NotNull Attribute attribute,
|
||||
@NotNull Double value,
|
||||
Player p) {
|
||||
private boolean checkIfValueIsOutOfBoundsForAttribute(
|
||||
@NotNull Attribute attribute, @NotNull Double value, Player p) {
|
||||
if (!attribute.getType().getComplexType().isInstance(value)) {
|
||||
return true;
|
||||
}
|
||||
if (attribute.getType().equals(PersistentDataType.DOUBLE)) {
|
||||
double d = (double) value;
|
||||
double d = value;
|
||||
if (d < attribute.getMinValue() || d > attribute.getMaxValue()) {
|
||||
warn(
|
||||
"(Player "
|
||||
|
@ -157,13 +148,13 @@ public class SRPlayer {
|
|||
potionEffects.clear();
|
||||
}
|
||||
|
||||
public void setPotionEffects(@NotNull List<PotionEffect> effects) {
|
||||
potionEffects.clear();
|
||||
potionEffects.addAll(effects);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<PotionEffect> getPotionEffects() {
|
||||
return potionEffects;
|
||||
}
|
||||
|
||||
public void setPotionEffects(@NotNull List<PotionEffect> effects) {
|
||||
potionEffects.clear();
|
||||
potionEffects.addAll(effects);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue