Skip to content

Commit e0e89ff

Browse files
committed
7.19.15
1 parent 4f7b63e commit e0e89ff

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group = "com.github.angeschossen"
2-
version = "7.19.1"
2+
version = "7.19.15"
33
description = "LandsAPI"
44

55
plugins {

src/main/java/me/angeschossen/lands/api/levels/requirement/Requirement.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public Requirement(@NotNull Plugin plugin, @NotNull String name, @NotNull String
5151

5252
/**
5353
* Get the plugin that provides this requirement.
54+
*
5455
* @return plugin that provides this requirement
5556
*/
5657
@Override
@@ -60,6 +61,7 @@ public Requirement(@NotNull Plugin plugin, @NotNull String name, @NotNull String
6061

6162
/**
6263
* Get the required value.
64+
*
6365
* @return example: 4 hoppers placed
6466
*/
6567
@Override
@@ -69,6 +71,7 @@ public final float getRequired() {
6971

7072
/**
7173
* Get the progress percentage.
74+
*
7275
* @param memberHolder land or nation
7376
* @return example: 50 because 2/4 required hoppers placed
7477
*/
@@ -80,6 +83,7 @@ public String getProgressDisplay(@NotNull MemberHolder memberHolder) {
8083

8184
/**
8285
* Get the progress in a numerical value.
86+
*
8387
* @param memberHolder land or nation
8488
* @return numerical progress
8589
*/
@@ -88,8 +92,17 @@ public final float getProgress(@NotNull MemberHolder memberHolder) {
8892
return (getValue(memberHolder) / required) * 100;
8993
}
9094

95+
public final boolean shouldRecalculateLevel(float previousValue, float currentValue) {
96+
if (previousValue < required) {
97+
return currentValue >= required;
98+
} else {
99+
return currentValue < required;
100+
}
101+
}
102+
91103
/**
92104
* Check if this land or nation already fullfills this requirement.
105+
*
93106
* @param memberHolder land or nation
94107
* @return true, if the land or nation already fullfills this requirement
95108
*/
@@ -100,6 +113,7 @@ public boolean matches(@NotNull MemberHolder memberHolder) {
100113

101114
/**
102115
* Get the description of this requirement.
116+
*
103117
* @return used for menus
104118
*/
105119
@Override
@@ -109,6 +123,7 @@ public boolean matches(@NotNull MemberHolder memberHolder) {
109123

110124
/**
111125
* Get the unique name of this requirement. For display name, use {@link #getTitle()} instead.
126+
*
112127
* @return unique name
113128
*/
114129
@Override
@@ -119,6 +134,7 @@ public final String getName() {
119134

120135
/**
121136
* Get the title of this requirement.
137+
*
122138
* @return might include parsed color
123139
*/
124140
@Override

src/main/java/me/angeschossen/lands/api/memberholder/MemberHolder.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,13 +391,14 @@ public interface MemberHolder extends BalanceHolder, ExpressionEntity, CMDTarget
391391
/**
392392
* Update the progress of a cached level requirement.
393393
*
394-
* @param requirement The identification of the requirement
395-
* @param modify Can be negative
396-
* @param allowNegative Allow the result to be negative?
394+
* @param requirement the identification of the requirement
395+
* @param modify can be negative
396+
* @param allowNegative allow the result to be negative?
397+
* @param levelRecalculation should the level be recalculated, if the requirement is met or no longer met
397398
* @return The result / progress value
398399
*/
399400
@NotNull
400-
CompletableFuture<@Nullable Float> modifyRequirementCache(@NotNull String requirement, float modify, boolean allowNegative);
401+
CompletableFuture<@Nullable Float> modifyRequirementCache(@NotNull String requirement, float modify, boolean allowNegative, boolean levelRecalculation);
401402

402403
/**
403404
* Remove an inbox message from the inbox.
@@ -448,6 +449,5 @@ public interface MemberHolder extends BalanceHolder, ExpressionEntity, CMDTarget
448449
* @param levelCalc If the level should be recalculated after updating this requirement
449450
* @throws IllegalArgumentException If this requirement doesn't exist
450451
*/
451-
@Deprecated
452452
void updateRequirementCache(@NotNull String requirement, float val, boolean levelCalc) throws IllegalArgumentException;
453453
}

0 commit comments

Comments
 (0)