diff --git a/pom.xml b/pom.xml index 2485b458b..a4b3d86bf 100755 --- a/pom.xml +++ b/pom.xml @@ -118,10 +118,15 @@ co.aikar:acf-bukkit com.neetgames:mcMMO-API com.neetgames:jmal + com.neetgames:NEET-lib + + com.neetgames.neetlib + com.gmail.nossr50.neetlib + co.aikar.commands com.gmail.nossr50.mcmmo.acf @@ -210,6 +215,11 @@ jmal 0.01.00-SNAPSHOT + + com.neetgames + NEET-lib + 1.0-SNAPSHOT + co.aikar acf-bukkit diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index be4704ab5..4cdf3dda3 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -1,11 +1,11 @@ package com.gmail.nossr50.config; import com.gmail.nossr50.database.SQLDatabaseManager.PoolIdentifier; -import com.gmail.nossr50.datatypes.MobHealthBarType; import com.gmail.nossr50.datatypes.party.PartyFeature; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.util.text.StringUtils; +import com.neetgames.mcmmo.MobHealthBarType; import org.bukkit.Material; import org.bukkit.block.data.BlockData; import org.bukkit.configuration.ConfigurationSection; diff --git a/src/main/java/com/gmail/nossr50/database/FlatFileDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/FlatFileDatabaseManager.java index beb205bd0..0454fe821 100644 --- a/src/main/java/com/gmail/nossr50/database/FlatFileDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/FlatFileDatabaseManager.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.database; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.datatypes.MobHealthBarType; import com.gmail.nossr50.datatypes.database.DatabaseType; import com.gmail.nossr50.datatypes.database.PlayerStat; import com.gmail.nossr50.datatypes.database.UpgradeType; diff --git a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java index 760612afb..f4911f76f 100644 --- a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.database; import com.gmail.nossr50.api.exceptions.InvalidSkillException; import com.gmail.nossr50.api.exceptions.ProfileRetrievalException; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.datatypes.MobHealthBarType; import com.gmail.nossr50.datatypes.database.DatabaseType; import com.gmail.nossr50.datatypes.database.PlayerStat; import com.gmail.nossr50.datatypes.database.UpgradeType; @@ -15,6 +14,8 @@ import com.gmail.nossr50.runnables.database.UUIDUpdateAsyncTask; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.experience.MMOExperienceBarManager; import com.gmail.nossr50.util.skills.SkillUtils; +import com.neetgames.mcmmo.MobHealthBarType; +import com.neetgames.mcmmo.UniqueDataType; import org.apache.commons.lang.NullArgumentException; import org.apache.tomcat.jdbc.pool.DataSource; import org.apache.tomcat.jdbc.pool.PoolProperties; diff --git a/src/main/java/com/gmail/nossr50/datatypes/MobHealthBarType.java b/src/main/java/com/gmail/nossr50/datatypes/MobHealthBarType.java deleted file mode 100644 index ece258b1c..000000000 --- a/src/main/java/com/gmail/nossr50/datatypes/MobHealthBarType.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.gmail.nossr50.datatypes; - -public enum MobHealthBarType { - HEARTS, - BAR, - DISABLED -} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/datatypes/dirtydata/DirtyData.java b/src/main/java/com/gmail/nossr50/datatypes/dirtydata/DirtyData.java deleted file mode 100644 index 0dab2868d..000000000 --- a/src/main/java/com/gmail/nossr50/datatypes/dirtydata/DirtyData.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.gmail.nossr50.datatypes.dirtydata; - -import com.gmail.nossr50.datatypes.mutableprimitives.MutableBoolean; -import com.google.common.base.Objects; -import org.jetbrains.annotations.NotNull; - -public class DirtyData { - - private final @NotNull MutableBoolean dirtyFlag; //Can be pointed at a reference - private @NotNull T data; - - - public DirtyData(@NotNull T data, @NotNull MutableBoolean referenceFlag) { - this.data = data; - this.dirtyFlag = referenceFlag; - } - - public boolean isDirty() { - return dirtyFlag.getImmutableCopy(); - } - - public void setDirty(boolean newDirtyValue) { - dirtyFlag.setBoolean(newDirtyValue); - } - - public @NotNull T getData() { - return data; - } - - public T getData(boolean newDirty) { - setDirty(newDirty); - return data; - } - - public void setData(@NotNull T data) { - this.data = data; - setDirty(true); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - DirtyData dirtyData = (DirtyData) o; - return Objects.equal(getData(), dirtyData.getData()); - } - - @Override - public int hashCode() { - return Objects.hashCode(getData()); - } -} diff --git a/src/main/java/com/gmail/nossr50/datatypes/dirtydata/DirtyMap.java b/src/main/java/com/gmail/nossr50/datatypes/dirtydata/DirtyMap.java deleted file mode 100644 index d5e04ad37..000000000 --- a/src/main/java/com/gmail/nossr50/datatypes/dirtydata/DirtyMap.java +++ /dev/null @@ -1,198 +0,0 @@ -package com.gmail.nossr50.datatypes.dirtydata; - -import com.gmail.nossr50.datatypes.mutableprimitives.MutableBoolean; -import com.google.common.base.Objects; -import org.jetbrains.annotations.NotNull; - -import java.util.Collection; -import java.util.Map; -import java.util.Set; -import java.util.function.BiConsumer; -import java.util.function.BiFunction; -import java.util.function.Function; - -public class DirtyMap implements Map { - - private final @NotNull MutableBoolean dirtyFlag; //Can be pointed at a reference - private @NotNull Map map; - - public DirtyMap(@NotNull Map data, @NotNull MutableBoolean referenceFlag) { - this.map = data; - this.dirtyFlag = referenceFlag; - } - - public boolean isDirty() { - return dirtyFlag.getImmutableCopy(); - } - - private void setDirty() { - dirtyFlag.setBoolean(true); - } - - /** - * Change the map contained in this wrapper - * @param dataMap the map to wrap around instead of the current map - */ - public void setMap(@NotNull Map dataMap) { - this.map = dataMap; - setDirty(); - } - - /** - * Get the inner map that this DirtyMap is wrapping - * @return the inner map of this DirtyMap - */ - public @NotNull Map unwrapMap() { - setDirty(); - return map; - } - - /* Map Interface Delegates */ - - @Override - public V get(Object key) { - return map.get(key); - } - - @Override - public int size() { - return map.size(); - } - - @Override - public boolean isEmpty() { - return map.isEmpty(); - } - - @Override - public boolean containsKey(Object key) { - return map.containsKey(key); - } - - @Override - public boolean containsValue(Object value) { - return map.containsValue(value); - } - - @Override - public V put(K key, V value) { - setDirty(); - return map.put(key, value); - } - - @Override - public V remove(Object key) { - setDirty(); - return map.remove(key); - } - - @Override - public void putAll(@NotNull Map m) { - setDirty(); - map.putAll(m); - } - - @Override - public void clear() { - setDirty(); - map.clear(); - } - - @Override - public @NotNull Set keySet() { - setDirty(); - return map.keySet(); - } - - @Override - public @NotNull Collection values() { - setDirty(); - return map.values(); - } - - @Override - public @NotNull Set> entrySet() { - setDirty(); - return map.entrySet(); - } - - @Override - public V getOrDefault(Object key, V defaultValue) { - return map.getOrDefault(key, defaultValue); - } - - @Override - public void forEach(BiConsumer action) { - setDirty(); - map.forEach(action); - } - - @Override - public void replaceAll(BiFunction function) { - setDirty(); - map.replaceAll(function); - } - - @Override - public V putIfAbsent(K key, V value) { - setDirty(); - return map.putIfAbsent(key, value); - } - - @Override - public boolean remove(Object key, Object value) { - setDirty(); - return map.remove(key, value); - } - - @Override - public boolean replace(K key, V oldValue, V newValue) { - setDirty(); - return map.replace(key, oldValue, newValue); - } - - @Override - public V replace(K key, V value) { - setDirty(); - return map.replace(key, value); - } - - @Override - public V computeIfAbsent(K key, @NotNull Function mappingFunction) { - setDirty(); - return map.computeIfAbsent(key, mappingFunction); - } - - @Override - public V computeIfPresent(K key, @NotNull BiFunction remappingFunction) { - setDirty(); - return map.computeIfPresent(key, remappingFunction); - } - - @Override - public V compute(K key, @NotNull BiFunction remappingFunction) { - setDirty(); - return map.compute(key, remappingFunction); - } - - @Override - public V merge(K key, @NotNull V value, @NotNull BiFunction remappingFunction) { - setDirty(); - return map.merge(key, value, remappingFunction); - } - - /* Override for equals and hash */ - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - DirtyMap that = (DirtyMap) o; - return Objects.equal(map, that.map); - } - - @Override - public int hashCode() { - return Objects.hashCode(map); - } -} diff --git a/src/main/java/com/gmail/nossr50/datatypes/dirtydata/DirtySet.java b/src/main/java/com/gmail/nossr50/datatypes/dirtydata/DirtySet.java deleted file mode 100644 index f3b670d17..000000000 --- a/src/main/java/com/gmail/nossr50/datatypes/dirtydata/DirtySet.java +++ /dev/null @@ -1,164 +0,0 @@ -package com.gmail.nossr50.datatypes.dirtydata; - -import com.gmail.nossr50.datatypes.mutableprimitives.MutableBoolean; -import com.google.common.base.Objects; -import org.jetbrains.annotations.NotNull; - -import java.util.Collection; -import java.util.Iterator; -import java.util.Set; -import java.util.Spliterator; -import java.util.function.Consumer; -import java.util.function.Predicate; -import java.util.stream.Stream; - -public class DirtySet implements Set { - - private final @NotNull MutableBoolean dirtyFlag; //Can be pointed at a reference - private @NotNull Set set; - - public DirtySet(@NotNull Set data, @NotNull MutableBoolean referenceFlag) { - this.set = data; - this.dirtyFlag = referenceFlag; - } - - public boolean isDirty() { - return dirtyFlag.getImmutableCopy(); - } - - private void setDirty() { - dirtyFlag.setBoolean(true); - } - - /** - * Assign the inner wrapped set to a new value - * @param dataSet the new value to assign the inner wrapped set - */ - public void setSet(@NotNull Set dataSet) { - this.set = dataSet; - setDirty(); - } - - /** - * Get the wrapped set of this DirtySet - * @return the inner wrapped Set of this DirtySet - */ - public @NotNull Set unwrapSet() { - setDirty(); - return set; - } - - /* Set Interface Delegates */ - - @Override - public int size() { - return set.size(); - } - - @Override - public boolean isEmpty() { - return set.isEmpty(); - } - - @Override - public boolean contains(Object o) { - return set.contains(o); - } - - @Override - public @NotNull Iterator iterator() { - return set.iterator(); - } - - @Override - public Object[] toArray() { - return set.toArray(); - } - - @Override - public T[] toArray(@NotNull T[] ts) { - return set.toArray(ts); - } - - @Override - public boolean add(E e) { - setDirty(); - return set.add(e); - } - - @Override - public boolean remove(Object o) { - setDirty(); - return set.remove(o); - } - - @Override - public boolean containsAll(@NotNull Collection collection) { - return set.containsAll(collection); - } - - @Override - public boolean addAll(@NotNull Collection collection) { - setDirty(); - return set.addAll(collection); - } - - @Override - public boolean retainAll(@NotNull Collection collection) { - setDirty(); - return set.retainAll(collection); - } - - @Override - public boolean removeAll(@NotNull Collection collection) { - setDirty(); - return set.removeAll(collection); - } - - @Override - public void clear() { - setDirty(); - set.clear(); - } - - @Override - public Spliterator spliterator() { - setDirty(); - return set.spliterator(); - } - - @Override - public boolean removeIf(Predicate filter) { - return set.removeIf(filter); - } - - @Override - public Stream stream() { - return set.stream(); - } - - @Override - public Stream parallelStream() { - return set.parallelStream(); - } - - @Override - public void forEach(Consumer action) { - set.forEach(action); - } - - /* Equals & Hash Overrides */ - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - DirtySet dirtySet = (DirtySet) o; - return Objects.equal(set, dirtySet.set); - } - - @Override - public int hashCode() { - return Objects.hashCode(set); - } -} diff --git a/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableBoolean.java b/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableBoolean.java deleted file mode 100644 index 89eabf72e..000000000 --- a/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableBoolean.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.gmail.nossr50.datatypes.mutableprimitives; - -import com.google.common.base.Objects; - -public class MutableBoolean { - private boolean bool; - - public MutableBoolean(boolean bool) { - this.bool = bool; - } - - public boolean getImmutableCopy() { - return bool; - } - - public void setBoolean(boolean bool) { - this.bool = bool; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - MutableBoolean that = (MutableBoolean) o; - return bool == that.bool; - } - - @Override - public int hashCode() { - return Objects.hashCode(bool); - } -} diff --git a/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableByte.java b/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableByte.java deleted file mode 100644 index 226750967..000000000 --- a/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableByte.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.gmail.nossr50.datatypes.mutableprimitives; - -import com.google.common.base.Objects; - -public class MutableByte { - - private byte byteValue; - - public MutableByte(byte byteValue) { - this.byteValue = byteValue; - } - - public byte getImmutableCopy() { - return byteValue; - } - - public void setByte(byte byteValue) { - this.byteValue = byteValue; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - MutableByte that = (MutableByte) o; - return byteValue == that.byteValue; - } - - @Override - public int hashCode() { - return Objects.hashCode(byteValue); - } -} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableChar.java b/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableChar.java deleted file mode 100644 index 9c8084342..000000000 --- a/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableChar.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.gmail.nossr50.datatypes.mutableprimitives; - -import com.google.common.base.Objects; - -public class MutableChar { - - private char charValue; - - public MutableChar(char charValue) { - this.charValue = charValue; - } - - public char getImmutableCopy() { - return charValue; - } - - public void setChar(char charValue) { - this.charValue = charValue; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - MutableChar that = (MutableChar) o; - return charValue == that.charValue; - } - - @Override - public int hashCode() { - return Objects.hashCode(charValue); - } -} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableDouble.java b/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableDouble.java deleted file mode 100644 index e00d24aa7..000000000 --- a/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableDouble.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.gmail.nossr50.datatypes.mutableprimitives; - -import com.google.common.base.Objects; - -public class MutableDouble { - - private double doubleValue; - - public MutableDouble(double doubleValue) { - this.doubleValue = doubleValue; - } - - public double getImmutableCopy() { - return doubleValue; - } - - public void setDouble(double doubleValue) { - this.doubleValue = doubleValue; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - MutableDouble that = (MutableDouble) o; - return Double.compare(that.doubleValue, doubleValue) == 0; - } - - @Override - public int hashCode() { - return Objects.hashCode(doubleValue); - } -} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableFloat.java b/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableFloat.java deleted file mode 100644 index 518f1bfb1..000000000 --- a/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableFloat.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.gmail.nossr50.datatypes.mutableprimitives; - -import com.google.common.base.Objects; - -public class MutableFloat { - - private float floatValue; - - public MutableFloat(float floatValue) { - this.floatValue = floatValue; - } - - public float getImmutableCopy() { - return floatValue; - } - - public void setFloat(float floatValue) { - this.floatValue = floatValue; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - MutableFloat that = (MutableFloat) o; - return Float.compare(that.floatValue, floatValue) == 0; - } - - @Override - public int hashCode() { - return Objects.hashCode(floatValue); - } -} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableInteger.java b/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableInteger.java deleted file mode 100644 index be4814a0f..000000000 --- a/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableInteger.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.gmail.nossr50.datatypes.mutableprimitives; - -import com.google.common.base.Objects; - -public class MutableInteger { - private int integer; - - public MutableInteger(int integer) { - this.integer = integer; - } - - public int getImmutableCopy() { - return integer; - } - - public void setInt(int integer) { - this.integer = integer; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - MutableInteger that = (MutableInteger) o; - return integer == that.integer; - } - - @Override - public int hashCode() { - return Objects.hashCode(integer); - } -} diff --git a/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableLong.java b/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableLong.java deleted file mode 100644 index c40fafaa9..000000000 --- a/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableLong.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.gmail.nossr50.datatypes.mutableprimitives; - -import com.google.common.base.Objects; - -public class MutableLong { - - private long longValue; - - public MutableLong(long longValue) { - this.longValue = longValue; - } - - public long getImmutableCopy() { - return longValue; - } - - public void setLong(long longValue) { - this.longValue = longValue; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - MutableLong that = (MutableLong) o; - return longValue == that.longValue; - } - - @Override - public int hashCode() { - return Objects.hashCode(longValue); - } -} diff --git a/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableShort.java b/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableShort.java deleted file mode 100644 index 3843ad835..000000000 --- a/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableShort.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.gmail.nossr50.datatypes.mutableprimitives; - -import com.google.common.base.Objects; - -public class MutableShort { - - private short shortValue; - - public MutableShort(short shortValue) { - this.shortValue = shortValue; - } - - public short getImmutableCopy() { - return shortValue; - } - - public void setShort(short shortValue) { - this.shortValue = shortValue; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - MutableShort that = (MutableShort) o; - return shortValue == that.shortValue; - } - - @Override - public int hashCode() { - return Objects.hashCode(shortValue); - } -} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableString.java b/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableString.java deleted file mode 100644 index c7201aa61..000000000 --- a/src/main/java/com/gmail/nossr50/datatypes/mutableprimitives/MutableString.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.gmail.nossr50.datatypes.mutableprimitives; - -import com.google.common.base.Objects; -import org.jetbrains.annotations.NotNull; - -public class MutableString { - - private @NotNull String string; - - public MutableString(@NotNull String string) { - this.string = string; - } - - public @NotNull String getImmutableCopy() { - return string; - } - - public void setString(@NotNull String string) { - this.string = string; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - MutableString that = (MutableString) o; - return Objects.equal(string, that.string); - } - - @Override - public int hashCode() { - return Objects.hashCode(string); - } -} diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/MMODataSnapshot.java b/src/main/java/com/gmail/nossr50/datatypes/player/MMODataSnapshot.java index 685f7b7dd..cfd11884f 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/MMODataSnapshot.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/MMODataSnapshot.java @@ -1,10 +1,11 @@ package com.gmail.nossr50.datatypes.player; -import com.gmail.nossr50.datatypes.MobHealthBarType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; -import com.gmail.nossr50.util.experience.MMOExperienceBarManager; import com.google.common.collect.ImmutableMap; +import com.neetgames.mcmmo.MobHealthBarType; +import com.neetgames.mcmmo.UniqueDataType; +import com.neetgames.mcmmo.skill.SkillBossBarState; import org.jetbrains.annotations.NotNull; import java.util.UUID; @@ -25,7 +26,7 @@ public class MMODataSnapshot { private final @NotNull ImmutableMap skillExperienceValues; private final @NotNull ImmutableMap abilityDeactivationTimestamps; // Ability & Cooldown private final @NotNull ImmutableMap uniquePlayerData; //Misc data that doesn't fit into other categories (chimaera wing, etc..) - private final @NotNull ImmutableMap barStateMap; + private final @NotNull ImmutableMap barStateMap; /* Special Flags */ private final @NotNull Boolean partyChatSpying; @@ -86,7 +87,7 @@ public class MMODataSnapshot { return uniquePlayerData; } - public @NotNull ImmutableMap getBarStateMap() { + public @NotNull ImmutableMap getBarStateMap() { return barStateMap; } @@ -98,23 +99,23 @@ public class MMODataSnapshot { return scoreboardTipsShown; } - public int getSkillLevel(PrimarySkillType primarySkillType) { + public int getSkillLevel(@NotNull PrimarySkillType primarySkillType) { return skillLevelValues.getOrDefault(primarySkillType, 0); } - public int getSkillXpLevel(PrimarySkillType primarySkillType) { + public int getSkillXpLevel(@NotNull PrimarySkillType primarySkillType) { return (skillExperienceValues.getOrDefault(primarySkillType, 0F)).intValue(); } - public long getAbilityDATS(SuperAbilityType superAbilityType) { + public long getAbilityDATS(@NotNull SuperAbilityType superAbilityType) { return abilityDeactivationTimestamps.getOrDefault(superAbilityType, 0); } - public long getUniqueData(UniqueDataType uniqueDataType) { + public long getUniqueData(@NotNull UniqueDataType uniqueDataType) { return uniquePlayerData.getOrDefault(uniqueDataType, 0); } - public Boolean isLeaderBoardExcluded() { + public boolean isLeaderBoardExcluded() { return leaderBoardExclusion; } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index fd25a49d0..427016369 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -33,6 +33,9 @@ import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.experience.MMOExperienceBarManager; import com.gmail.nossr50.util.input.AbilityActivationProcessor; import com.gmail.nossr50.util.input.SuperAbilityManager; +import com.neetgames.jmal.core.player.OnlinePlayer; +import com.neetgames.mcmmo.player.MMOPlayer; +import com.neetgames.mcmmo.player.OnlineMMOPlayer; import net.kyori.adventure.identity.Identified; import net.kyori.adventure.identity.Identity; import org.bukkit.Location; @@ -46,7 +49,7 @@ import java.util.HashMap; import java.util.Map; import java.util.UUID; -public class McMMOPlayer extends PlayerProfile implements Identified { +public class McMMOPlayer implements OnlineMMOPlayer, Identified { private final @NotNull Player player; private final @NotNull Identity identity; private @Nullable Party playerPartyRef; @@ -600,4 +603,9 @@ public class McMMOPlayer extends PlayerProfile implements Identified { public @Nullable Party getPlayerPartyRef() { return playerPartyRef; } + + @Override + public UUID getUUID() { + return ; + } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/PersistentPlayerData.java b/src/main/java/com/gmail/nossr50/datatypes/player/PersistentPlayerData.java index 5a87d049e..bd0d35b75 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/PersistentPlayerData.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/PersistentPlayerData.java @@ -1,15 +1,7 @@ package com.gmail.nossr50.datatypes.player; -import com.gmail.nossr50.api.exceptions.UnexpectedValueException; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.datatypes.MobHealthBarType; -import com.gmail.nossr50.datatypes.dirtydata.DirtyData; -import com.gmail.nossr50.datatypes.dirtydata.DirtyMap; -import com.gmail.nossr50.datatypes.mutableprimitives.MutableBoolean; -import com.gmail.nossr50.datatypes.mutableprimitives.MutableInteger; -import com.gmail.nossr50.datatypes.mutableprimitives.MutableLong; -import com.gmail.nossr50.datatypes.mutableprimitives.MutableString; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.validation.NonNullRule; @@ -17,14 +9,26 @@ import com.gmail.nossr50.datatypes.validation.PositiveIntegerRule; import com.gmail.nossr50.datatypes.validation.Validator; import com.gmail.nossr50.util.experience.MMOExperienceBarManager; import com.google.common.collect.ImmutableMap; +import com.neetgames.mcmmo.MobHealthBarType; +import com.neetgames.mcmmo.UniqueDataType; +import com.neetgames.mcmmo.exceptions.UnexpectedValueException; +import com.neetgames.mcmmo.skill.Skill; +import com.neetgames.mcmmo.skill.SkillBossBarState; +import com.neetgames.mcmmo.player.MMOPlayerData; +import com.neetgames.mcmmo.skill.SuperSkill; +import com.neetgames.neetlib.dirtydata.DirtyData; +import com.neetgames.neetlib.dirtydata.DirtyMap; +import com.neetgames.neetlib.mutableprimitives.MutableBoolean; +import com.neetgames.neetlib.mutableprimitives.MutableInteger; +import com.neetgames.neetlib.mutableprimitives.MutableLong; +import com.neetgames.neetlib.mutableprimitives.MutableString; import org.apache.commons.lang.NullArgumentException; import org.jetbrains.annotations.NotNull; - import java.util.EnumMap; import java.util.Map; import java.util.UUID; -public class PersistentPlayerData { +public class PersistentPlayerData implements MMOPlayerData { private final @NotNull MutableBoolean dirtyFlag; //Dirty values in this class will change this flag as needed @@ -43,7 +47,7 @@ public class PersistentPlayerData { private final @NotNull DirtyMap skillExperienceValues; private final @NotNull DirtyMap abilityDeactivationTimestamps; // Ability & Cooldown private final @NotNull DirtyMap uniquePlayerData; //Misc data that doesn't fit into other categories (chimaera wing, etc..) - private final @NotNull DirtyMap barStateMap; + private final @NotNull DirtyMap barStateMap; /* Special Flags */ private final @NotNull DirtyData partyChatSpying; @@ -117,7 +121,7 @@ public class PersistentPlayerData { @NotNull EnumMap skillExperienceValues, @NotNull EnumMap abilityDeactivationTimestamps, @NotNull EnumMap uniquePlayerData, - @NotNull EnumMap barStateMap, + @NotNull EnumMap barStateMap, int scoreboardTipsShown, @NotNull MobHealthBarType mobHealthBarType, long lastLogin, @@ -187,6 +191,16 @@ public class PersistentPlayerData { return skillLevelValues.get(primarySkillType); } + @Override + public void setSkillLevel(Skill skill, int i) { + + } + + @Override + public int getSkillLevel(Skill skill) { + return 0; + } + /** * True if the persistent data has changed state and not yet saved to DB * @return true if data is dirty (not saved) @@ -296,7 +310,7 @@ public class PersistentPlayerData { * Set the time stamp for Chimaera Wing's last use for this player * @param DATS the new time stamp */ - private void setChimaeraWingDATS(int DATS) { + public void setChimaeraWingDATS(int DATS) { uniquePlayerData.put(UniqueDataType.CHIMAERA_WING_DATS, DATS); } @@ -316,6 +330,16 @@ public class PersistentPlayerData { */ public long getUniqueData(@NotNull UniqueDataType uniqueDataType) { return uniquePlayerData.get(uniqueDataType); } + @Override + public long getAbilityDATS(@NotNull SuperSkill superSkill) { + return 0; + } + + @Override + public void setAbilityDATS(@NotNull SuperSkill superSkill, long l) { + + } + /** * Get the current deactivation timestamp of an superAbilityType. * @@ -344,18 +368,18 @@ public class PersistentPlayerData { } /** - * Get the {@link Map} for the related {@link com.gmail.nossr50.util.experience.MMOExperienceBarManager.BarState}'s of this player + * Get the {@link Map} for the related {@link SkillBossBarState}'s of this player * @return the bar state map for this player */ - public @NotNull Map getBarStateMap() { + public @NotNull Map getBarStateMap() { return barStateMap; } /** - * Get the {@link DirtyMap} for the related {@link com.gmail.nossr50.util.experience.MMOExperienceBarManager.BarState}'s of this player + * Get the {@link DirtyMap} for the related {@link SkillBossBarState}'s of this player * @return the dirty bar state map for this player */ - public @NotNull DirtyMap getDirtyBarStateMap() { + public @NotNull DirtyMap getDirtyBarStateMap() { return barStateMap; } diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/PersistentPlayerDataBuilder.java b/src/main/java/com/gmail/nossr50/datatypes/player/PersistentPlayerDataBuilder.java index 37b7a5ee9..5b2b1640e 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/PersistentPlayerDataBuilder.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/PersistentPlayerDataBuilder.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.datatypes.player; -import com.gmail.nossr50.datatypes.MobHealthBarType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.mcMMO; diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java index 67f674236..1f55e42d2 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java @@ -1,16 +1,19 @@ package com.gmail.nossr50.datatypes.player; -import com.gmail.nossr50.datatypes.MobHealthBarType; import com.gmail.nossr50.datatypes.experience.ExperienceManager; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.mcMMO; +import com.neetgames.mcmmo.MobHealthBarType; +import com.neetgames.mcmmo.player.MMOPlayerData; +import com.neetgames.mcmmo.player.OfflineMMOPlayer; +import com.neetgames.mcmmo.skill.Skill; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.UUID; -public class PlayerProfile { +public class PlayerProfile implements OfflineMMOPlayer { /* All of the persistent data for a player that gets saved and loaded from DB */ private final @NotNull PersistentPlayerData persistentPlayerData; //All persistent data is kept here @@ -59,14 +62,6 @@ public class PlayerProfile { return getPersistentPlayerData().getPlayerName(); } - /** - * Get the saved {@link UUID} for this profile - * @return the saved {@link UUID} for this profile - */ - public @NotNull UUID getUniqueId() { - return getPersistentPlayerData().getPlayerUUID(); - } - /** * Get the current {@link MobHealthBarType} for this profile * @return the mob health bar setting for this profile @@ -154,4 +149,44 @@ public class PlayerProfile { public boolean isLeaderBoardExcluded() { return persistentPlayerData.isLeaderBoardExcluded(); } + + + /** + * Get the saved {@link UUID} for this profile + * @return the saved {@link UUID} for this profile + */ + @Override + public @NotNull UUID getUUID() { + return getPersistentPlayerData().getPlayerUUID(); + } + + @Override + public int getPowerLevel() { + return persistentPlayerData + } + + @Override + public int getSkillLevel(@NotNull Skill skill) { + return 0; + } + + @Override + public int getSkillExperience() { + return 0; + } + + @Override + public int getExperienceToNextLevel() { + return 0; + } + + @Override + public void savePlayerData() { + + } + + @Override + public @NotNull MMOPlayerData getMMOPlayerData() { + return null; + } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/UniqueDataType.java b/src/main/java/com/gmail/nossr50/datatypes/player/UniqueDataType.java deleted file mode 100644 index 8728c9b7f..000000000 --- a/src/main/java/com/gmail/nossr50/datatypes/player/UniqueDataType.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.gmail.nossr50.datatypes.player; - -public enum UniqueDataType { - CHIMAERA_WING_DATS -} diff --git a/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java b/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java index 228c023d4..631c1edac 100644 --- a/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java +++ b/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java @@ -2,11 +2,11 @@ package com.gmail.nossr50.util; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.datatypes.MobHealthBarType; import com.gmail.nossr50.datatypes.meta.OldName; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.MobHealthDisplayUpdaterTask; import com.gmail.nossr50.util.text.StringUtils; +import com.neetgames.mcmmo.MobHealthBarType; import org.bukkit.ChatColor; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; diff --git a/src/main/java/com/gmail/nossr50/util/experience/MMOExperienceBarManager.java b/src/main/java/com/gmail/nossr50/util/experience/MMOExperienceBarManager.java index bff914c10..cdc087a97 100644 --- a/src/main/java/com/gmail/nossr50/util/experience/MMOExperienceBarManager.java +++ b/src/main/java/com/gmail/nossr50/util/experience/MMOExperienceBarManager.java @@ -6,6 +6,8 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.skills.ExperienceBarHideTask; import com.gmail.nossr50.util.player.NotificationManager; +import com.neetgames.mcmmo.skill.SkillBossBarSetting; +import com.neetgames.mcmmo.skill.SkillBossBarState; import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -22,13 +24,13 @@ public class MMOExperienceBarManager { int delaySeconds = 3; - private @NotNull final Map barStateMapRef; + private @NotNull final Map barStateMapRef; private @NotNull final EnumMap experienceBars; private @NotNull final EnumMap experienceBarHideTaskHashMap; - public MMOExperienceBarManager(@NotNull McMMOPlayer mmoPlayer, @NotNull Map barStateMapRef) + public MMOExperienceBarManager(@NotNull McMMOPlayer mmoPlayer, @NotNull Map barStateMapRef) { this.mmoPlayer = mmoPlayer; this.barStateMapRef = barStateMapRef; @@ -45,17 +47,17 @@ public class MMOExperienceBarManager { } private void syncBarStates() { - for(Map.Entry entry : barStateMapRef.entrySet()) { + for(Map.Entry entry : barStateMapRef.entrySet()) { PrimarySkillType key = entry.getKey(); - BarState barState = entry.getValue(); + SkillBossBarState barState = entry.getValue(); switch(barState) { case NORMAL: break; case ALWAYS_ON: - xpBarSettingToggle(XPBarSettingTarget.SHOW, key); + xpBarSettingToggle(SkillBossBarSetting.SHOW, key); case DISABLED: - xpBarSettingToggle(XPBarSettingTarget.HIDE, key); + xpBarSettingToggle(SkillBossBarSetting.HIDE, key); } } } @@ -64,7 +66,7 @@ public class MMOExperienceBarManager { barStateMapRef.putAll(generateDefaultBarStateMap()); } - public void updateExperienceBar(PrimarySkillType primarySkillType, Plugin plugin) + public void updateExperienceBar(@NotNull PrimarySkillType primarySkillType, @NotNull Plugin plugin) { if(isBarDisabled(primarySkillType)) return; @@ -130,10 +132,10 @@ public class MMOExperienceBarManager { NotificationManager.sendPlayerInformationChatOnlyPrefixed(mmoPlayer.getPlayer(), "Commands.XPBar.DisableAll"); } - public void xpBarSettingToggle(@NotNull XPBarSettingTarget settingTarget, @Nullable PrimarySkillType skillType) { - switch(settingTarget) { + public void xpBarSettingToggle(@NotNull SkillBossBarSetting skillBossBarSetting, @Nullable PrimarySkillType skillType) { + switch(skillBossBarSetting) { case SHOW: - barStateMapRef.put(skillType, BarState.ALWAYS_ON); + barStateMapRef.put(skillType, SkillBossBarState.ALWAYS_ON); //Remove lingering tasks if(experienceBarHideTaskHashMap.containsKey(skillType)) { @@ -143,7 +145,7 @@ public class MMOExperienceBarManager { updateExperienceBar(skillType, mcMMO.p); break; case HIDE: - barStateMapRef.put(skillType, BarState.DISABLED); + barStateMapRef.put(skillType, SkillBossBarState.DISABLED); //Remove lingering tasks if(experienceBarHideTaskHashMap.containsKey(skillType)) { @@ -157,44 +159,40 @@ public class MMOExperienceBarManager { break; } - informPlayer(settingTarget, skillType); + informPlayer(skillBossBarSetting, skillType); } private void resetBarSettings() { barStateMapRef.putAll(generateDefaultBarStateMap()); } - private void informPlayer(@NotNull MMOExperienceBarManager.@NotNull XPBarSettingTarget settingTarget, @Nullable PrimarySkillType skillType) { + private void informPlayer(@NotNull SkillBossBarSetting settingTarget, @Nullable PrimarySkillType skillType) { //Inform player of setting change - if(settingTarget != XPBarSettingTarget.RESET) { + if(settingTarget != SkillBossBarSetting.RESET) { NotificationManager.sendPlayerInformationChatOnlyPrefixed(mmoPlayer.getPlayer(), "Commands.XPBar.SettingChanged", skillType.getName(), settingTarget.toString()); } else { NotificationManager.sendPlayerInformationChatOnlyPrefixed(mmoPlayer.getPlayer(), "Commands.XPBar.Reset"); } } - public enum XPBarSettingTarget { SHOW, HIDE, RESET, DISABLE } - - public enum BarState { NORMAL, ALWAYS_ON, DISABLED } - /* * Utility Methods */ - public static EnumMap generateDefaultBarStateMap() { - EnumMap barStateMap = new EnumMap<>(PrimarySkillType.class); + public static @NotNull EnumMap generateDefaultBarStateMap() { + EnumMap barStateMap = new EnumMap<>(PrimarySkillType.class); setBarStateDefaults(barStateMap); return barStateMap; } - public static void setBarStateDefaults(EnumMap barStateHashMap) { + public static void setBarStateDefaults(EnumMap barStateHashMap) { for(PrimarySkillType skillType : PrimarySkillType.values()) { if(skillType.isChildSkill()) { - barStateHashMap.put(skillType, MMOExperienceBarManager.BarState.DISABLED); + barStateHashMap.put(skillType, SkillBossBarState.DISABLED); } else { - barStateHashMap.put(skillType, MMOExperienceBarManager.BarState.NORMAL); + barStateHashMap.put(skillType, SkillBossBarState.NORMAL); } } } diff --git a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java index 921d8b74d..ad66c36b1 100644 --- a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java +++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java @@ -14,12 +14,14 @@ import com.gmail.nossr50.util.Misc; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; +import com.neetgames.mcmmo.player.MMOPlayer; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Scoreboard; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*; @@ -326,7 +328,7 @@ public class ScoreboardManager { changeScoreboard(wrapper, Config.getInstance().getStatsScoreboardTime()); } - public static void enablePlayerInspectScoreboard(Player player, PlayerProfile targetProfile) { + public static void enablePlayerInspectScoreboard(@NotNull Player player, @NotNull PlayerProfile targetProfile) { ScoreboardWrapper wrapper = getWrapper(player); if(wrapper == null) { @@ -427,7 +429,7 @@ public class ScoreboardManager { } } - public static @Nullable ScoreboardWrapper getWrapper(Player player) { + public static @Nullable ScoreboardWrapper getWrapper(@NotNull Player player) { if(PLAYER_SCOREBOARDS.get(player.getName()) == null) { makeNewScoreboard(player); } @@ -448,7 +450,7 @@ public class ScoreboardManager { } for (String playerName : dirtyPowerLevels) { - McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(playerName); + MMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(playerName); if (mmoPlayer == null) { continue;