more work on migrating API

This commit is contained in:
nossr50 2020-12-14 15:20:01 -08:00
parent 64e1d1a9d7
commit d8f8d541fc
26 changed files with 145 additions and 790 deletions

10
pom.xml
View File

@ -118,10 +118,15 @@
<include>co.aikar:acf-bukkit</include>
<include>com.neetgames:mcMMO-API</include>
<include>com.neetgames:jmal</include>
<include>com.neetgames:NEET-lib</include>
</includes>
</artifactSet>
<!-- <dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>-->
<relocations>
<relocation>
<pattern>com.neetgames.neetlib</pattern>
<shadedPattern>com.gmail.nossr50.neetlib</shadedPattern>
</relocation>
<relocation>
<pattern>co.aikar.commands</pattern>
<shadedPattern>com.gmail.nossr50.mcmmo.acf</shadedPattern> <!-- Replace this -->
@ -210,6 +215,11 @@
<artifactId>jmal</artifactId>
<version>0.01.00-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.neetgames</groupId>
<artifactId>NEET-lib</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>co.aikar</groupId>
<artifactId>acf-bukkit</artifactId> <!-- Don't forget to replace this -->

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -1,7 +0,0 @@
package com.gmail.nossr50.datatypes;
public enum MobHealthBarType {
HEARTS,
BAR,
DISABLED
}

View File

@ -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<T> {
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());
}
}

View File

@ -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<K, V> implements Map<K, V> {
private final @NotNull MutableBoolean dirtyFlag; //Can be pointed at a reference
private @NotNull Map<K, V> map;
public DirtyMap(@NotNull Map<K, V> 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<K, V> dataMap) {
this.map = dataMap;
setDirty();
}
/**
* Get the inner map that this DirtyMap is wrapping
* @return the inner map of this DirtyMap
*/
public @NotNull Map<K, V> 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<? extends K, ? extends V> m) {
setDirty();
map.putAll(m);
}
@Override
public void clear() {
setDirty();
map.clear();
}
@Override
public @NotNull Set<K> keySet() {
setDirty();
return map.keySet();
}
@Override
public @NotNull Collection<V> values() {
setDirty();
return map.values();
}
@Override
public @NotNull Set<Map.Entry<K, V>> entrySet() {
setDirty();
return map.entrySet();
}
@Override
public V getOrDefault(Object key, V defaultValue) {
return map.getOrDefault(key, defaultValue);
}
@Override
public void forEach(BiConsumer<? super K, ? super V> action) {
setDirty();
map.forEach(action);
}
@Override
public void replaceAll(BiFunction<? super K, ? super V, ? extends V> 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<? super K, ? extends V> mappingFunction) {
setDirty();
return map.computeIfAbsent(key, mappingFunction);
}
@Override
public V computeIfPresent(K key, @NotNull BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
setDirty();
return map.computeIfPresent(key, remappingFunction);
}
@Override
public V compute(K key, @NotNull BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
setDirty();
return map.compute(key, remappingFunction);
}
@Override
public V merge(K key, @NotNull V value, @NotNull BiFunction<? super V, ? super V, ? extends V> 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);
}
}

View File

@ -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<E> implements Set<E> {
private final @NotNull MutableBoolean dirtyFlag; //Can be pointed at a reference
private @NotNull Set<E> set;
public DirtySet(@NotNull Set<E> 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<E> dataSet) {
this.set = dataSet;
setDirty();
}
/**
* Get the wrapped set of this DirtySet
* @return the inner wrapped Set of this DirtySet
*/
public @NotNull Set<E> 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<E> iterator() {
return set.iterator();
}
@Override
public Object[] toArray() {
return set.toArray();
}
@Override
public <T> 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<? extends E> 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<E> spliterator() {
setDirty();
return set.spliterator();
}
@Override
public boolean removeIf(Predicate<? super E> filter) {
return set.removeIf(filter);
}
@Override
public Stream<E> stream() {
return set.stream();
}
@Override
public Stream<E> parallelStream() {
return set.parallelStream();
}
@Override
public void forEach(Consumer<? super E> 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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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<PrimarySkillType, Float> skillExperienceValues;
private final @NotNull ImmutableMap<SuperAbilityType, Integer> abilityDeactivationTimestamps; // Ability & Cooldown
private final @NotNull ImmutableMap<UniqueDataType, Integer> uniquePlayerData; //Misc data that doesn't fit into other categories (chimaera wing, etc..)
private final @NotNull ImmutableMap<PrimarySkillType, MMOExperienceBarManager.BarState> barStateMap;
private final @NotNull ImmutableMap<PrimarySkillType, SkillBossBarState> barStateMap;
/* Special Flags */
private final @NotNull Boolean partyChatSpying;
@ -86,7 +87,7 @@ public class MMODataSnapshot {
return uniquePlayerData;
}
public @NotNull ImmutableMap<PrimarySkillType, MMOExperienceBarManager.BarState> getBarStateMap() {
public @NotNull ImmutableMap<PrimarySkillType, SkillBossBarState> 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;
}
}

View File

@ -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 ;
}
}

View File

@ -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<PrimarySkillType, Float> skillExperienceValues;
private final @NotNull DirtyMap<SuperAbilityType, Integer> abilityDeactivationTimestamps; // Ability & Cooldown
private final @NotNull DirtyMap<UniqueDataType, Integer> uniquePlayerData; //Misc data that doesn't fit into other categories (chimaera wing, etc..)
private final @NotNull DirtyMap<PrimarySkillType, MMOExperienceBarManager.BarState> barStateMap;
private final @NotNull DirtyMap<PrimarySkillType, SkillBossBarState> barStateMap;
/* Special Flags */
private final @NotNull DirtyData<MutableBoolean> partyChatSpying;
@ -117,7 +121,7 @@ public class PersistentPlayerData {
@NotNull EnumMap<PrimarySkillType, Float> skillExperienceValues,
@NotNull EnumMap<SuperAbilityType, Integer> abilityDeactivationTimestamps,
@NotNull EnumMap<UniqueDataType, Integer> uniquePlayerData,
@NotNull EnumMap<PrimarySkillType, MMOExperienceBarManager.BarState> barStateMap,
@NotNull EnumMap<PrimarySkillType, SkillBossBarState> 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<PrimarySkillType, MMOExperienceBarManager.BarState> getBarStateMap() {
public @NotNull Map<PrimarySkillType, SkillBossBarState> 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<PrimarySkillType, MMOExperienceBarManager.BarState> getDirtyBarStateMap() {
public @NotNull DirtyMap<PrimarySkillType, SkillBossBarState> getDirtyBarStateMap() {
return barStateMap;
}

View File

@ -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;

View File

@ -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;
}
}

View File

@ -1,5 +0,0 @@
package com.gmail.nossr50.datatypes.player;
public enum UniqueDataType {
CHIMAERA_WING_DATS
}

View File

@ -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;

View File

@ -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<PrimarySkillType, BarState> barStateMapRef;
private @NotNull final Map<PrimarySkillType, SkillBossBarState> barStateMapRef;
private @NotNull final EnumMap<PrimarySkillType, ExperienceBarWrapper> experienceBars;
private @NotNull final EnumMap<PrimarySkillType, ExperienceBarHideTask> experienceBarHideTaskHashMap;
public MMOExperienceBarManager(@NotNull McMMOPlayer mmoPlayer, @NotNull Map<PrimarySkillType, BarState> barStateMapRef)
public MMOExperienceBarManager(@NotNull McMMOPlayer mmoPlayer, @NotNull Map<PrimarySkillType, SkillBossBarState> barStateMapRef)
{
this.mmoPlayer = mmoPlayer;
this.barStateMapRef = barStateMapRef;
@ -45,17 +47,17 @@ public class MMOExperienceBarManager {
}
private void syncBarStates() {
for(Map.Entry<PrimarySkillType, BarState> entry : barStateMapRef.entrySet()) {
for(Map.Entry<PrimarySkillType, SkillBossBarState> 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<PrimarySkillType, BarState> generateDefaultBarStateMap() {
EnumMap<PrimarySkillType, MMOExperienceBarManager.BarState> barStateMap = new EnumMap<>(PrimarySkillType.class);
public static @NotNull EnumMap<PrimarySkillType, SkillBossBarState> generateDefaultBarStateMap() {
EnumMap<PrimarySkillType, SkillBossBarState> barStateMap = new EnumMap<>(PrimarySkillType.class);
setBarStateDefaults(barStateMap);
return barStateMap;
}
public static void setBarStateDefaults(EnumMap<PrimarySkillType, MMOExperienceBarManager.BarState> barStateHashMap) {
public static void setBarStateDefaults(EnumMap<PrimarySkillType, SkillBossBarState> 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);
}
}
}

View File

@ -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;