mirror of
https://github.com/SunNetservers/MiniGames.git
synced 2025-12-05 02:18:46 +01:00
Cleans up some nullability annotations
This commit is contained in:
@@ -15,22 +15,22 @@ import java.util.logging.Level;
|
|||||||
/**
|
/**
|
||||||
* An interface describing a generic arena handler
|
* An interface describing a generic arena handler
|
||||||
*
|
*
|
||||||
* @param <K> <p>The type of arena stored</p>
|
* @param <ArenaType> <p>The type of arena stored</p>
|
||||||
* @param <S> <p>The type of arena group stored</p>
|
* @param <GroupType> <p>The type of arena group stored</p>
|
||||||
*/
|
*/
|
||||||
public abstract class ArenaHandler<K extends Arena, S extends ArenaGroup<K, S>> {
|
public abstract class ArenaHandler<ArenaType extends Arena, GroupType extends ArenaGroup<ArenaType, GroupType>> {
|
||||||
|
|
||||||
protected Map<UUID, K> arenas = new HashMap<>();
|
protected Map<UUID, ArenaType> arenas = new HashMap<>();
|
||||||
protected Map<UUID, S> arenaGroups = new HashMap<>();
|
protected Map<UUID, GroupType> arenaGroups = new HashMap<>();
|
||||||
protected Map<String, UUID> arenaNameLookup = new HashMap<>();
|
protected Map<String, UUID> arenaNameLookup = new HashMap<>();
|
||||||
private final ArenaPlayerRegistry<K> playerRegistry;
|
private final ArenaPlayerRegistry<ArenaType> playerRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new arena handler
|
* Instantiates a new arena handler
|
||||||
*
|
*
|
||||||
* @param playerRegistry <p>The registry keeping track of player sessions</p>
|
* @param playerRegistry <p>The registry keeping track of player sessions</p>
|
||||||
*/
|
*/
|
||||||
public ArenaHandler(ArenaPlayerRegistry<K> playerRegistry) {
|
public ArenaHandler(@NotNull ArenaPlayerRegistry<ArenaType> playerRegistry) {
|
||||||
this.playerRegistry = playerRegistry;
|
this.playerRegistry = playerRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,8 +39,8 @@ public abstract class ArenaHandler<K extends Arena, S extends ArenaGroup<K, S>>
|
|||||||
*
|
*
|
||||||
* @return <p>All arenas in a group</p>
|
* @return <p>All arenas in a group</p>
|
||||||
*/
|
*/
|
||||||
public @NotNull Set<K> getArenasInAGroup() {
|
public @NotNull Set<ArenaType> getArenasInAGroup() {
|
||||||
Set<K> arenas = new HashSet<>();
|
Set<ArenaType> arenas = new HashSet<>();
|
||||||
for (UUID arenaId : arenaGroups.keySet()) {
|
for (UUID arenaId : arenaGroups.keySet()) {
|
||||||
arenas.add(this.arenas.get(arenaId));
|
arenas.add(this.arenas.get(arenaId));
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ public abstract class ArenaHandler<K extends Arena, S extends ArenaGroup<K, S>>
|
|||||||
*
|
*
|
||||||
* @return <p>All arena groups</p>
|
* @return <p>All arena groups</p>
|
||||||
*/
|
*/
|
||||||
public Set<S> getAllGroups() {
|
public Set<GroupType> getAllGroups() {
|
||||||
return new HashSet<>(arenaGroups.values());
|
return new HashSet<>(arenaGroups.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ public abstract class ArenaHandler<K extends Arena, S extends ArenaGroup<K, S>>
|
|||||||
* @param arenaId <p>The id of the arena to get the group of</p>
|
* @param arenaId <p>The id of the arena to get the group of</p>
|
||||||
* @return <p>The group the arena belongs to, or null if not in a group</p>
|
* @return <p>The group the arena belongs to, or null if not in a group</p>
|
||||||
*/
|
*/
|
||||||
public @Nullable S getGroup(@NotNull UUID arenaId) {
|
public @Nullable GroupType getGroup(@NotNull UUID arenaId) {
|
||||||
return this.arenaGroups.get(arenaId);
|
return this.arenaGroups.get(arenaId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ public abstract class ArenaHandler<K extends Arena, S extends ArenaGroup<K, S>>
|
|||||||
* @param arenaId <p>The id of the arena to change</p>
|
* @param arenaId <p>The id of the arena to change</p>
|
||||||
* @param arenaGroup <p>The group to add the arena to, or null to remove the current group</p>
|
* @param arenaGroup <p>The group to add the arena to, or null to remove the current group</p>
|
||||||
*/
|
*/
|
||||||
public void setGroup(@NotNull UUID arenaId, @Nullable S arenaGroup) {
|
public void setGroup(@NotNull UUID arenaId, @Nullable GroupType arenaGroup) {
|
||||||
if (arenaGroup == null) {
|
if (arenaGroup == null) {
|
||||||
// No need to remove something non-existing
|
// No need to remove something non-existing
|
||||||
if (!this.arenaGroups.containsKey(arenaId)) {
|
if (!this.arenaGroups.containsKey(arenaId)) {
|
||||||
@@ -80,7 +80,7 @@ public abstract class ArenaHandler<K extends Arena, S extends ArenaGroup<K, S>>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove the existing group
|
// Remove the existing group
|
||||||
S oldGroup = this.arenaGroups.remove(arenaId);
|
GroupType oldGroup = this.arenaGroups.remove(arenaId);
|
||||||
oldGroup.removeArena(arenaId);
|
oldGroup.removeArena(arenaId);
|
||||||
} else {
|
} else {
|
||||||
// Make sure to remove the arena from the old group's internal tracking
|
// Make sure to remove the arena from the old group's internal tracking
|
||||||
@@ -100,9 +100,9 @@ public abstract class ArenaHandler<K extends Arena, S extends ArenaGroup<K, S>>
|
|||||||
* @param groupName <p>The name of the group to get</p>
|
* @param groupName <p>The name of the group to get</p>
|
||||||
* @return <p>The group, or null if not found</p>
|
* @return <p>The group, or null if not found</p>
|
||||||
*/
|
*/
|
||||||
public @Nullable S getGroup(String groupName) {
|
public @Nullable GroupType getGroup(@NotNull String groupName) {
|
||||||
String sanitized = StringSanitizer.sanitizeArenaName(groupName);
|
String sanitized = StringSanitizer.sanitizeArenaName(groupName);
|
||||||
for (S arenaGroup : this.arenaGroups.values()) {
|
for (GroupType arenaGroup : this.arenaGroups.values()) {
|
||||||
if (arenaGroup.getGroupNameSanitized().equals(sanitized)) {
|
if (arenaGroup.getGroupNameSanitized().equals(sanitized)) {
|
||||||
return arenaGroup;
|
return arenaGroup;
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ public abstract class ArenaHandler<K extends Arena, S extends ArenaGroup<K, S>>
|
|||||||
*
|
*
|
||||||
* @param arena <p>The arena to add</p>
|
* @param arena <p>The arena to add</p>
|
||||||
*/
|
*/
|
||||||
public void addArena(@NotNull K arena) {
|
public void addArena(@NotNull ArenaType arena) {
|
||||||
this.arenas.put(arena.getArenaId(), arena);
|
this.arenas.put(arena.getArenaId(), arena);
|
||||||
this.arenaNameLookup.put(arena.getArenaNameSanitized(), arena.getArenaId());
|
this.arenaNameLookup.put(arena.getArenaNameSanitized(), arena.getArenaId());
|
||||||
this.saveArenas();
|
this.saveArenas();
|
||||||
@@ -140,7 +140,7 @@ public abstract class ArenaHandler<K extends Arena, S extends ArenaGroup<K, S>>
|
|||||||
* @param arenaId <p>The id of the arena to get</p>
|
* @param arenaId <p>The id of the arena to get</p>
|
||||||
* @return <p>The arena, or null if no arena could be found</p>
|
* @return <p>The arena, or null if no arena could be found</p>
|
||||||
*/
|
*/
|
||||||
public @Nullable K getArena(@NotNull UUID arenaId) {
|
public @Nullable ArenaType getArena(@NotNull UUID arenaId) {
|
||||||
return this.arenas.get(arenaId);
|
return this.arenas.get(arenaId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ public abstract class ArenaHandler<K extends Arena, S extends ArenaGroup<K, S>>
|
|||||||
* @param arenaName <p>The arena to get</p>
|
* @param arenaName <p>The arena to get</p>
|
||||||
* @return <p>The arena with the given name, or null if not found</p>
|
* @return <p>The arena with the given name, or null if not found</p>
|
||||||
*/
|
*/
|
||||||
public @Nullable K getArena(@NotNull String arenaName) {
|
public @Nullable ArenaType getArena(@NotNull String arenaName) {
|
||||||
try {
|
try {
|
||||||
return this.arenas.get(UUID.fromString(arenaName));
|
return this.arenas.get(UUID.fromString(arenaName));
|
||||||
} catch (IllegalArgumentException exception) {
|
} catch (IllegalArgumentException exception) {
|
||||||
@@ -163,7 +163,7 @@ public abstract class ArenaHandler<K extends Arena, S extends ArenaGroup<K, S>>
|
|||||||
*
|
*
|
||||||
* @return <p>All known arenas</p>
|
* @return <p>All known arenas</p>
|
||||||
*/
|
*/
|
||||||
public @NotNull Map<UUID, K> getArenas() {
|
public @NotNull Map<UUID, ArenaType> getArenas() {
|
||||||
return new HashMap<>(this.arenas);
|
return new HashMap<>(this.arenas);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,7 +172,7 @@ public abstract class ArenaHandler<K extends Arena, S extends ArenaGroup<K, S>>
|
|||||||
*
|
*
|
||||||
* @param arena <p>The arena to remove</p>
|
* @param arena <p>The arena to remove</p>
|
||||||
*/
|
*/
|
||||||
public void removeArena(@NotNull K arena) {
|
public void removeArena(@NotNull ArenaType arena) {
|
||||||
UUID arenaId = arena.getArenaId();
|
UUID arenaId = arena.getArenaId();
|
||||||
this.playerRegistry.removeForArena(arena, false);
|
this.playerRegistry.removeForArena(arena, false);
|
||||||
this.arenas.remove(arenaId);
|
this.arenas.remove(arenaId);
|
||||||
@@ -190,8 +190,8 @@ public abstract class ArenaHandler<K extends Arena, S extends ArenaGroup<K, S>>
|
|||||||
*
|
*
|
||||||
* @param arenaId <p>The id of the arena whose data should be saved</p>
|
* @param arenaId <p>The id of the arena whose data should be saved</p>
|
||||||
*/
|
*/
|
||||||
public void saveData(UUID arenaId) {
|
public void saveData(@NotNull UUID arenaId) {
|
||||||
K arena = getArena(arenaId);
|
ArenaType arena = getArena(arenaId);
|
||||||
if (arena != null) {
|
if (arena != null) {
|
||||||
if (!arena.saveData()) {
|
if (!arena.saveData()) {
|
||||||
MiniGames.log(Level.WARNING, "Unable to save data for arena with id " + arenaId +
|
MiniGames.log(Level.WARNING, "Unable to save data for arena with id " + arenaId +
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ public abstract class ArenaRecordsRegistry implements ConfigurationSerializable
|
|||||||
*
|
*
|
||||||
* @return <p>Existing death records</p>
|
* @return <p>Existing death records</p>
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public Set<SummableArenaRecord<Integer>> getLeastDeathsRecords() {
|
public Set<SummableArenaRecord<Integer>> getLeastDeathsRecords() {
|
||||||
return new HashSet<>(this.leastDeaths);
|
return new HashSet<>(this.leastDeaths);
|
||||||
}
|
}
|
||||||
@@ -63,6 +64,7 @@ public abstract class ArenaRecordsRegistry implements ConfigurationSerializable
|
|||||||
*
|
*
|
||||||
* @return <p>Existing time records</p>
|
* @return <p>Existing time records</p>
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public Set<SummableArenaRecord<Long>> getShortestTimeMilliSecondsRecords() {
|
public Set<SummableArenaRecord<Long>> getShortestTimeMilliSecondsRecords() {
|
||||||
return new HashSet<>(this.shortestTimeMilliSeconds);
|
return new HashSet<>(this.shortestTimeMilliSeconds);
|
||||||
}
|
}
|
||||||
@@ -74,7 +76,8 @@ public abstract class ArenaRecordsRegistry implements ConfigurationSerializable
|
|||||||
* @param deaths <p>The number of deaths suffered before the player finished the arena</p>
|
* @param deaths <p>The number of deaths suffered before the player finished the arena</p>
|
||||||
* @return <p>The result explaining what type of record was achieved</p>
|
* @return <p>The result explaining what type of record was achieved</p>
|
||||||
*/
|
*/
|
||||||
public @NotNull RecordResult registerDeathRecord(@NotNull UUID playerId, int deaths) {
|
@NotNull
|
||||||
|
public RecordResult registerDeathRecord(@NotNull UUID playerId, int deaths) {
|
||||||
Consumer<Integer> consumer = (value) -> {
|
Consumer<Integer> consumer = (value) -> {
|
||||||
leastDeaths.removeIf((item) -> item.getUserId().equals(playerId));
|
leastDeaths.removeIf((item) -> item.getUserId().equals(playerId));
|
||||||
leastDeaths.add(new IntegerRecord(playerId, value));
|
leastDeaths.add(new IntegerRecord(playerId, value));
|
||||||
@@ -89,7 +92,8 @@ public abstract class ArenaRecordsRegistry implements ConfigurationSerializable
|
|||||||
* @param milliseconds <p>The number of milliseconds it took the player to finish the dropper arena</p>
|
* @param milliseconds <p>The number of milliseconds it took the player to finish the dropper arena</p>
|
||||||
* @return <p>The result explaining what type of record was achieved</p>
|
* @return <p>The result explaining what type of record was achieved</p>
|
||||||
*/
|
*/
|
||||||
public @NotNull RecordResult registerTimeRecord(@NotNull UUID playerId, long milliseconds) {
|
@NotNull
|
||||||
|
public RecordResult registerTimeRecord(@NotNull UUID playerId, long milliseconds) {
|
||||||
Consumer<Long> consumer = (value) -> {
|
Consumer<Long> consumer = (value) -> {
|
||||||
shortestTimeMilliSeconds.removeIf((item) -> item.getUserId().equals(playerId));
|
shortestTimeMilliSeconds.removeIf((item) -> item.getUserId().equals(playerId));
|
||||||
shortestTimeMilliSeconds.add(new LongRecord(playerId, value));
|
shortestTimeMilliSeconds.add(new LongRecord(playerId, value));
|
||||||
@@ -111,9 +115,10 @@ public abstract class ArenaRecordsRegistry implements ConfigurationSerializable
|
|||||||
* @param amount <p>The amount of whatever the player achieved</p>
|
* @param amount <p>The amount of whatever the player achieved</p>
|
||||||
* @return <p>The result of the player's record attempt</p>
|
* @return <p>The result of the player's record attempt</p>
|
||||||
*/
|
*/
|
||||||
private <T extends Comparable<T>> @NotNull RecordResult registerRecord(@NotNull Set<ArenaRecord<T>> existingRecords,
|
@NotNull
|
||||||
@NotNull Consumer<T> recordSetter,
|
private <RecordType extends Comparable<RecordType>> RecordResult registerRecord(@NotNull Set<ArenaRecord<RecordType>> existingRecords,
|
||||||
@NotNull UUID playerId, T amount) {
|
@NotNull Consumer<RecordType> recordSetter,
|
||||||
|
@NotNull UUID playerId, RecordType amount) {
|
||||||
RecordResult result;
|
RecordResult result;
|
||||||
if (existingRecords.stream().allMatch((entry) -> amount.compareTo(entry.getRecord()) < 0)) {
|
if (existingRecords.stream().allMatch((entry) -> amount.compareTo(entry.getRecord()) < 0)) {
|
||||||
// If the given value is less than all other values, that's a world record!
|
// If the given value is less than all other values, that's a world record!
|
||||||
@@ -123,7 +128,7 @@ public abstract class ArenaRecordsRegistry implements ConfigurationSerializable
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArenaRecord<T> playerRecord = getRecord(existingRecords, playerId);
|
ArenaRecord<RecordType> playerRecord = getRecord(existingRecords, playerId);
|
||||||
if (playerRecord != null && amount.compareTo(playerRecord.getRecord()) < 0) {
|
if (playerRecord != null && amount.compareTo(playerRecord.getRecord()) < 0) {
|
||||||
// If the given value is less than the player's previous value, that's a personal best!
|
// If the given value is less than the player's previous value, that's a personal best!
|
||||||
result = RecordResult.PERSONAL_BEST;
|
result = RecordResult.PERSONAL_BEST;
|
||||||
@@ -146,12 +151,13 @@ public abstract class ArenaRecordsRegistry implements ConfigurationSerializable
|
|||||||
*
|
*
|
||||||
* @param existingRecords <p>The existing records to look through</p>
|
* @param existingRecords <p>The existing records to look through</p>
|
||||||
* @param playerId <p>The id of the player to look for</p>
|
* @param playerId <p>The id of the player to look for</p>
|
||||||
* @param <T> <p>The type of the stored record</p>
|
* @param <RecordType> <p>The type of the stored record</p>
|
||||||
* @return <p>The record, or null if not found</p>
|
* @return <p>The record, or null if not found</p>
|
||||||
*/
|
*/
|
||||||
private <T extends Comparable<T>> @Nullable ArenaRecord<T> getRecord(@NotNull Set<ArenaRecord<T>> existingRecords,
|
@Nullable
|
||||||
@NotNull UUID playerId) {
|
private <RecordType extends Comparable<RecordType>> ArenaRecord<RecordType> getRecord(@NotNull Set<ArenaRecord<RecordType>> existingRecords,
|
||||||
AtomicReference<ArenaRecord<T>> record = new AtomicReference<>();
|
@NotNull UUID playerId) {
|
||||||
|
AtomicReference<ArenaRecord<RecordType>> record = new AtomicReference<>();
|
||||||
existingRecords.forEach((item) -> {
|
existingRecords.forEach((item) -> {
|
||||||
if (item.getUserId().equals(playerId)) {
|
if (item.getUserId().equals(playerId)) {
|
||||||
record.set(item);
|
record.set(item);
|
||||||
|
|||||||
@@ -35,23 +35,27 @@ public class DropperArena implements Arena {
|
|||||||
/**
|
/**
|
||||||
* An unique and persistent identifier for this arena
|
* An unique and persistent identifier for this arena
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
private final UUID arenaId;
|
private final UUID arenaId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A name used when listing and storing this arena.
|
* A name used when listing and storing this arena.
|
||||||
*/
|
*/
|
||||||
private @NotNull String arenaName;
|
@NotNull
|
||||||
|
private String arenaName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The location players are teleported to when joining this arena.
|
* The location players are teleported to when joining this arena.
|
||||||
*/
|
*/
|
||||||
private @NotNull Location spawnLocation;
|
@NotNull
|
||||||
|
private Location spawnLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The location players will be sent to when they win or lose the arena. If not set, their entry location should be
|
* The location players will be sent to when they win or lose the arena. If not set, their entry location should be
|
||||||
* used instead.
|
* used instead.
|
||||||
*/
|
*/
|
||||||
private @Nullable Location exitLocation;
|
@Nullable
|
||||||
|
private Location exitLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The velocity in the y-direction to apply to all players in this arena.
|
* The velocity in the y-direction to apply to all players in this arena.
|
||||||
@@ -73,27 +77,34 @@ public class DropperArena implements Arena {
|
|||||||
/**
|
/**
|
||||||
* Types of damage that won't be blocked in this arena
|
* Types of damage that won't be blocked in this arena
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
private Set<EntityDamageEvent.DamageCause> allowedDamageCauses;
|
private Set<EntityDamageEvent.DamageCause> allowedDamageCauses;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Types of damage that will trigger a loss in this arena
|
* Types of damage that will trigger a loss in this arena
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
private Set<EntityDamageEvent.DamageCause> lossTriggerDamageCauses;
|
private Set<EntityDamageEvent.DamageCause> lossTriggerDamageCauses;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The material of the block players have to hit to win this dropper arena
|
* The material of the block players have to hit to win this dropper arena
|
||||||
*/
|
*/
|
||||||
private @NotNull Material winBlockType;
|
@NotNull
|
||||||
|
private Material winBlockType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The arena data for this arena
|
* The arena data for this arena
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
private final DropperArenaData dropperArenaData;
|
private final DropperArenaData dropperArenaData;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
private final DropperArenaHandler dropperArenaHandler;
|
private final DropperArenaHandler dropperArenaHandler;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
private Map<RewardCondition, Set<Reward>> rewards = new HashMap<>();
|
private Map<RewardCondition, Set<Reward>> rewards = new HashMap<>();
|
||||||
|
|
||||||
|
@NotNull
|
||||||
private static final DropperConfiguration dropperConfiguration = MiniGames.getInstance().getDropperConfiguration();
|
private static final DropperConfiguration dropperConfiguration = MiniGames.getInstance().getDropperConfiguration();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -168,27 +179,32 @@ public class DropperArena implements Arena {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull DropperArenaData getData() {
|
@NotNull
|
||||||
|
public DropperArenaData getData() {
|
||||||
return this.dropperArenaData;
|
return this.dropperArenaData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull UUID getArenaId() {
|
@NotNull
|
||||||
|
public UUID getArenaId() {
|
||||||
return this.arenaId;
|
return this.arenaId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getArenaName() {
|
@NotNull
|
||||||
|
public String getArenaName() {
|
||||||
return this.arenaName;
|
return this.arenaName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Location getSpawnLocation() {
|
@NotNull
|
||||||
|
public Location getSpawnLocation() {
|
||||||
return this.spawnLocation.clone();
|
return this.spawnLocation.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable Location getExitLocation() {
|
@Nullable
|
||||||
|
public Location getExitLocation() {
|
||||||
return this.exitLocation != null ? this.exitLocation.clone() : null;
|
return this.exitLocation != null ? this.exitLocation.clone() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,7 +222,8 @@ public class DropperArena implements Arena {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Set<Reward> getRewards(RewardCondition rewardCondition) {
|
@NotNull
|
||||||
|
public Set<Reward> getRewards(@NotNull RewardCondition rewardCondition) {
|
||||||
if (this.rewards.containsKey(rewardCondition) && this.rewards.get(rewardCondition) != null) {
|
if (this.rewards.containsKey(rewardCondition) && this.rewards.get(rewardCondition) != null) {
|
||||||
return this.rewards.get(rewardCondition);
|
return this.rewards.get(rewardCondition);
|
||||||
} else {
|
} else {
|
||||||
@@ -231,12 +248,14 @@ public class DropperArena implements Arena {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Set<EntityDamageEvent.DamageCause> getAllowedDamageCauses() {
|
@NotNull
|
||||||
|
public Set<EntityDamageEvent.DamageCause> getAllowedDamageCauses() {
|
||||||
return this.allowedDamageCauses;
|
return this.allowedDamageCauses;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Set<EntityDamageEvent.DamageCause> getLossTriggerDamageCauses() {
|
@NotNull
|
||||||
|
public Set<EntityDamageEvent.DamageCause> getLossTriggerDamageCauses() {
|
||||||
return this.lossTriggerDamageCauses;
|
return this.lossTriggerDamageCauses;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,11 +433,8 @@ public class DropperArena implements Arena {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(@Nullable Object other) {
|
||||||
if (!(other instanceof DropperArena otherArena)) {
|
return other instanceof DropperArena otherArena && this.getArenaNameSanitized().equals(otherArena.getArenaNameSanitized());
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return this.getArenaNameSanitized().equals(otherArena.getArenaNameSanitized());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ public class DropperArenaData extends ArenaData {
|
|||||||
* @return <p>The deserialized dropper arena data</p>
|
* @return <p>The deserialized dropper arena data</p>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unused", "unchecked"})
|
@SuppressWarnings({"unused", "unchecked"})
|
||||||
public static @NotNull DropperArenaData deserialize(@NotNull Map<String, Object> data) {
|
@NotNull
|
||||||
|
public static DropperArenaData deserialize(@NotNull Map<String, Object> data) {
|
||||||
SerializableUUID serializableUUID = (SerializableUUID) data.get("arenaId");
|
SerializableUUID serializableUUID = (SerializableUUID) data.get("arenaId");
|
||||||
Map<ArenaGameMode, ArenaRecordsRegistry> recordsRegistry =
|
Map<ArenaGameMode, ArenaRecordsRegistry> recordsRegistry =
|
||||||
(Map<ArenaGameMode, ArenaRecordsRegistry>) data.get("recordsRegistry");
|
(Map<ArenaGameMode, ArenaRecordsRegistry>) data.get("recordsRegistry");
|
||||||
|
|||||||
@@ -77,8 +77,9 @@ public enum DropperArenaEditableProperty {
|
|||||||
*
|
*
|
||||||
* @param argumentString <p>The argument string used to specify this property</p>
|
* @param argumentString <p>The argument string used to specify this property</p>
|
||||||
*/
|
*/
|
||||||
DropperArenaEditableProperty(@NotNull String argumentString, Function<DropperArena, String> currentValueProvider,
|
DropperArenaEditableProperty(@NotNull String argumentString,
|
||||||
EditablePropertyType propertyType) {
|
@NotNull Function<DropperArena, String> currentValueProvider,
|
||||||
|
@NotNull EditablePropertyType propertyType) {
|
||||||
this.argumentString = argumentString;
|
this.argumentString = argumentString;
|
||||||
this.currentValueProvider = currentValueProvider;
|
this.currentValueProvider = currentValueProvider;
|
||||||
this.propertyType = propertyType;
|
this.propertyType = propertyType;
|
||||||
@@ -89,6 +90,7 @@ public enum DropperArenaEditableProperty {
|
|||||||
*
|
*
|
||||||
* @return <p>The type of this property</p>
|
* @return <p>The type of this property</p>
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public EditablePropertyType getPropertyType() {
|
public EditablePropertyType getPropertyType() {
|
||||||
return this.propertyType;
|
return this.propertyType;
|
||||||
}
|
}
|
||||||
@@ -99,7 +101,8 @@ public enum DropperArenaEditableProperty {
|
|||||||
* @param arena <p>The arena to check the value for</p>
|
* @param arena <p>The arena to check the value for</p>
|
||||||
* @return <p>The current value as a string</p>
|
* @return <p>The current value as a string</p>
|
||||||
*/
|
*/
|
||||||
public String getCurrentValueAsString(DropperArena arena) {
|
@NotNull
|
||||||
|
public String getCurrentValueAsString(@NotNull DropperArena arena) {
|
||||||
return this.currentValueProvider.apply(arena);
|
return this.currentValueProvider.apply(arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +111,8 @@ public enum DropperArenaEditableProperty {
|
|||||||
*
|
*
|
||||||
* @return <p>The argument string</p>
|
* @return <p>The argument string</p>
|
||||||
*/
|
*/
|
||||||
public @NotNull String getArgumentString() {
|
@NotNull
|
||||||
|
public String getArgumentString() {
|
||||||
return this.argumentString;
|
return this.argumentString;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +122,8 @@ public enum DropperArenaEditableProperty {
|
|||||||
* @param argumentString <p>The argument string used to specify an editable property</p>
|
* @param argumentString <p>The argument string used to specify an editable property</p>
|
||||||
* @return <p>The corresponding editable property, or null if not found</p>
|
* @return <p>The corresponding editable property, or null if not found</p>
|
||||||
*/
|
*/
|
||||||
public static @Nullable DropperArenaEditableProperty getFromArgumentString(String argumentString) {
|
@Nullable
|
||||||
|
public static DropperArenaEditableProperty getFromArgumentString(@NotNull String argumentString) {
|
||||||
for (DropperArenaEditableProperty property : DropperArenaEditableProperty.values()) {
|
for (DropperArenaEditableProperty property : DropperArenaEditableProperty.values()) {
|
||||||
if (property.argumentString.equalsIgnoreCase(argumentString)) {
|
if (property.argumentString.equalsIgnoreCase(argumentString)) {
|
||||||
return property;
|
return property;
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ public enum DropperArenaGameMode implements ConfigurationSerializable, ArenaGame
|
|||||||
* @param gameMode <p>The game-mode string to match</p>
|
* @param gameMode <p>The game-mode string to match</p>
|
||||||
* @return <p>The specified arena game-mode</p>
|
* @return <p>The specified arena game-mode</p>
|
||||||
*/
|
*/
|
||||||
public static @NotNull DropperArenaGameMode matchGameMode(@NotNull String gameMode) {
|
@NotNull
|
||||||
|
public static DropperArenaGameMode matchGameMode(@NotNull String gameMode) {
|
||||||
String sanitized = gameMode.trim().toLowerCase();
|
String sanitized = gameMode.trim().toLowerCase();
|
||||||
if (sanitized.matches("(invert(ed)?|inverse)")) {
|
if (sanitized.matches("(invert(ed)?|inverse)")) {
|
||||||
return DropperArenaGameMode.INVERTED;
|
return DropperArenaGameMode.INVERTED;
|
||||||
@@ -60,12 +61,14 @@ public enum DropperArenaGameMode implements ConfigurationSerializable, ArenaGame
|
|||||||
* @return <p>The deserialized arena game-mode</p>
|
* @return <p>The deserialized arena game-mode</p>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public static DropperArenaGameMode deserialize(Map<String, Object> data) {
|
@NotNull
|
||||||
|
public static DropperArenaGameMode deserialize(@NotNull Map<String, Object> data) {
|
||||||
return DropperArenaGameMode.valueOf((String) data.get("name"));
|
return DropperArenaGameMode.valueOf((String) data.get("name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull DropperArenaGameMode[] getValues() {
|
@NotNull
|
||||||
|
public DropperArenaGameMode[] getValues() {
|
||||||
return DropperArenaGameMode.values();
|
return DropperArenaGameMode.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ public class DropperArenaGroup extends ArenaGroup<DropperArena, DropperArenaGrou
|
|||||||
* @return <p>The deserialized arena group</p>
|
* @return <p>The deserialized arena group</p>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unused", "unchecked"})
|
@SuppressWarnings({"unused", "unchecked"})
|
||||||
public static @NotNull DropperArenaGroup deserialize(@NotNull Map<String, Object> data) {
|
@NotNull
|
||||||
|
public static DropperArenaGroup deserialize(@NotNull Map<String, Object> data) {
|
||||||
UUID id = ((SerializableUUID) data.get("groupId")).getRawValue();
|
UUID id = ((SerializableUUID) data.get("groupId")).getRawValue();
|
||||||
String name = (String) data.get("groupName");
|
String name = (String) data.get("groupName");
|
||||||
List<SerializableUUID> serializableArenas = (List<SerializableUUID>) data.get("arenas");
|
List<SerializableUUID> serializableArenas = (List<SerializableUUID>) data.get("arenas");
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import net.knarcraft.minigames.arena.ArenaHandler;
|
|||||||
import net.knarcraft.minigames.arena.ArenaPlayerRegistry;
|
import net.knarcraft.minigames.arena.ArenaPlayerRegistry;
|
||||||
import net.knarcraft.minigames.config.MiniGameMessage;
|
import net.knarcraft.minigames.config.MiniGameMessage;
|
||||||
import net.knarcraft.minigames.util.DropperArenaStorageHelper;
|
import net.knarcraft.minigames.util.DropperArenaStorageHelper;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -24,7 +25,7 @@ public class DropperArenaHandler extends ArenaHandler<DropperArena, DropperArena
|
|||||||
*
|
*
|
||||||
* @param playerRegistry <p>The registry keeping track of player sessions</p>
|
* @param playerRegistry <p>The registry keeping track of player sessions</p>
|
||||||
*/
|
*/
|
||||||
public DropperArenaHandler(ArenaPlayerRegistry<DropperArena> playerRegistry) {
|
public DropperArenaHandler(@NotNull ArenaPlayerRegistry<DropperArena> playerRegistry) {
|
||||||
super(playerRegistry);
|
super(playerRegistry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.knarcraft.minigames.arena.dropper;
|
package net.knarcraft.minigames.arena.dropper;
|
||||||
|
|
||||||
import net.knarcraft.minigames.arena.AbstractArenaPlayerRegistry;
|
import net.knarcraft.minigames.arena.AbstractArenaPlayerRegistry;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A registry to keep track of which players are playing in which arenas
|
* A registry to keep track of which players are playing in which arenas
|
||||||
@@ -8,6 +9,7 @@ import net.knarcraft.minigames.arena.AbstractArenaPlayerRegistry;
|
|||||||
public class DropperArenaPlayerRegistry extends AbstractArenaPlayerRegistry<DropperArena> {
|
public class DropperArenaPlayerRegistry extends AbstractArenaPlayerRegistry<DropperArena> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@NotNull
|
||||||
protected String getEntryStateStorageKey() {
|
protected String getEntryStateStorageKey() {
|
||||||
return "dropper";
|
return "dropper";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ public class DropperArenaRecordsRegistry extends ArenaRecordsRegistry {
|
|||||||
* @return <p>The deserialized records registry</p>
|
* @return <p>The deserialized records registry</p>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unused", "unchecked"})
|
@SuppressWarnings({"unused", "unchecked"})
|
||||||
public static DropperArenaRecordsRegistry deserialize(Map<String, Object> data) {
|
@NotNull
|
||||||
|
public static DropperArenaRecordsRegistry deserialize(@NotNull Map<String, Object> data) {
|
||||||
UUID arenaId = ((SerializableUUID) data.get("arenaId")).getRawValue();
|
UUID arenaId = ((SerializableUUID) data.get("arenaId")).getRawValue();
|
||||||
Set<IntegerRecord> leastDeaths =
|
Set<IntegerRecord> leastDeaths =
|
||||||
(Set<IntegerRecord>) data.getOrDefault("leastDeaths", new HashMap<>());
|
(Set<IntegerRecord>) data.getOrDefault("leastDeaths", new HashMap<>());
|
||||||
|
|||||||
@@ -23,9 +23,12 @@ import java.util.logging.Level;
|
|||||||
*/
|
*/
|
||||||
public class DropperArenaSession extends AbstractArenaSession {
|
public class DropperArenaSession extends AbstractArenaSession {
|
||||||
|
|
||||||
private final @NotNull DropperArena arena;
|
@NotNull
|
||||||
private final @NotNull Player player;
|
private final DropperArena arena;
|
||||||
private final @NotNull DropperArenaGameMode gameMode;
|
@NotNull
|
||||||
|
private final Player player;
|
||||||
|
@NotNull
|
||||||
|
private final DropperArenaGameMode gameMode;
|
||||||
private boolean startedMoving = false;
|
private boolean startedMoving = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,7 +70,8 @@ public class DropperArenaSession extends AbstractArenaSession {
|
|||||||
*
|
*
|
||||||
* @return <p>This session's player</p>
|
* @return <p>This session's player</p>
|
||||||
*/
|
*/
|
||||||
public @NotNull Player getPlayer() {
|
@NotNull
|
||||||
|
public Player getPlayer() {
|
||||||
return this.player;
|
return this.player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,12 +80,14 @@ public class DropperArenaSession extends AbstractArenaSession {
|
|||||||
*
|
*
|
||||||
* @return <p>The game-mode for this session</p>
|
* @return <p>The game-mode for this session</p>
|
||||||
*/
|
*/
|
||||||
public @NotNull DropperArenaGameMode getGameMode() {
|
@NotNull
|
||||||
|
public DropperArenaGameMode getGameMode() {
|
||||||
return this.gameMode;
|
return this.gameMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull PlayerEntryState getEntryState() {
|
@NotNull
|
||||||
|
public PlayerEntryState getEntryState() {
|
||||||
return this.entryState;
|
return this.entryState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,12 +126,14 @@ public class DropperArenaSession extends AbstractArenaSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull DropperArena getArena() {
|
@NotNull
|
||||||
|
public DropperArena getArena() {
|
||||||
return this.arena;
|
return this.arena;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull ArenaGUI getGUI() {
|
@NotNull
|
||||||
|
public ArenaGUI getGUI() {
|
||||||
if (GeyserHelper.isGeyserPlayer(this.player)) {
|
if (GeyserHelper.isGeyserPlayer(this.player)) {
|
||||||
return new DropperGUIBedrock(this.player);
|
return new DropperGUIBedrock(this.player);
|
||||||
} else {
|
} else {
|
||||||
@@ -151,6 +159,7 @@ public class DropperArenaSession extends AbstractArenaSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@NotNull
|
||||||
protected String getGameModeString() {
|
protected String getGameModeString() {
|
||||||
return switch (this.gameMode) {
|
return switch (this.gameMode) {
|
||||||
case DEFAULT -> "default";
|
case DEFAULT -> "default";
|
||||||
|
|||||||
@@ -69,7 +69,8 @@ public enum DropperArenaStorageKey implements StorageKey {
|
|||||||
LOSS_TRIGGER_DAMAGE_CAUSES("lossTriggerDamageCauses"),
|
LOSS_TRIGGER_DAMAGE_CAUSES("lossTriggerDamageCauses"),
|
||||||
;
|
;
|
||||||
|
|
||||||
private final @NotNull String key;
|
@NotNull
|
||||||
|
private final String key;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new arena storage key
|
* Instantiates a new arena storage key
|
||||||
@@ -81,7 +82,8 @@ public enum DropperArenaStorageKey implements StorageKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getKey() {
|
@NotNull
|
||||||
|
public String getKey() {
|
||||||
return this.key;
|
return this.key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public class DropperPlayerEntryState extends AbstractPlayerEntryState {
|
|||||||
|
|
||||||
private final float originalFlySpeed;
|
private final float originalFlySpeed;
|
||||||
private final float horizontalVelocity;
|
private final float horizontalVelocity;
|
||||||
|
@NotNull
|
||||||
private final DropperArenaGameMode arenaGameMode;
|
private final DropperArenaGameMode arenaGameMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -118,7 +119,8 @@ public class DropperPlayerEntryState extends AbstractPlayerEntryState {
|
|||||||
* @return <p>The data to deserialize</p>
|
* @return <p>The data to deserialize</p>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unused", "unchecked"})
|
@SuppressWarnings({"unused", "unchecked"})
|
||||||
public static DropperPlayerEntryState deserialize(Map<String, Object> data) {
|
@NotNull
|
||||||
|
public static DropperPlayerEntryState deserialize(@NotNull Map<String, Object> data) {
|
||||||
UUID playerId = ((SerializableUUID) data.get("playerId")).getRawValue();
|
UUID playerId = ((SerializableUUID) data.get("playerId")).getRawValue();
|
||||||
Location entryLocation = (Location) data.get("entryLocation");
|
Location entryLocation = (Location) data.get("entryLocation");
|
||||||
boolean originalIsFlying = getBoolean(data, "originalIsFlying");
|
boolean originalIsFlying = getBoolean(data, "originalIsFlying");
|
||||||
|
|||||||
@@ -38,53 +38,63 @@ public class ParkourArena implements Arena {
|
|||||||
/**
|
/**
|
||||||
* An unique and persistent identifier for this arena
|
* An unique and persistent identifier for this arena
|
||||||
*/
|
*/
|
||||||
private final @NotNull UUID arenaId;
|
@NotNull
|
||||||
|
private final UUID arenaId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A name used when listing and storing this arena.
|
* A name used when listing and storing this arena.
|
||||||
*/
|
*/
|
||||||
private @NotNull String arenaName;
|
@NotNull
|
||||||
|
private String arenaName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The location players are teleported to when joining this arena.
|
* The location players are teleported to when joining this arena.
|
||||||
*/
|
*/
|
||||||
private @NotNull Location spawnLocation;
|
@NotNull
|
||||||
|
private Location spawnLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The location players will be sent to when they win or lose the arena. If not set, their entry location should be
|
* The location players will be sent to when they win or lose the arena. If not set, their entry location should be
|
||||||
* used instead.
|
* used instead.
|
||||||
*/
|
*/
|
||||||
private @Nullable Location exitLocation;
|
@Nullable
|
||||||
|
private Location exitLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The material of the block players have to hit to win this parkour arena
|
* The material of the block players have to hit to win this parkour arena
|
||||||
*/
|
*/
|
||||||
private @NotNull Material winBlockType;
|
@NotNull
|
||||||
|
private Material winBlockType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The location the player has to reach to win. If not set, winBlockType is used instead
|
* The location the player has to reach to win. If not set, winBlockType is used instead
|
||||||
*/
|
*/
|
||||||
private @Nullable Location winLocation;
|
@Nullable
|
||||||
|
private Location winLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The names of the block types constituting this arena's kill plane
|
* The names of the block types constituting this arena's kill plane
|
||||||
*/
|
*/
|
||||||
private @Nullable Set<String> killPlaneBlockNames;
|
@Nullable
|
||||||
|
private Set<String> killPlaneBlockNames;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The block types constituting this arena's kill plane
|
* The block types constituting this arena's kill plane
|
||||||
*/
|
*/
|
||||||
private @Nullable Set<Material> killPlaneBlocks;
|
@Nullable
|
||||||
|
private Set<Material> killPlaneBlocks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The names of the block types serving as obstacles for this arena
|
* The names of the block types serving as obstacles for this arena
|
||||||
*/
|
*/
|
||||||
private @Nullable Set<String> obstacleBlockNames;
|
@Nullable
|
||||||
|
private Set<String> obstacleBlockNames;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The block types serving as obstacles for this arena
|
* The block types serving as obstacles for this arena
|
||||||
*/
|
*/
|
||||||
private @Nullable Set<Material> obstacleBlocks;
|
@Nullable
|
||||||
|
private Set<Material> obstacleBlocks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum amount of players able to join this arena at any time
|
* The maximum amount of players able to join this arena at any time
|
||||||
@@ -94,25 +104,31 @@ public class ParkourArena implements Arena {
|
|||||||
/**
|
/**
|
||||||
* Types of damage that won't be blocked in this arena
|
* Types of damage that won't be blocked in this arena
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
private Set<EntityDamageEvent.DamageCause> allowedDamageCauses;
|
private Set<EntityDamageEvent.DamageCause> allowedDamageCauses;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Types of damage that will trigger a loss in this arena
|
* Types of damage that will trigger a loss in this arena
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
private Set<EntityDamageEvent.DamageCause> lossTriggerDamageCauses;
|
private Set<EntityDamageEvent.DamageCause> lossTriggerDamageCauses;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The checkpoints for this arena. Entering a checkpoint overrides the player's spawn location.
|
* The checkpoints for this arena. Entering a checkpoint overrides the player's spawn location.
|
||||||
*/
|
*/
|
||||||
private final @NotNull List<Location> checkpoints;
|
@NotNull
|
||||||
|
private final List<Location> checkpoints;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The arena data for this arena
|
* The arena data for this arena
|
||||||
*/
|
*/
|
||||||
private final @NotNull ParkourArenaData parkourArenaData;
|
@NotNull
|
||||||
|
private final ParkourArenaData parkourArenaData;
|
||||||
|
|
||||||
private final @NotNull ParkourArenaHandler parkourArenaHandler;
|
@NotNull
|
||||||
|
private final ParkourArenaHandler parkourArenaHandler;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
private Map<RewardCondition, Set<Reward>> rewards = new HashMap<>();
|
private Map<RewardCondition, Set<Reward>> rewards = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -198,27 +214,32 @@ public class ParkourArena implements Arena {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull ParkourArenaData getData() {
|
@NotNull
|
||||||
|
public ParkourArenaData getData() {
|
||||||
return this.parkourArenaData;
|
return this.parkourArenaData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull UUID getArenaId() {
|
@NotNull
|
||||||
|
public UUID getArenaId() {
|
||||||
return this.arenaId;
|
return this.arenaId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getArenaName() {
|
@NotNull
|
||||||
|
public String getArenaName() {
|
||||||
return this.arenaName;
|
return this.arenaName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Location getSpawnLocation() {
|
@NotNull
|
||||||
|
public Location getSpawnLocation() {
|
||||||
return this.spawnLocation;
|
return this.spawnLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable Location getExitLocation() {
|
@Nullable
|
||||||
|
public Location getExitLocation() {
|
||||||
return this.exitLocation;
|
return this.exitLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,7 +257,8 @@ public class ParkourArena implements Arena {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Set<Reward> getRewards(RewardCondition rewardCondition) {
|
@NotNull
|
||||||
|
public Set<Reward> getRewards(@NotNull RewardCondition rewardCondition) {
|
||||||
if (this.rewards.containsKey(rewardCondition)) {
|
if (this.rewards.containsKey(rewardCondition)) {
|
||||||
return this.rewards.get(rewardCondition);
|
return this.rewards.get(rewardCondition);
|
||||||
} else {
|
} else {
|
||||||
@@ -261,12 +283,14 @@ public class ParkourArena implements Arena {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Set<EntityDamageEvent.DamageCause> getAllowedDamageCauses() {
|
@NotNull
|
||||||
|
public Set<EntityDamageEvent.DamageCause> getAllowedDamageCauses() {
|
||||||
return this.allowedDamageCauses;
|
return this.allowedDamageCauses;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Set<EntityDamageEvent.DamageCause> getLossTriggerDamageCauses() {
|
@NotNull
|
||||||
|
public Set<EntityDamageEvent.DamageCause> getLossTriggerDamageCauses() {
|
||||||
return this.lossTriggerDamageCauses;
|
return this.lossTriggerDamageCauses;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,7 +321,8 @@ public class ParkourArena implements Arena {
|
|||||||
*
|
*
|
||||||
* @return <p>The win trigger's location</p>
|
* @return <p>The win trigger's location</p>
|
||||||
*/
|
*/
|
||||||
public @Nullable Location getWinLocation() {
|
@Nullable
|
||||||
|
public Location getWinLocation() {
|
||||||
return this.winLocation != null ? this.winLocation.clone() : null;
|
return this.winLocation != null ? this.winLocation.clone() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,7 +331,8 @@ public class ParkourArena implements Arena {
|
|||||||
*
|
*
|
||||||
* @return <p>The types of blocks that cause a loss</p>
|
* @return <p>The types of blocks that cause a loss</p>
|
||||||
*/
|
*/
|
||||||
public @NotNull Set<Material> getKillPlaneBlocks() {
|
@NotNull
|
||||||
|
public Set<Material> getKillPlaneBlocks() {
|
||||||
if (this.killPlaneBlocks != null) {
|
if (this.killPlaneBlocks != null) {
|
||||||
return new HashSet<>(this.killPlaneBlocks);
|
return new HashSet<>(this.killPlaneBlocks);
|
||||||
} else {
|
} else {
|
||||||
@@ -319,7 +345,8 @@ public class ParkourArena implements Arena {
|
|||||||
*
|
*
|
||||||
* @return <p>The names of the types of blocks that cause a loss</p>
|
* @return <p>The names of the types of blocks that cause a loss</p>
|
||||||
*/
|
*/
|
||||||
public @Nullable Set<String> getKillPlaneBlockNames() {
|
@Nullable
|
||||||
|
public Set<String> getKillPlaneBlockNames() {
|
||||||
return this.killPlaneBlockNames;
|
return this.killPlaneBlockNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,7 +355,8 @@ public class ParkourArena implements Arena {
|
|||||||
*
|
*
|
||||||
* @return <p>The types of blocks used as obstacles</p>
|
* @return <p>The types of blocks used as obstacles</p>
|
||||||
*/
|
*/
|
||||||
public @NotNull Set<Material> getObstacleBlocks() {
|
@NotNull
|
||||||
|
public Set<Material> getObstacleBlocks() {
|
||||||
if (this.obstacleBlocks != null) {
|
if (this.obstacleBlocks != null) {
|
||||||
return new HashSet<>(this.obstacleBlocks);
|
return new HashSet<>(this.obstacleBlocks);
|
||||||
} else {
|
} else {
|
||||||
@@ -341,7 +369,8 @@ public class ParkourArena implements Arena {
|
|||||||
*
|
*
|
||||||
* @return <p>The names of the blocks used as this arena's obstacle blocks</p>
|
* @return <p>The names of the blocks used as this arena's obstacle blocks</p>
|
||||||
*/
|
*/
|
||||||
public @Nullable Set<String> getObstacleBlockNames() {
|
@Nullable
|
||||||
|
public Set<String> getObstacleBlockNames() {
|
||||||
return this.obstacleBlockNames;
|
return this.obstacleBlockNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,6 +379,7 @@ public class ParkourArena implements Arena {
|
|||||||
*
|
*
|
||||||
* @return <p>All checkpoint locations for this arena</p>
|
* @return <p>All checkpoint locations for this arena</p>
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public List<Location> getCheckpoints() {
|
public List<Location> getCheckpoints() {
|
||||||
List<Location> copy = new ArrayList<>(this.checkpoints.size());
|
List<Location> copy = new ArrayList<>(this.checkpoints.size());
|
||||||
for (Location location : this.checkpoints) {
|
for (Location location : this.checkpoints) {
|
||||||
@@ -569,11 +599,8 @@ public class ParkourArena implements Arena {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(@Nullable Object other) {
|
||||||
if (!(other instanceof ParkourArena otherArena)) {
|
return other instanceof ParkourArena otherArena && this.getArenaNameSanitized().equals(otherArena.getArenaNameSanitized());
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return this.getArenaNameSanitized().equals(otherArena.getArenaNameSanitized());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ public class ParkourArenaData extends ArenaData {
|
|||||||
* @return <p>The deserialized parkour arena data</p>
|
* @return <p>The deserialized parkour arena data</p>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unused", "unchecked"})
|
@SuppressWarnings({"unused", "unchecked"})
|
||||||
public static @NotNull ParkourArenaData deserialize(@NotNull Map<String, Object> data) {
|
@NotNull
|
||||||
|
public static ParkourArenaData deserialize(@NotNull Map<String, Object> data) {
|
||||||
SerializableUUID serializableUUID = (SerializableUUID) data.get("arenaId");
|
SerializableUUID serializableUUID = (SerializableUUID) data.get("arenaId");
|
||||||
Map<ArenaGameMode, ArenaRecordsRegistry> recordsRegistry =
|
Map<ArenaGameMode, ArenaRecordsRegistry> recordsRegistry =
|
||||||
(Map<ArenaGameMode, ArenaRecordsRegistry>) data.get("recordsRegistry");
|
(Map<ArenaGameMode, ArenaRecordsRegistry>) data.get("recordsRegistry");
|
||||||
|
|||||||
@@ -91,8 +91,11 @@ public enum ParkourArenaEditableProperty {
|
|||||||
EditablePropertyType.DAMAGE_CAUSE_LIST),
|
EditablePropertyType.DAMAGE_CAUSE_LIST),
|
||||||
;
|
;
|
||||||
|
|
||||||
private final @NotNull String argumentString;
|
@NotNull
|
||||||
|
private final String argumentString;
|
||||||
|
@NotNull
|
||||||
private final Function<ParkourArena, String> currentValueProvider;
|
private final Function<ParkourArena, String> currentValueProvider;
|
||||||
|
@NotNull
|
||||||
private final EditablePropertyType propertyType;
|
private final EditablePropertyType propertyType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,8 +103,8 @@ public enum ParkourArenaEditableProperty {
|
|||||||
*
|
*
|
||||||
* @param argumentString <p>The argument string used to specify this property</p>
|
* @param argumentString <p>The argument string used to specify this property</p>
|
||||||
*/
|
*/
|
||||||
ParkourArenaEditableProperty(@NotNull String argumentString, Function<ParkourArena, String> currentValueProvider,
|
ParkourArenaEditableProperty(@NotNull String argumentString, @NotNull Function<ParkourArena, String> currentValueProvider,
|
||||||
EditablePropertyType propertyType) {
|
@NotNull EditablePropertyType propertyType) {
|
||||||
this.argumentString = argumentString;
|
this.argumentString = argumentString;
|
||||||
this.currentValueProvider = currentValueProvider;
|
this.currentValueProvider = currentValueProvider;
|
||||||
this.propertyType = propertyType;
|
this.propertyType = propertyType;
|
||||||
@@ -112,6 +115,7 @@ public enum ParkourArenaEditableProperty {
|
|||||||
*
|
*
|
||||||
* @return <p>The type of this property</p>
|
* @return <p>The type of this property</p>
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public EditablePropertyType getPropertyType() {
|
public EditablePropertyType getPropertyType() {
|
||||||
return this.propertyType;
|
return this.propertyType;
|
||||||
}
|
}
|
||||||
@@ -122,7 +126,8 @@ public enum ParkourArenaEditableProperty {
|
|||||||
* @param arena <p>The arena to check the value for</p>
|
* @param arena <p>The arena to check the value for</p>
|
||||||
* @return <p>The current value as a string</p>
|
* @return <p>The current value as a string</p>
|
||||||
*/
|
*/
|
||||||
public String getCurrentValueAsString(ParkourArena arena) {
|
@NotNull
|
||||||
|
public String getCurrentValueAsString(@NotNull ParkourArena arena) {
|
||||||
return this.currentValueProvider.apply(arena);
|
return this.currentValueProvider.apply(arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +146,8 @@ public enum ParkourArenaEditableProperty {
|
|||||||
* @param argumentString <p>The argument string used to specify an editable property</p>
|
* @param argumentString <p>The argument string used to specify an editable property</p>
|
||||||
* @return <p>The corresponding editable property, or null if not found</p>
|
* @return <p>The corresponding editable property, or null if not found</p>
|
||||||
*/
|
*/
|
||||||
public static @Nullable ParkourArenaEditableProperty getFromArgumentString(String argumentString) {
|
@Nullable
|
||||||
|
public static ParkourArenaEditableProperty getFromArgumentString(@NotNull String argumentString) {
|
||||||
for (ParkourArenaEditableProperty property : ParkourArenaEditableProperty.values()) {
|
for (ParkourArenaEditableProperty property : ParkourArenaEditableProperty.values()) {
|
||||||
if (property.argumentString.equalsIgnoreCase(argumentString)) {
|
if (property.argumentString.equalsIgnoreCase(argumentString)) {
|
||||||
return property;
|
return property;
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ public enum ParkourArenaGameMode implements ConfigurationSerializable, ArenaGame
|
|||||||
* @param gameMode <p>The game-mode string to match</p>
|
* @param gameMode <p>The game-mode string to match</p>
|
||||||
* @return <p>The specified arena game-mode</p>
|
* @return <p>The specified arena game-mode</p>
|
||||||
*/
|
*/
|
||||||
public static @NotNull ParkourArenaGameMode matchGameMode(@NotNull String gameMode) {
|
@NotNull
|
||||||
|
public static ParkourArenaGameMode matchGameMode(@NotNull String gameMode) {
|
||||||
try {
|
try {
|
||||||
return ParkourArenaGameMode.valueOf(gameMode.toUpperCase());
|
return ParkourArenaGameMode.valueOf(gameMode.toUpperCase());
|
||||||
} catch (IllegalArgumentException exception) {
|
} catch (IllegalArgumentException exception) {
|
||||||
@@ -52,12 +53,14 @@ public enum ParkourArenaGameMode implements ConfigurationSerializable, ArenaGame
|
|||||||
* @return <p>The deserialized arena game-mode</p>
|
* @return <p>The deserialized arena game-mode</p>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public static ParkourArenaGameMode deserialize(Map<String, Object> data) {
|
@NotNull
|
||||||
|
public static ParkourArenaGameMode deserialize(@NotNull Map<String, Object> data) {
|
||||||
return ParkourArenaGameMode.valueOf((String) data.get("name"));
|
return ParkourArenaGameMode.valueOf((String) data.get("name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull ParkourArenaGameMode[] getValues() {
|
@NotNull
|
||||||
|
public ParkourArenaGameMode[] getValues() {
|
||||||
return ParkourArenaGameMode.values();
|
return ParkourArenaGameMode.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ public class ParkourArenaGroup extends ArenaGroup<ParkourArena, ParkourArenaGrou
|
|||||||
* @return <p>The deserialized arena group</p>
|
* @return <p>The deserialized arena group</p>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unused", "unchecked"})
|
@SuppressWarnings({"unused", "unchecked"})
|
||||||
public static @NotNull ParkourArenaGroup deserialize(@NotNull Map<String, Object> data) {
|
@NotNull
|
||||||
|
public static ParkourArenaGroup deserialize(@NotNull Map<String, Object> data) {
|
||||||
UUID id = ((SerializableUUID) data.get("groupId")).getRawValue();
|
UUID id = ((SerializableUUID) data.get("groupId")).getRawValue();
|
||||||
String name = (String) data.get("groupName");
|
String name = (String) data.get("groupName");
|
||||||
List<SerializableUUID> serializableArenas = (List<SerializableUUID>) data.get("arenas");
|
List<SerializableUUID> serializableArenas = (List<SerializableUUID>) data.get("arenas");
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import net.knarcraft.minigames.arena.ArenaHandler;
|
|||||||
import net.knarcraft.minigames.arena.ArenaPlayerRegistry;
|
import net.knarcraft.minigames.arena.ArenaPlayerRegistry;
|
||||||
import net.knarcraft.minigames.config.MiniGameMessage;
|
import net.knarcraft.minigames.config.MiniGameMessage;
|
||||||
import net.knarcraft.minigames.util.ParkourArenaStorageHelper;
|
import net.knarcraft.minigames.util.ParkourArenaStorageHelper;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -24,7 +25,7 @@ public class ParkourArenaHandler extends ArenaHandler<ParkourArena, ParkourArena
|
|||||||
*
|
*
|
||||||
* @param playerRegistry <p>The registry keeping track of player sessions</p>
|
* @param playerRegistry <p>The registry keeping track of player sessions</p>
|
||||||
*/
|
*/
|
||||||
public ParkourArenaHandler(ArenaPlayerRegistry<ParkourArena> playerRegistry) {
|
public ParkourArenaHandler(@NotNull ArenaPlayerRegistry<ParkourArena> playerRegistry) {
|
||||||
super(playerRegistry);
|
super(playerRegistry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.knarcraft.minigames.arena.parkour;
|
package net.knarcraft.minigames.arena.parkour;
|
||||||
|
|
||||||
import net.knarcraft.minigames.arena.AbstractArenaPlayerRegistry;
|
import net.knarcraft.minigames.arena.AbstractArenaPlayerRegistry;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A registry to keep track of which players are playing in which arenas
|
* A registry to keep track of which players are playing in which arenas
|
||||||
@@ -8,6 +9,7 @@ import net.knarcraft.minigames.arena.AbstractArenaPlayerRegistry;
|
|||||||
public class ParkourArenaPlayerRegistry extends AbstractArenaPlayerRegistry<ParkourArena> {
|
public class ParkourArenaPlayerRegistry extends AbstractArenaPlayerRegistry<ParkourArena> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@NotNull
|
||||||
protected String getEntryStateStorageKey() {
|
protected String getEntryStateStorageKey() {
|
||||||
return "parkour";
|
return "parkour";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ public class ParkourArenaRecordsRegistry extends ArenaRecordsRegistry {
|
|||||||
* @return <p>The deserialized records registry</p>
|
* @return <p>The deserialized records registry</p>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unused", "unchecked"})
|
@SuppressWarnings({"unused", "unchecked"})
|
||||||
public static ParkourArenaRecordsRegistry deserialize(Map<String, Object> data) {
|
@NotNull
|
||||||
|
public static ParkourArenaRecordsRegistry deserialize(@NotNull Map<String, Object> data) {
|
||||||
UUID arenaId = ((SerializableUUID) data.get("arenaId")).getRawValue();
|
UUID arenaId = ((SerializableUUID) data.get("arenaId")).getRawValue();
|
||||||
Set<IntegerRecord> leastDeaths =
|
Set<IntegerRecord> leastDeaths =
|
||||||
(Set<IntegerRecord>) data.getOrDefault("leastDeaths", new HashMap<>());
|
(Set<IntegerRecord>) data.getOrDefault("leastDeaths", new HashMap<>());
|
||||||
|
|||||||
@@ -33,11 +33,16 @@ import java.util.logging.Level;
|
|||||||
*/
|
*/
|
||||||
public class ParkourArenaSession extends AbstractArenaSession {
|
public class ParkourArenaSession extends AbstractArenaSession {
|
||||||
|
|
||||||
private static final @NotNull Map<Arena, Set<Block>> changedLevers = new HashMap<>();
|
@NotNull
|
||||||
private final @NotNull ParkourArena arena;
|
private static final Map<Arena, Set<Block>> changedLevers = new HashMap<>();
|
||||||
private final @NotNull Player player;
|
@NotNull
|
||||||
private final @NotNull ParkourArenaGameMode gameMode;
|
private final ParkourArena arena;
|
||||||
private @Nullable Location reachedCheckpoint = null;
|
@NotNull
|
||||||
|
private final Player player;
|
||||||
|
@NotNull
|
||||||
|
private final ParkourArenaGameMode gameMode;
|
||||||
|
@Nullable
|
||||||
|
private Location reachedCheckpoint = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new parkour arena session
|
* Instantiates a new parkour arena session
|
||||||
@@ -62,7 +67,8 @@ public class ParkourArenaSession extends AbstractArenaSession {
|
|||||||
*
|
*
|
||||||
* @return <p>The game-mode for this session</p>
|
* @return <p>The game-mode for this session</p>
|
||||||
*/
|
*/
|
||||||
public @NotNull ParkourArenaGameMode getGameMode() {
|
@NotNull
|
||||||
|
public ParkourArenaGameMode getGameMode() {
|
||||||
return this.gameMode;
|
return this.gameMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,12 +96,14 @@ public class ParkourArenaSession extends AbstractArenaSession {
|
|||||||
*
|
*
|
||||||
* @return <p>The registered checkpoint, or null if not set</p>
|
* @return <p>The registered checkpoint, or null if not set</p>
|
||||||
*/
|
*/
|
||||||
public @Nullable Location getRegisteredCheckpoint() {
|
@Nullable
|
||||||
|
public Location getRegisteredCheckpoint() {
|
||||||
return this.reachedCheckpoint;
|
return this.reachedCheckpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull PlayerEntryState getEntryState() {
|
@NotNull
|
||||||
|
public PlayerEntryState getEntryState() {
|
||||||
return this.entryState;
|
return this.entryState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,12 +147,14 @@ public class ParkourArenaSession extends AbstractArenaSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull ParkourArena getArena() {
|
@NotNull
|
||||||
|
public ParkourArena getArena() {
|
||||||
return this.arena;
|
return this.arena;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull ArenaGUI getGUI() {
|
@NotNull
|
||||||
|
public ArenaGUI getGUI() {
|
||||||
if (GeyserHelper.isGeyserPlayer(this.player)) {
|
if (GeyserHelper.isGeyserPlayer(this.player)) {
|
||||||
return new ParkourGUIBedrock(this.player);
|
return new ParkourGUIBedrock(this.player);
|
||||||
} else {
|
} else {
|
||||||
@@ -173,6 +183,7 @@ public class ParkourArenaSession extends AbstractArenaSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@NotNull
|
||||||
protected String getGameModeString() {
|
protected String getGameModeString() {
|
||||||
return switch (this.gameMode) {
|
return switch (this.gameMode) {
|
||||||
case DEFAULT -> "default";
|
case DEFAULT -> "default";
|
||||||
|
|||||||
@@ -91,7 +91,8 @@ public enum ParkourArenaStorageKey implements StorageKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getKey() {
|
@NotNull
|
||||||
|
public String getKey() {
|
||||||
return this.key;
|
return this.key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,10 +42,10 @@ public class ParkourPlayerEntryState extends AbstractPlayerEntryState {
|
|||||||
* @param originalHealth <p>The health of the player when joining the arena</p>
|
* @param originalHealth <p>The health of the player when joining the arena</p>
|
||||||
* @param originalSaturation <p>The saturation of the player when joining the arena</p>
|
* @param originalSaturation <p>The saturation of the player when joining the arena</p>
|
||||||
*/
|
*/
|
||||||
public ParkourPlayerEntryState(@NotNull UUID playerId, Location entryLocation,
|
public ParkourPlayerEntryState(@NotNull UUID playerId, @NotNull Location entryLocation,
|
||||||
boolean originalIsFlying, GameMode originalGameMode, boolean originalAllowFlight,
|
boolean originalIsFlying, @NotNull GameMode originalGameMode, boolean originalAllowFlight,
|
||||||
boolean originalInvulnerable, boolean originalIsSwimming,
|
boolean originalInvulnerable, boolean originalIsSwimming,
|
||||||
boolean originalCollideAble, Collection<PotionEffect> originalPotionEffects,
|
boolean originalCollideAble, @NotNull Collection<PotionEffect> originalPotionEffects,
|
||||||
double originalHealth, float originalSaturation) {
|
double originalHealth, float originalSaturation) {
|
||||||
super(playerId, entryLocation, originalIsFlying, originalGameMode, originalAllowFlight,
|
super(playerId, entryLocation, originalIsFlying, originalGameMode, originalAllowFlight,
|
||||||
originalInvulnerable, originalIsSwimming, originalCollideAble, originalPotionEffects, originalHealth,
|
originalInvulnerable, originalIsSwimming, originalCollideAble, originalPotionEffects, originalHealth,
|
||||||
@@ -70,7 +70,8 @@ public class ParkourPlayerEntryState extends AbstractPlayerEntryState {
|
|||||||
* @return <p>The data to deserialize</p>
|
* @return <p>The data to deserialize</p>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unused", "unchecked"})
|
@SuppressWarnings({"unused", "unchecked"})
|
||||||
public static ParkourPlayerEntryState deserialize(Map<String, Object> data) {
|
@NotNull
|
||||||
|
public static ParkourPlayerEntryState deserialize(@NotNull Map<String, Object> data) {
|
||||||
UUID playerId = ((SerializableUUID) data.get("playerId")).getRawValue();
|
UUID playerId = ((SerializableUUID) data.get("playerId")).getRawValue();
|
||||||
Location entryLocation = (Location) data.get("entryLocation");
|
Location entryLocation = (Location) data.get("entryLocation");
|
||||||
boolean originalIsFlying = getBoolean(data, "originalIsFlying");
|
boolean originalIsFlying = getBoolean(data, "originalIsFlying");
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package net.knarcraft.minigames.arena.record;
|
|||||||
import net.knarcraft.minigames.container.SerializableUUID;
|
import net.knarcraft.minigames.container.SerializableUUID;
|
||||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -12,16 +13,16 @@ import java.util.UUID;
|
|||||||
/**
|
/**
|
||||||
* A record stored for an arena
|
* A record stored for an arena
|
||||||
*/
|
*/
|
||||||
public abstract class ArenaRecord<K extends Comparable<K>> implements Comparable<ArenaRecord<K>>, ConfigurationSerializable {
|
public abstract class ArenaRecord<RecordType extends Comparable<RecordType>> implements Comparable<ArenaRecord<RecordType>>, ConfigurationSerializable {
|
||||||
|
|
||||||
private final UUID userId;
|
private final UUID userId;
|
||||||
private final K record;
|
private final RecordType record;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param userId <p>The id of the player that achieved the record</p>
|
* @param userId <p>The id of the player that achieved the record</p>
|
||||||
* @param record <p>The record achieved</p>
|
* @param record <p>The record achieved</p>
|
||||||
*/
|
*/
|
||||||
public ArenaRecord(UUID userId, K record) {
|
public ArenaRecord(@NotNull UUID userId, @NotNull RecordType record) {
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
this.record = record;
|
this.record = record;
|
||||||
}
|
}
|
||||||
@@ -31,6 +32,7 @@ public abstract class ArenaRecord<K extends Comparable<K>> implements Comparable
|
|||||||
*
|
*
|
||||||
* @return <p>The record's achiever</p>
|
* @return <p>The record's achiever</p>
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public UUID getUserId() {
|
public UUID getUserId() {
|
||||||
return userId;
|
return userId;
|
||||||
}
|
}
|
||||||
@@ -40,7 +42,8 @@ public abstract class ArenaRecord<K extends Comparable<K>> implements Comparable
|
|||||||
*
|
*
|
||||||
* @return <p>The record value</p>
|
* @return <p>The record value</p>
|
||||||
*/
|
*/
|
||||||
public K getRecord() {
|
@NotNull
|
||||||
|
public RecordType getRecord() {
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,12 +55,12 @@ public abstract class ArenaRecord<K extends Comparable<K>> implements Comparable
|
|||||||
public abstract String getAsString();
|
public abstract String getAsString();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(@Nullable Object other) {
|
||||||
return other instanceof ArenaRecord<?> && userId.equals(((ArenaRecord<?>) other).userId);
|
return other instanceof ArenaRecord<?> && userId.equals(((ArenaRecord<?>) other).userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(@NotNull ArenaRecord<K> other) {
|
public int compareTo(@NotNull ArenaRecord<RecordType> other) {
|
||||||
return record.compareTo(other.record);
|
return record.compareTo(other.record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package net.knarcraft.minigames.arena.record;
|
|||||||
|
|
||||||
import net.knarcraft.minigames.container.SerializableUUID;
|
import net.knarcraft.minigames.container.SerializableUUID;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -12,25 +13,29 @@ import java.util.UUID;
|
|||||||
public class IntegerRecord extends SummableArenaRecord<Integer> {
|
public class IntegerRecord extends SummableArenaRecord<Integer> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Instantiates a new integer record
|
||||||
|
*
|
||||||
* @param userId <p>The id of the player that achieved the record</p>
|
* @param userId <p>The id of the player that achieved the record</p>
|
||||||
* @param record <p>The record achieved</p>
|
* @param record <p>The record achieved</p>
|
||||||
*/
|
*/
|
||||||
public IntegerRecord(UUID userId, Integer record) {
|
public IntegerRecord(@NotNull UUID userId, @NotNull Integer record) {
|
||||||
super(userId, record);
|
super(userId, record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@NotNull
|
||||||
public String getAsString() {
|
public String getAsString() {
|
||||||
return String.valueOf(this.getRecord());
|
return String.valueOf(this.getRecord());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SummableArenaRecord<Integer> sum(Integer value) {
|
@NotNull
|
||||||
|
public SummableArenaRecord<Integer> sum(@NotNull Integer value) {
|
||||||
return new IntegerRecord(this.getUserId(), this.getRecord() + value);
|
return new IntegerRecord(this.getUserId(), this.getRecord() + value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(@Nullable Object other) {
|
||||||
return other instanceof IntegerRecord && this.getUserId().equals(((IntegerRecord) other).getUserId());
|
return other instanceof IntegerRecord && this.getUserId().equals(((IntegerRecord) other).getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,6 +46,7 @@ public class IntegerRecord extends SummableArenaRecord<Integer> {
|
|||||||
* @return <p>The deserialized data</p>
|
* @return <p>The deserialized data</p>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@NotNull
|
||||||
public static IntegerRecord deserialize(@NotNull Map<String, Object> data) {
|
public static IntegerRecord deserialize(@NotNull Map<String, Object> data) {
|
||||||
return new IntegerRecord(((SerializableUUID) data.get("userId")).getRawValue(), (Integer) data.get("record"));
|
return new IntegerRecord(((SerializableUUID) data.get("userId")).getRawValue(), (Integer) data.get("record"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package net.knarcraft.minigames.arena.record;
|
|||||||
|
|
||||||
import net.knarcraft.minigames.container.SerializableUUID;
|
import net.knarcraft.minigames.container.SerializableUUID;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -12,24 +13,28 @@ import java.util.UUID;
|
|||||||
public class LongRecord extends SummableArenaRecord<Long> {
|
public class LongRecord extends SummableArenaRecord<Long> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Instantiates a new long record
|
||||||
|
*
|
||||||
* @param userId <p>The id of the player that achieved the record</p>
|
* @param userId <p>The id of the player that achieved the record</p>
|
||||||
* @param record <p>The record achieved</p>
|
* @param record <p>The record achieved</p>
|
||||||
*/
|
*/
|
||||||
public LongRecord(UUID userId, Long record) {
|
public LongRecord(@NotNull UUID userId, @NotNull Long record) {
|
||||||
super(userId, record);
|
super(userId, record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(@Nullable Object other) {
|
||||||
return other instanceof LongRecord && this.getUserId().equals(((LongRecord) other).getUserId());
|
return other instanceof LongRecord && this.getUserId().equals(((LongRecord) other).getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SummableArenaRecord<Long> sum(Long value) {
|
@NotNull
|
||||||
|
public SummableArenaRecord<Long> sum(@NotNull Long value) {
|
||||||
return new LongRecord(this.getUserId(), this.getRecord() + value);
|
return new LongRecord(this.getUserId(), this.getRecord() + value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@NotNull
|
||||||
public String getAsString() {
|
public String getAsString() {
|
||||||
double seconds = getRecord() / 1000.0;
|
double seconds = getRecord() / 1000.0;
|
||||||
double minutes = 0;
|
double minutes = 0;
|
||||||
@@ -52,6 +57,7 @@ public class LongRecord extends SummableArenaRecord<Long> {
|
|||||||
* @return <p>The deserialized data</p>
|
* @return <p>The deserialized data</p>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@NotNull
|
||||||
public static LongRecord deserialize(@NotNull Map<String, Object> data) {
|
public static LongRecord deserialize(@NotNull Map<String, Object> data) {
|
||||||
return new LongRecord(((SerializableUUID) data.get("userId")).getRawValue(),
|
return new LongRecord(((SerializableUUID) data.get("userId")).getRawValue(),
|
||||||
((Number) data.get("record")).longValue());
|
((Number) data.get("record")).longValue());
|
||||||
|
|||||||
@@ -1,19 +1,21 @@
|
|||||||
package net.knarcraft.minigames.arena.record;
|
package net.knarcraft.minigames.arena.record;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A type of arena record which can be summed together
|
* A type of arena record which can be summed together
|
||||||
*
|
*
|
||||||
* @param <K> <p>The type of the stored value</p>
|
* @param <RecordType> <p>The type of the stored value</p>
|
||||||
*/
|
*/
|
||||||
public abstract class SummableArenaRecord<K extends Comparable<K>> extends ArenaRecord<K> {
|
public abstract class SummableArenaRecord<RecordType extends Comparable<RecordType>> extends ArenaRecord<RecordType> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param userId <p>The id of the player that achieved the record</p>
|
* @param userId <p>The id of the player that achieved the record</p>
|
||||||
* @param record <p>The record achieved</p>
|
* @param record <p>The record achieved</p>
|
||||||
*/
|
*/
|
||||||
public SummableArenaRecord(UUID userId, K record) {
|
public SummableArenaRecord(@NotNull UUID userId, @NotNull RecordType record) {
|
||||||
super(userId, record);
|
super(userId, record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,6 +25,7 @@ public abstract class SummableArenaRecord<K extends Comparable<K>> extends Arena
|
|||||||
* @param value <p>The value to add to the existing value</p>
|
* @param value <p>The value to add to the existing value</p>
|
||||||
* @return <p>A record with the sum of this record and the given value</p>
|
* @return <p>A record with the sum of this record and the given value</p>
|
||||||
*/
|
*/
|
||||||
public abstract SummableArenaRecord<K> sum(K value);
|
@NotNull
|
||||||
|
public abstract SummableArenaRecord<RecordType> sum(@NotNull RecordType value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ public class CommandReward implements Reward {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull FormatBuilder getGrantMessage() {
|
@NotNull
|
||||||
|
public FormatBuilder getGrantMessage() {
|
||||||
return new FormatBuilder(MiniGameMessage.SUCCESS_COMMAND_REWARDED).replace("{command}", command);
|
return new FormatBuilder(MiniGameMessage.SUCCESS_COMMAND_REWARDED).replace("{command}", command);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,6 +51,7 @@ public class CommandReward implements Reward {
|
|||||||
* @param input <p>The input containing a name placeholder</p>
|
* @param input <p>The input containing a name placeholder</p>
|
||||||
* @return <p>The input with the placeholder replaced</p>
|
* @return <p>The input with the placeholder replaced</p>
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
private String replaceNamePlaceholder(@NotNull Player player, @NotNull String input) {
|
private String replaceNamePlaceholder(@NotNull Player player, @NotNull String input) {
|
||||||
return input.replaceAll("[<%(\\[{]player[_\\-]?(name)?[>%)\\]}]", player.getName());
|
return input.replaceAll("[<%(\\[{]player[_\\-]?(name)?[>%)\\]}]", player.getName());
|
||||||
}
|
}
|
||||||
@@ -61,7 +63,8 @@ public class CommandReward implements Reward {
|
|||||||
* @return <p>The deserialized data</p>
|
* @return <p>The deserialized data</p>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public static CommandReward deserialize(Map<String, Object> data) {
|
@NotNull
|
||||||
|
public static CommandReward deserialize(@NotNull Map<String, Object> data) {
|
||||||
return new CommandReward((String) data.get("command"));
|
return new CommandReward((String) data.get("command"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ public class EconomyReward implements Reward {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull FormatBuilder getGrantMessage() {
|
@NotNull
|
||||||
|
public FormatBuilder getGrantMessage() {
|
||||||
return new FormatBuilder(MiniGameMessage.SUCCESS_ECONOMY_REWARDED).replace("{currency}",
|
return new FormatBuilder(MiniGameMessage.SUCCESS_ECONOMY_REWARDED).replace("{currency}",
|
||||||
EconomyManager.format(amount));
|
EconomyManager.format(amount));
|
||||||
}
|
}
|
||||||
@@ -59,7 +60,8 @@ public class EconomyReward implements Reward {
|
|||||||
* @return <p>The deserialized data</p>
|
* @return <p>The deserialized data</p>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public static EconomyReward deserialize(Map<String, Object> data) {
|
@NotNull
|
||||||
|
public static EconomyReward deserialize(@NotNull Map<String, Object> data) {
|
||||||
return new EconomyReward((Double) data.get("amount"));
|
return new EconomyReward((Double) data.get("amount"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ public class ItemReward implements Reward {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull FormatBuilder getGrantMessage() {
|
@NotNull
|
||||||
|
public FormatBuilder getGrantMessage() {
|
||||||
NamespacedKey key = item.getType().getKeyOrNull();
|
NamespacedKey key = item.getType().getKeyOrNull();
|
||||||
String name = key == null ? "Unnamed item" : key.getKey().replace("_", " ");
|
String name = key == null ? "Unnamed item" : key.getKey().replace("_", " ");
|
||||||
return new FormatBuilder(MiniGameMessage.SUCCESS_ITEM_REWARDED).
|
return new FormatBuilder(MiniGameMessage.SUCCESS_ITEM_REWARDED).
|
||||||
@@ -65,7 +66,8 @@ public class ItemReward implements Reward {
|
|||||||
* @return <p>The deserialized data</p>
|
* @return <p>The deserialized data</p>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public static ItemReward deserialize(Map<String, Object> data) {
|
@NotNull
|
||||||
|
public static ItemReward deserialize(@NotNull Map<String, Object> data) {
|
||||||
return new ItemReward((ItemStack) data.get("item"));
|
return new ItemReward((ItemStack) data.get("item"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +77,7 @@ public class ItemReward implements Reward {
|
|||||||
* @param inventory <p>The inventory to check</p>
|
* @param inventory <p>The inventory to check</p>
|
||||||
* @return <p>True if the inventory can fit the item</p>
|
* @return <p>True if the inventory can fit the item</p>
|
||||||
*/
|
*/
|
||||||
private boolean canFitItem(Inventory inventory) {
|
private boolean canFitItem(@NotNull Inventory inventory) {
|
||||||
// If a slot is available, there is no problem
|
// If a slot is available, there is no problem
|
||||||
if (inventory.firstEmpty() != -1) {
|
if (inventory.firstEmpty() != -1) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ public class PermissionReward implements Reward {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull FormatBuilder getGrantMessage() {
|
@NotNull
|
||||||
|
public FormatBuilder getGrantMessage() {
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
return new FormatBuilder(MiniGameMessage.SUCCESS_PERMISSION_REWARDED).replace("{permission}",
|
return new FormatBuilder(MiniGameMessage.SUCCESS_PERMISSION_REWARDED).replace("{permission}",
|
||||||
permission);
|
permission);
|
||||||
@@ -76,7 +77,8 @@ public class PermissionReward implements Reward {
|
|||||||
* @return <p>The deserialized data</p>
|
* @return <p>The deserialized data</p>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public static PermissionReward deserialize(Map<String, Object> data) {
|
@NotNull
|
||||||
|
public static PermissionReward deserialize(@NotNull Map<String, Object> data) {
|
||||||
World world = (World) data.getOrDefault("world", null);
|
World world = (World) data.getOrDefault("world", null);
|
||||||
String permission = (String) data.get("permission");
|
String permission = (String) data.get("permission");
|
||||||
return new PermissionReward(world, permission);
|
return new PermissionReward(world, permission);
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ public enum RewardCondition implements ConfigurationSerializable {
|
|||||||
* @param condition <p>The string specifying a reward condition</p>
|
* @param condition <p>The string specifying a reward condition</p>
|
||||||
* @return <p>The matching reward condition, or null if not found</p>
|
* @return <p>The matching reward condition, or null if not found</p>
|
||||||
*/
|
*/
|
||||||
public static @Nullable RewardCondition getFromString(@NotNull String condition) {
|
@Nullable
|
||||||
|
public static RewardCondition getFromString(@NotNull String condition) {
|
||||||
for (RewardCondition rewardCondition : RewardCondition.values()) {
|
for (RewardCondition rewardCondition : RewardCondition.values()) {
|
||||||
if (rewardCondition.name().equalsIgnoreCase(condition.replace("-", "_"))) {
|
if (rewardCondition.name().equalsIgnoreCase(condition.replace("-", "_"))) {
|
||||||
return rewardCondition;
|
return rewardCondition;
|
||||||
@@ -75,7 +76,8 @@ public enum RewardCondition implements ConfigurationSerializable {
|
|||||||
* @return <p>The deserialized reward condition</p>
|
* @return <p>The deserialized reward condition</p>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unused"})
|
@SuppressWarnings({"unused"})
|
||||||
public static @NotNull RewardCondition deserialize(@NotNull Map<String, Object> data) {
|
@NotNull
|
||||||
|
public static RewardCondition deserialize(@NotNull Map<String, Object> data) {
|
||||||
RewardCondition rewardCondition = getFromString(String.valueOf(data.get("condition")));
|
RewardCondition rewardCondition = getFromString(String.valueOf(data.get("condition")));
|
||||||
return Objects.requireNonNullElse(rewardCondition, RewardCondition.FIRST_WIN);
|
return Objects.requireNonNullElse(rewardCondition, RewardCondition.FIRST_WIN);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.knarcraft.minigames.arena.reward;
|
package net.knarcraft.minigames.arena.reward;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of a specific reward
|
* The type of a specific reward
|
||||||
@@ -34,6 +35,7 @@ public enum RewardType {
|
|||||||
* @param condition <p>The string specifying a reward type</p>
|
* @param condition <p>The string specifying a reward type</p>
|
||||||
* @return <p>The matching reward type, or null if not found</p>
|
* @return <p>The matching reward type, or null if not found</p>
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public static RewardType getFromString(@NotNull String condition) {
|
public static RewardType getFromString(@NotNull String condition) {
|
||||||
for (RewardType rewardType : RewardType.values()) {
|
for (RewardType rewardType : RewardType.values()) {
|
||||||
if (rewardType.name().equalsIgnoreCase(condition.replace("-", "_"))) {
|
if (rewardType.name().equalsIgnoreCase(condition.replace("-", "_"))) {
|
||||||
|
|||||||
Reference in New Issue
Block a user