optimize import and code reformat
This commit is contained in:
parent
36f8e3f6f0
commit
64ef73f7e0
15 changed files with 379 additions and 371 deletions
|
@ -4,49 +4,13 @@ import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
|
||||||
public enum Attribute {
|
public enum Attribute {
|
||||||
HEALTH(
|
HEALTH("HEALTH", "Health", 100, 100000, 0, new NamespacedKey("sr", "health")),
|
||||||
"HEALTH",
|
STRENGTH("STRENGTH", "Strength", 10, 10000, 0, new NamespacedKey("sr", "strength")),
|
||||||
"Health",
|
DEFENSE("DEFENSE", "Defense", 10, 10000, 0, new NamespacedKey("sr", "defense")),
|
||||||
100,
|
AGILITY("AGILITY", "Agility", 100, 10000, 0, new NamespacedKey("sr", "agility")),
|
||||||
100000,
|
LUCK("LUCK", "Luck", 100, 99999, -99999, new NamespacedKey("sr", "luck")),
|
||||||
0,
|
|
||||||
new NamespacedKey("sr", "health")),
|
|
||||||
STRENGTH(
|
|
||||||
"STRENGTH",
|
|
||||||
"Strength",
|
|
||||||
10,
|
|
||||||
10000,
|
|
||||||
0,
|
|
||||||
new NamespacedKey("sr", "strength")),
|
|
||||||
DEFENSE(
|
|
||||||
"DEFENSE",
|
|
||||||
"Defense",
|
|
||||||
10,
|
|
||||||
10000,
|
|
||||||
0,
|
|
||||||
new NamespacedKey("sr", "defense")),
|
|
||||||
AGILITY(
|
|
||||||
"AGILITY",
|
|
||||||
"Agility",
|
|
||||||
100,
|
|
||||||
10000,
|
|
||||||
0,
|
|
||||||
new NamespacedKey("sr", "agility")),
|
|
||||||
LUCK(
|
|
||||||
"LUCK",
|
|
||||||
"Luck",
|
|
||||||
100,
|
|
||||||
99999,
|
|
||||||
-99999,
|
|
||||||
new NamespacedKey("sr", "luck")),
|
|
||||||
MANA("MANA", "Mana", 100, 10000, 0, new NamespacedKey("sr", "mana")),
|
MANA("MANA", "Mana", 100, 10000, 0, new NamespacedKey("sr", "mana")),
|
||||||
CHARISMA(
|
CHARISMA("CHARISMA", "Charisma", 0, 10000, -10000, new NamespacedKey("sr", "charisma")),
|
||||||
"CHARISMA",
|
|
||||||
"Charisma",
|
|
||||||
0,
|
|
||||||
10000,
|
|
||||||
-10000,
|
|
||||||
new NamespacedKey("sr", "charisma")),
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
@ -57,12 +21,7 @@ public enum Attribute {
|
||||||
private final NamespacedKey key;
|
private final NamespacedKey key;
|
||||||
|
|
||||||
Attribute(
|
Attribute(
|
||||||
String ID,
|
String ID, String name, int defaultValue, int maxValue, int minValue, NamespacedKey key) {
|
||||||
String name,
|
|
||||||
int defaultValue,
|
|
||||||
int maxValue,
|
|
||||||
int minValue,
|
|
||||||
NamespacedKey key) {
|
|
||||||
this.ID = ID;
|
this.ID = ID;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.defaultValue = defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
|
|
|
@ -34,7 +34,8 @@ public class CombatManager extends Manager {
|
||||||
public void onDamage(EntityDamageByEntityEvent e) {
|
public void onDamage(EntityDamageByEntityEvent e) {
|
||||||
e.setDamage(0.0);
|
e.setDamage(0.0);
|
||||||
|
|
||||||
if (!(e.getDamager() instanceof LivingEntity damager) || !(e.getEntity() instanceof LivingEntity entity)) {
|
if (!(e.getDamager() instanceof LivingEntity damager)
|
||||||
|
|| !(e.getEntity() instanceof LivingEntity entity)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlayerManager pm = (PlayerManager) PlayerManager.getInstance(PlayerManager.class);
|
PlayerManager pm = (PlayerManager) PlayerManager.getInstance(PlayerManager.class);
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package me.unurled.sacredrealms.sr.components.item;
|
package me.unurled.sacredrealms.sr.components.item;
|
||||||
|
|
||||||
|
import static me.unurled.sacredrealms.sr.utils.Component.comp;
|
||||||
|
import static me.unurled.sacredrealms.sr.utils.Items.lore;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.unurled.sacredrealms.sr.components.attributes.Attribute;
|
import me.unurled.sacredrealms.sr.components.attributes.Attribute;
|
||||||
|
@ -7,6 +10,10 @@ import me.unurled.sacredrealms.sr.components.item.abilities.Ability;
|
||||||
import me.unurled.sacredrealms.sr.components.item.enchantments.Enchantment;
|
import me.unurled.sacredrealms.sr.components.item.enchantments.Enchantment;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.persistence.PersistentDataContainer;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/* <b><color of the rarity>rarity
|
/* <b><color of the rarity>rarity
|
||||||
* <dark_gray>Description: blablabla
|
* <dark_gray>Description: blablabla
|
||||||
|
@ -31,119 +38,175 @@ import org.bukkit.inventory.ItemStack;
|
||||||
* */
|
* */
|
||||||
public class Item {
|
public class Item {
|
||||||
|
|
||||||
private final String ID;
|
@NotNull private final String ID;
|
||||||
|
|
||||||
private String name;
|
@NotNull private String name;
|
||||||
|
|
||||||
private Material material;
|
@NotNull private Material material;
|
||||||
|
|
||||||
private String description;
|
@NotNull private String description;
|
||||||
|
|
||||||
private Rarity rarity;
|
@NotNull private Integer customModelData;
|
||||||
|
|
||||||
private HashMap<Attribute, Double> attributes;
|
@NotNull private Rarity rarity;
|
||||||
|
|
||||||
private HashMap<Enchantment, Integer> enchantments;
|
@NotNull private HashMap<Attribute, Double> attributes;
|
||||||
|
|
||||||
private List<Ability> abilities;
|
@NotNull private HashMap<Enchantment, Integer> enchantments;
|
||||||
|
|
||||||
public Item(String ID, String name, Material material) {
|
@NotNull private List<Ability> abilities;
|
||||||
this.ID = ID;
|
|
||||||
this.name = name;
|
public Item(@NotNull String ID, @NotNull String name, @NotNull Material material) {
|
||||||
this.material = material;
|
this.ID = ID;
|
||||||
|
this.name = name;
|
||||||
|
this.material = material;
|
||||||
|
this.description = "";
|
||||||
|
this.rarity = Rarity.COMMON;
|
||||||
|
this.customModelData = 0;
|
||||||
|
this.abilities = List.of();
|
||||||
|
this.attributes = new HashMap<>();
|
||||||
|
this.enchantments = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull String getID() {
|
||||||
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(@NotNull String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Material getMaterial() {
|
||||||
|
return material;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaterial(@NotNull Material material) {
|
||||||
|
this.material = material;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Rarity getRarity() {
|
||||||
|
return rarity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRarity(Rarity rarity) {
|
||||||
|
this.rarity = rarity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<Attribute, Double> getAttributes() {
|
||||||
|
return attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAttributes(HashMap<Attribute, Double> attributes) {
|
||||||
|
this.attributes = attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getAttribute(Attribute attribute) {
|
||||||
|
return attributes.get(attribute);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAttribute(Attribute attribute, double value) {
|
||||||
|
attributes.put(attribute, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAttribute(Attribute attribute) {
|
||||||
|
attributes.remove(attribute);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<Enchantment, Integer> getEnchantments() {
|
||||||
|
return enchantments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnchantments(HashMap<Enchantment, Integer> enchantments) {
|
||||||
|
this.enchantments = enchantments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEnchantment(Enchantment enchantment, int level) {
|
||||||
|
enchantments.put(enchantment, level);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeEnchantment(Enchantment enchantment) {
|
||||||
|
enchantments.remove(enchantment);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Ability> getAbilities() {
|
||||||
|
return abilities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAbilities(List<Ability> abilities) {
|
||||||
|
this.abilities = abilities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAbility(Ability ability) {
|
||||||
|
abilities.add(ability);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAbility(Ability ability) {
|
||||||
|
abilities.remove(ability);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getCustomModelData() {
|
||||||
|
return customModelData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCustomModelData(Integer customModelData) {
|
||||||
|
this.customModelData = customModelData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack toItemStack() {
|
||||||
|
ItemStack item = new ItemStack(material);
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
if (meta == null) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getID() {
|
PersistentDataContainer p = meta.getPersistentDataContainer();
|
||||||
return ID;
|
p.set(ItemManager.ID, PersistentDataType.STRING, ID);
|
||||||
|
|
||||||
|
meta.displayName(comp(name).color(rarity.getColor()));
|
||||||
|
|
||||||
|
if (customModelData != 0) {
|
||||||
|
meta.setCustomModelData(customModelData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
lore(item);
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
item.setItemMeta(meta);
|
||||||
this.name = name;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Material getMaterial() {
|
@Override
|
||||||
return material;
|
public String toString() {
|
||||||
}
|
return "{"
|
||||||
|
+ "ID: "
|
||||||
public void setMaterial(Material material) {
|
+ ID
|
||||||
this.material = material;
|
+ ", name: "
|
||||||
}
|
+ name
|
||||||
|
+ ", material: "
|
||||||
public String getDescription() {
|
+ material
|
||||||
return description;
|
+ ", description: "
|
||||||
}
|
+ description
|
||||||
|
+ ", customModelData: "
|
||||||
public void setDescription(String description) {
|
+ customModelData
|
||||||
this.description = description;
|
+ ", rarity: "
|
||||||
}
|
+ rarity
|
||||||
|
+ ", attributes: "
|
||||||
public Rarity getRarity() {
|
+ attributes
|
||||||
return rarity;
|
+ ", enchantments: "
|
||||||
}
|
+ enchantments
|
||||||
|
+ ", abilities: "
|
||||||
public void setRarity(Rarity rarity) {
|
+ abilities
|
||||||
this.rarity = rarity;
|
+ "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<Attribute, Double> getAttributes() {
|
|
||||||
return attributes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Double getAttribute(Attribute attribute) {
|
|
||||||
return attributes.get(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAttributes(HashMap<Attribute, Double> attributes) {
|
|
||||||
this.attributes = attributes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addAttribute(Attribute attribute, double value) {
|
|
||||||
attributes.put(attribute, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeAttribute(Attribute attribute) {
|
|
||||||
attributes.remove(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<Enchantment, Integer> getEnchantments() {
|
|
||||||
return enchantments;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnchantments(HashMap<Enchantment, Integer> enchantments) {
|
|
||||||
this.enchantments = enchantments;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addEnchantment(Enchantment enchantment, int level) {
|
|
||||||
enchantments.put(enchantment, level);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeEnchantment(Enchantment enchantment) {
|
|
||||||
enchantments.remove(enchantment);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Ability> getAbilities() {
|
|
||||||
return abilities;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAbilities(List<Ability> abilities) {
|
|
||||||
this.abilities = abilities;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addAbility(Ability ability) {
|
|
||||||
abilities.add(ability);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeAbility(Ability ability) {
|
|
||||||
abilities.remove(ability);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack toItemStack() {
|
|
||||||
ItemStack item = new ItemStack(material);
|
|
||||||
// set item meta
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,10 @@ public enum Rarity {
|
||||||
SPECIAL("<red>Special", "SPECIAL", 7, NamedTextColor.RED),
|
SPECIAL("<red>Special", "SPECIAL", 7, NamedTextColor.RED),
|
||||||
UNIQUE("<yellow>Unique", "UNIQUE", 8, NamedTextColor.YELLOW),
|
UNIQUE("<yellow>Unique", "UNIQUE", 8, NamedTextColor.YELLOW),
|
||||||
ADMIN(
|
ADMIN(
|
||||||
"<color:#800000><obf>aa</obf><dark_red>Admin</dark_red><obf>aa</obf></color>", "ADMIN", 100, NamedTextColor.DARK_RED);
|
"<color:#800000><obf>aa</obf><dark_red>Admin</dark_red><obf>aa</obf></color>",
|
||||||
|
"ADMIN",
|
||||||
|
100,
|
||||||
|
NamedTextColor.DARK_RED);
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String ID;
|
private final String ID;
|
||||||
|
|
|
@ -1,42 +1,40 @@
|
||||||
package me.unurled.sacredrealms.sr.components.item.abilities;
|
package me.unurled.sacredrealms.sr.components.item.abilities;
|
||||||
|
|
||||||
/**
|
/** Represents an ability that an item can have. TODO: Implement this class */
|
||||||
* Represents an ability that an item can have.
|
|
||||||
* TODO: Implement this class
|
|
||||||
*/
|
|
||||||
public class Ability {
|
public class Ability {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String description;
|
private final String description;
|
||||||
private final Integer cooldown;
|
private final Integer cooldown;
|
||||||
private final Integer manaCost;
|
private final Integer manaCost;
|
||||||
private final Integer damage;
|
private final Integer damage;
|
||||||
|
|
||||||
public Ability(String name, String description, Integer cooldown, Integer manaCost, Integer damage) {
|
public Ability(
|
||||||
this.name = name;
|
String name, String description, Integer cooldown, Integer manaCost, Integer damage) {
|
||||||
this.description = description;
|
this.name = name;
|
||||||
this.cooldown = cooldown;
|
this.description = description;
|
||||||
this.manaCost = manaCost;
|
this.cooldown = cooldown;
|
||||||
this.damage = damage;
|
this.manaCost = manaCost;
|
||||||
}
|
this.damage = damage;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getCooldown() {
|
public Integer getCooldown() {
|
||||||
return cooldown;
|
return cooldown;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getManaCost() {
|
public Integer getManaCost() {
|
||||||
return manaCost;
|
return manaCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getDamage() {
|
public Integer getDamage() {
|
||||||
return damage;
|
return damage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,17 +19,10 @@ import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class SRPlayer {
|
public class SRPlayer {
|
||||||
|
|
||||||
@Expose
|
@Expose private final UUID uuid;
|
||||||
private final UUID uuid;
|
@Expose private final HashMap<Attribute, Double> attributes;
|
||||||
|
@Expose private final List<PotionEffect> potionEffects;
|
||||||
@Expose
|
@Expose private Inventory inventory;
|
||||||
private Inventory inventory;
|
|
||||||
|
|
||||||
@Expose
|
|
||||||
private final HashMap<Attribute, Double> attributes;
|
|
||||||
|
|
||||||
@Expose
|
|
||||||
private final List<PotionEffect> potionEffects;
|
|
||||||
|
|
||||||
public SRPlayer(@NotNull Player player) {
|
public SRPlayer(@NotNull Player player) {
|
||||||
this.uuid = player.getUniqueId();
|
this.uuid = player.getUniqueId();
|
||||||
|
@ -43,15 +36,15 @@ public class SRPlayer {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInventory(Inventory inventory) {
|
|
||||||
this.inventory = inventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
return inventory;
|
return inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setInventory(Inventory inventory) {
|
||||||
|
this.inventory = inventory;
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public HashMap<Attribute, Double> getAttributes() {
|
public HashMap<Attribute, Double> getAttributes() {
|
||||||
return attributes;
|
return attributes;
|
||||||
|
@ -80,11 +73,12 @@ public class SRPlayer {
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Object o = p.getInventory()
|
Object o =
|
||||||
.getItemInMainHand()
|
p.getInventory()
|
||||||
.getItemMeta()
|
.getItemInMainHand()
|
||||||
.getPersistentDataContainer()
|
.getItemMeta()
|
||||||
.get(attribute.getKey(), attribute.getType());
|
.getPersistentDataContainer()
|
||||||
|
.get(attribute.getKey(), attribute.getType());
|
||||||
if (o == null) {
|
if (o == null) {
|
||||||
setHandItemAttribute(attribute, attribute.getDefaultValue());
|
setHandItemAttribute(attribute, attribute.getDefaultValue());
|
||||||
return attribute.getDefaultValue();
|
return attribute.getDefaultValue();
|
||||||
|
@ -97,23 +91,20 @@ public class SRPlayer {
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (checkIfValueIsOutOfBoundsForAttribute(attribute, value, p))
|
if (checkIfValueIsOutOfBoundsForAttribute(attribute, value, p)) return;
|
||||||
return;
|
|
||||||
ItemStack i = p.getInventory().getItemInMainHand();
|
ItemStack i = p.getInventory().getItemInMainHand();
|
||||||
ItemMeta im = i.getItemMeta();
|
ItemMeta im = i.getItemMeta();
|
||||||
im.getPersistentDataContainer()
|
im.getPersistentDataContainer().set(attribute.getKey(), PersistentDataType.DOUBLE, value);
|
||||||
.set(attribute.getKey(), PersistentDataType.DOUBLE, value);
|
|
||||||
im.lore();
|
im.lore();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkIfValueIsOutOfBoundsForAttribute(@NotNull Attribute attribute,
|
private boolean checkIfValueIsOutOfBoundsForAttribute(
|
||||||
@NotNull Double value,
|
@NotNull Attribute attribute, @NotNull Double value, Player p) {
|
||||||
Player p) {
|
|
||||||
if (!attribute.getType().getComplexType().isInstance(value)) {
|
if (!attribute.getType().getComplexType().isInstance(value)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (attribute.getType().equals(PersistentDataType.DOUBLE)) {
|
if (attribute.getType().equals(PersistentDataType.DOUBLE)) {
|
||||||
double d = (double) value;
|
double d = value;
|
||||||
if (d < attribute.getMinValue() || d > attribute.getMaxValue()) {
|
if (d < attribute.getMinValue() || d > attribute.getMaxValue()) {
|
||||||
warn(
|
warn(
|
||||||
"(Player "
|
"(Player "
|
||||||
|
@ -157,13 +148,13 @@ public class SRPlayer {
|
||||||
potionEffects.clear();
|
potionEffects.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPotionEffects(@NotNull List<PotionEffect> effects) {
|
|
||||||
potionEffects.clear();
|
|
||||||
potionEffects.addAll(effects);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public List<PotionEffect> getPotionEffects() {
|
public List<PotionEffect> getPotionEffects() {
|
||||||
return potionEffects;
|
return potionEffects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPotionEffects(@NotNull List<PotionEffect> effects) {
|
||||||
|
potionEffects.clear();
|
||||||
|
potionEffects.addAll(effects);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ import static me.unurled.sacredrealms.sr.utils.Logger.error;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import me.unurled.sacredrealms.sr.SR;
|
import me.unurled.sacredrealms.sr.SR;
|
||||||
import me.unurled.sacredrealms.sr.data.DataHandler;
|
|
||||||
import me.unurled.sacredrealms.sr.data.Redis;
|
|
||||||
import me.unurled.sacredrealms.sr.managers.Manager;
|
import me.unurled.sacredrealms.sr.managers.Manager;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package me.unurled.sacredrealms.sr.data.gson;
|
package me.unurled.sacredrealms.sr.data.gson;
|
||||||
|
|
||||||
import static me.unurled.sacredrealms.sr.utils.Logger.log;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonDeserializationContext;
|
import com.google.gson.JsonDeserializationContext;
|
||||||
|
@ -9,7 +7,6 @@ import com.google.gson.JsonDeserializer;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.Arrays;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
@ -17,26 +14,26 @@ import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class InventoryDeserializer implements JsonDeserializer<Inventory> {
|
public class InventoryDeserializer implements JsonDeserializer<Inventory> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Inventory deserialize(JsonElement jsonElement, Type type,
|
public Inventory deserialize(
|
||||||
JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
|
JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext)
|
||||||
Inventory inv = Bukkit.createInventory(null, InventoryType.PLAYER);
|
throws JsonParseException {
|
||||||
// parse from a string, to a list of string
|
Inventory inv = Bukkit.createInventory(null, InventoryType.PLAYER);
|
||||||
String[] contents = jsonElement.getAsString().split(";");
|
// parse from a string, to a list of string
|
||||||
|
String[] contents = jsonElement.getAsString().split(";");
|
||||||
// iterate through the list of strings and create ItemStacks with deserialize()
|
// iterate through the list of strings and create ItemStacks with deserialize()
|
||||||
Gson gson =
|
Gson gson =
|
||||||
new GsonBuilder()
|
new GsonBuilder()
|
||||||
.registerTypeAdapter(ItemStack.class, new ItemStackDeserializer())
|
.registerTypeAdapter(ItemStack.class, new ItemStackDeserializer())
|
||||||
.create();
|
.create();
|
||||||
for (int i = 0; i < contents.length; i++) {
|
for (int i = 0; i < contents.length; i++) {
|
||||||
if (contents[i].equals("null")) {
|
if (contents[i].equals("null")) {
|
||||||
inv.setItem(i, null);
|
inv.setItem(i, null);
|
||||||
} else {
|
} else {
|
||||||
ItemStack item = gson.fromJson(contents[i], ItemStack.class);
|
ItemStack item = gson.fromJson(contents[i], ItemStack.class);
|
||||||
if (item != null)
|
if (item != null) inv.setItem(i, item);
|
||||||
inv.setItem(i, item);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return inv;
|
|
||||||
}
|
}
|
||||||
|
return inv;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,26 @@
|
||||||
package me.unurled.sacredrealms.sr.data.gson;
|
package me.unurled.sacredrealms.sr.data.gson;
|
||||||
|
|
||||||
import static me.unurled.sacredrealms.sr.utils.Logger.error;
|
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonPrimitive;
|
import com.google.gson.JsonPrimitive;
|
||||||
import com.google.gson.JsonSerializationContext;
|
import com.google.gson.JsonSerializationContext;
|
||||||
import com.google.gson.JsonSerializer;
|
import com.google.gson.JsonSerializer;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
||||||
public class InventorySerializer implements JsonSerializer<Inventory> {
|
public class InventorySerializer implements JsonSerializer<Inventory> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JsonElement serialize(Inventory itemStacks, Type type,
|
public JsonElement serialize(
|
||||||
JsonSerializationContext jsonSerializationContext) {
|
Inventory itemStacks, Type type, JsonSerializationContext jsonSerializationContext) {
|
||||||
List<String> collect = Arrays.stream(itemStacks.getContents())
|
List<String> collect =
|
||||||
.map(item -> item == null ? "null" : Arrays.toString(item.serializeAsBytes())).collect(Collectors.toList());
|
Arrays.stream(itemStacks.getContents())
|
||||||
|
.map(item -> item == null ? "null" : Arrays.toString(item.serializeAsBytes()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
String s = String.join(";", collect);
|
String s = String.join(";", collect);
|
||||||
return new JsonPrimitive(s);
|
return new JsonPrimitive(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,24 @@
|
||||||
package me.unurled.sacredrealms.sr.data.gson;
|
package me.unurled.sacredrealms.sr.data.gson;
|
||||||
|
|
||||||
import com.google.common.reflect.TypeToken;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonDeserializationContext;
|
import com.google.gson.JsonDeserializationContext;
|
||||||
import com.google.gson.JsonDeserializer;
|
import com.google.gson.JsonDeserializer;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.Map;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class ItemStackDeserializer implements JsonDeserializer<ItemStack> {
|
public class ItemStackDeserializer implements JsonDeserializer<ItemStack> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack deserialize(JsonElement jsonElement, Type type,
|
public ItemStack deserialize(
|
||||||
JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
|
JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext)
|
||||||
Gson gson = new Gson();
|
throws JsonParseException {
|
||||||
byte[] mm = gson.fromJson(jsonElement, byte[].class);
|
Gson gson = new Gson();
|
||||||
if (mm != null) {
|
byte[] mm = gson.fromJson(jsonElement, byte[].class);
|
||||||
return ItemStack.deserializeBytes(mm);
|
if (mm != null) {
|
||||||
}
|
return ItemStack.deserializeBytes(mm);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,24 +14,25 @@ import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
public class PotionEffectDeserializer implements JsonDeserializer<PotionEffect> {
|
public class PotionEffectDeserializer implements JsonDeserializer<PotionEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PotionEffect deserialize(JsonElement jsonElement, Type type,
|
public PotionEffect deserialize(
|
||||||
JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
|
JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext)
|
||||||
try {
|
throws JsonParseException {
|
||||||
String pot = jsonElement.getAsString();
|
try {
|
||||||
pot = pot.replace("{", "").replace("}", "");
|
String pot = jsonElement.getAsString();
|
||||||
String[] parts = pot.split(",");
|
pot = pot.replace("{", "").replace("}", "");
|
||||||
// find the potion effect type from the string part[0] is a key
|
String[] parts = pot.split(",");
|
||||||
PotionEffectType pet = Registry.POTION_EFFECT_TYPE.get(new NamespacedKey("minecraft",
|
// find the potion effect type from the string part[0] is a key
|
||||||
parts[0]));
|
PotionEffectType pet =
|
||||||
int duration = Integer.parseInt(parts[1]);
|
Registry.POTION_EFFECT_TYPE.get(new NamespacedKey("minecraft", parts[0]));
|
||||||
int amplifier = Integer.parseInt(parts[2]);
|
int duration = Integer.parseInt(parts[1]);
|
||||||
boolean particles = Boolean.parseBoolean(parts[3]);
|
int amplifier = Integer.parseInt(parts[2]);
|
||||||
|
boolean particles = Boolean.parseBoolean(parts[3]);
|
||||||
|
|
||||||
return new PotionEffect(pet, duration, amplifier, false, particles, false);
|
return new PotionEffect(pet, duration, amplifier, false, particles, false);
|
||||||
} catch(Exception e) {
|
} catch (Exception e) {
|
||||||
error("Error deserializing potion effect: " + e.getMessage());
|
error("Error deserializing potion effect: " + e.getMessage());
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package me.unurled.sacredrealms.sr.data.gson;
|
package me.unurled.sacredrealms.sr.data.gson;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonPrimitive;
|
import com.google.gson.JsonPrimitive;
|
||||||
import com.google.gson.JsonSerializationContext;
|
import com.google.gson.JsonSerializationContext;
|
||||||
|
@ -10,18 +9,17 @@ import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
public class PotionEffectSerializer implements JsonSerializer<PotionEffect> {
|
public class PotionEffectSerializer implements JsonSerializer<PotionEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JsonElement serialize(PotionEffect potionEffect, Type type,
|
public JsonElement serialize(
|
||||||
JsonSerializationContext jsonSerializationContext) {
|
PotionEffect potionEffect, Type type, JsonSerializationContext jsonSerializationContext) {
|
||||||
StringBuilder sb = new StringBuilder();
|
String sb = "{"
|
||||||
sb.append("{");
|
+ potionEffect.getType().key()
|
||||||
sb.append(potionEffect.getType().key());
|
+ ","
|
||||||
sb.append(",");
|
+ potionEffect.getDuration()
|
||||||
sb.append(potionEffect.getDuration());
|
+ ","
|
||||||
sb.append(",");
|
+ potionEffect.getAmplifier()
|
||||||
sb.append(potionEffect.getAmplifier());
|
+ "," + potionEffect.hasParticles()
|
||||||
sb.append(",").append(potionEffect.hasParticles());
|
+ "}";
|
||||||
sb.append("}");
|
return new JsonPrimitive(sb);
|
||||||
return new JsonPrimitive(sb.toString());
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,31 +53,20 @@ public class Items {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** <b><color of the rarity>rarity
|
/**
|
||||||
* <dark_gray>Description: blablabla
|
* <b><color of the rarity>rarity <dark_gray>Description: blablabla <dark_gray>blabbla
|
||||||
* <dark_gray>blabbla
|
* <dark_gray>blabla <gray>Attributes: <gray>➤ Health: <green>+100 <gray>➤ Strength: <red>+10
|
||||||
* <dark_gray>blabla
|
* <gray>➤ Mana: <dark_aqua>+10 <gray>Abilities: <gray>➤ Ability 1,<yellow> On Rightclick unleash
|
||||||
* <gray>Attributes:
|
* a powerful attack <dark_gray>cooldown: 10s, <dark_gray>damage: 100, <dark_gray>mana cost:
|
||||||
* <gray>➤ Health: <green>+100
|
* <dark_aqua>50 <gray>➤ Ability 2,<yellow> On Rightclick unleash a powerful attack
|
||||||
* <gray>➤ Strength: <red>+10
|
* <dark_gray>cooldown: 10s, <dark_gray>damage: 100, <dark_gray>mana cost: <dark_aqua>50
|
||||||
* <gray>➤ Mana: <dark_aqua>+10
|
* <dark_purple>Enchantments: <blue>➤ Enchantment <if max level gold>1 <blue>➤ Enchantment <if max
|
||||||
* <gray>Abilities:
|
* level gold>2
|
||||||
* <gray>➤ Ability 1,<yellow> On Rightclick unleash a powerful attack
|
|
||||||
* <dark_gray>cooldown: 10s,
|
|
||||||
* <dark_gray>damage: 100,
|
|
||||||
* <dark_gray>mana cost: <dark_aqua>50
|
|
||||||
* <gray>➤ Ability 2,<yellow> On Rightclick unleash a powerful attack
|
|
||||||
* <dark_gray>cooldown: 10s,
|
|
||||||
* <dark_gray>damage: 100,
|
|
||||||
* <dark_gray>mana cost: <dark_aqua>50
|
|
||||||
* <dark_purple>Enchantments:
|
|
||||||
* <blue>➤ Enchantment <if max level gold>1
|
|
||||||
* <blue>➤ Enchantment <if max level gold>2
|
|
||||||
*
|
*
|
||||||
* @param item the item
|
* @param item the item
|
||||||
* @param stack the itemstack
|
* @param stack the itemstack
|
||||||
* @return the itemstack with lore
|
* @return the itemstack with lore
|
||||||
* */
|
*/
|
||||||
public static ItemStack lore(ItemStack stack) {
|
public static ItemStack lore(ItemStack stack) {
|
||||||
|
|
||||||
ItemManager im = (ItemManager) ItemManager.getInstance(ItemManager.class);
|
ItemManager im = (ItemManager) ItemManager.getInstance(ItemManager.class);
|
||||||
|
@ -94,22 +83,35 @@ public class Items {
|
||||||
lore.add(comp("<dark_gray>" + item.getDescription()));
|
lore.add(comp("<dark_gray>" + item.getDescription()));
|
||||||
if (!item.getAttributes().isEmpty()) {
|
if (!item.getAttributes().isEmpty()) {
|
||||||
lore.add(comp("<gray>Attributes:"));
|
lore.add(comp("<gray>Attributes:"));
|
||||||
item.getAttributes().forEach((k, v) -> lore.add(comp(" <gray>➤ " + k.getName() + ": " + (v < 0 ? "<red>" : "<green>") +
|
item.getAttributes()
|
||||||
"+" + v)));
|
.forEach(
|
||||||
|
(k, v) ->
|
||||||
|
lore.add(
|
||||||
|
comp(
|
||||||
|
" <gray>➤ "
|
||||||
|
+ k.getName()
|
||||||
|
+ ": "
|
||||||
|
+ (v < 0 ? "<red>" : "<green>")
|
||||||
|
+ "+"
|
||||||
|
+ v)));
|
||||||
}
|
}
|
||||||
if (!item.getAbilities().isEmpty()) {
|
if (!item.getAbilities().isEmpty()) {
|
||||||
lore.add(comp("<gray>Abilities:"));
|
lore.add(comp("<gray>Abilities:"));
|
||||||
item.getAbilities().forEach(a -> {
|
item.getAbilities()
|
||||||
lore.add(comp(" <gray>➤ " + a.getName() + ",<yellow> " + a.getDescription()));
|
.forEach(
|
||||||
lore.add(comp(" <dark_gray>cooldown: " + a.getCooldown() + "s,"));
|
a -> {
|
||||||
lore.add(comp(" <dark_gray>damage: " + a.getDamage() + ","));
|
lore.add(comp(" <gray>➤ " + a.getName() + ",<yellow> " + a.getDescription()));
|
||||||
lore.add(comp(" <dark_gray>mana cost: <dark_aqua>" + a.getManaCost()));
|
lore.add(comp(" <dark_gray>cooldown: " + a.getCooldown() + "s,"));
|
||||||
});
|
lore.add(comp(" <dark_gray>damage: " + a.getDamage() + ","));
|
||||||
|
lore.add(comp(" <dark_gray>mana cost: <dark_aqua>" + a.getManaCost()));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (!item.getEnchantments().isEmpty()) {
|
if (!item.getEnchantments().isEmpty()) {
|
||||||
lore.add(comp("<dark_purple>Enchantments:"));
|
lore.add(comp("<dark_purple>Enchantments:"));
|
||||||
item.getEnchantments().forEach((k, v) -> lore.add(comp(" <blue>➤ " + k.getName() + " <if "
|
item.getEnchantments()
|
||||||
+ "max level gold>" + v)));
|
.forEach(
|
||||||
|
(k, v) ->
|
||||||
|
lore.add(comp(" <blue>➤ " + k.getName() + " <if " + "max level gold>" + v)));
|
||||||
}
|
}
|
||||||
|
|
||||||
stack.lore(lore);
|
stack.lore(lore);
|
||||||
|
|
|
@ -1,33 +1,33 @@
|
||||||
package me.unurled.sacredrealms.sr.utils;
|
package me.unurled.sacredrealms.sr.utils;
|
||||||
|
|
||||||
public class NumberParser {
|
public class NumberParser {
|
||||||
public static double parse(String input) {
|
public static double parse(String input) {
|
||||||
input = input.toLowerCase().trim();
|
input = input.toLowerCase().trim();
|
||||||
double multiplier = 1.0;
|
double multiplier = 1.0;
|
||||||
|
|
||||||
if (input.endsWith("k")) {
|
if (input.endsWith("k")) {
|
||||||
multiplier = 1e3;
|
multiplier = 1e3;
|
||||||
input = input.substring(0, input.length() - 1);
|
input = input.substring(0, input.length() - 1);
|
||||||
} else if (input.endsWith("m")) {
|
} else if (input.endsWith("m")) {
|
||||||
multiplier = 1e6;
|
multiplier = 1e6;
|
||||||
input = input.substring(0, input.length() - 1);
|
input = input.substring(0, input.length() - 1);
|
||||||
} else if (input.endsWith("b")) {
|
} else if (input.endsWith("b")) {
|
||||||
multiplier = 1e9;
|
multiplier = 1e9;
|
||||||
input = input.substring(0, input.length() - 1);
|
input = input.substring(0, input.length() - 1);
|
||||||
}
|
|
||||||
|
|
||||||
return Double.parseDouble(input) * multiplier;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String format(double number) {
|
return Double.parseDouble(input) * multiplier;
|
||||||
if (number >= 1e9) {
|
}
|
||||||
return String.format("%.2fb", number / 1e9);
|
|
||||||
} else if (number >= 1e6) {
|
public static String format(double number) {
|
||||||
return String.format("%.2fm", number / 1e6);
|
if (number >= 1e9) {
|
||||||
} else if (number >= 1e3) {
|
return String.format("%.2fb", number / 1e9);
|
||||||
return String.format("%.2fk", number / 1e3);
|
} else if (number >= 1e6) {
|
||||||
} else {
|
return String.format("%.2fm", number / 1e6);
|
||||||
return String.format("%.2f", number);
|
} else if (number >= 1e3) {
|
||||||
}
|
return String.format("%.2fk", number / 1e3);
|
||||||
|
} else {
|
||||||
|
return String.format("%.2f", number);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,28 +7,28 @@ import org.bukkit.entity.Player;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
public class SRPlayerUtils {
|
public class SRPlayerUtils {
|
||||||
public static void syncPlayerToSR(Player p, SRPlayer sr) {
|
public static void syncPlayerToSR(Player p, SRPlayer sr) {
|
||||||
sr.setInventory(p.getInventory());
|
sr.setInventory(p.getInventory());
|
||||||
sr.setPotionEffects((List<PotionEffect>) p.getActivePotionEffects());
|
sr.setPotionEffects((List<PotionEffect>) p.getActivePotionEffects());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void syncSRToPlayer(SRPlayer sr, Player p) {
|
||||||
|
p.getInventory().setContents(sr.getInventory().getContents());
|
||||||
|
|
||||||
|
// agility (speed)
|
||||||
|
// default is 100 so 0.2
|
||||||
|
float value = (float) (sr.getAttribute(Attribute.AGILITY) / 500.0);
|
||||||
|
p.setFlySpeed(value);
|
||||||
|
p.setWalkSpeed(value);
|
||||||
|
|
||||||
|
for (PotionEffect pe : sr.getPotionEffects()) {
|
||||||
|
p.addPotionEffect(pe);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void syncSRToPlayer(SRPlayer sr, Player p) {
|
// health
|
||||||
p.getInventory().setContents(sr.getInventory().getContents());
|
// default is 100 so 20
|
||||||
|
p.setHealth(sr.getAttribute(Attribute.HEALTH) / 5);
|
||||||
// agility (speed)
|
p.sendHealthUpdate();
|
||||||
// default is 100 so 0.2
|
p.updateInventory();
|
||||||
float value = (float) (sr.getAttribute(Attribute.AGILITY) / 500.0);
|
}
|
||||||
p.setFlySpeed(value);
|
|
||||||
p.setWalkSpeed(value);
|
|
||||||
|
|
||||||
for (PotionEffect pe : sr.getPotionEffects()) {
|
|
||||||
p.addPotionEffect(pe);
|
|
||||||
}
|
|
||||||
|
|
||||||
// health
|
|
||||||
// default is 100 so 20
|
|
||||||
p.setHealth(sr.getAttribute(Attribute.HEALTH) / 5);
|
|
||||||
p.sendHealthUpdate();
|
|
||||||
p.updateInventory();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue