-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Event levels and new icons (2.207)
- Loading branch information
Showing
24 changed files
with
538 additions
and
32 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
200001|10|SXDEsWE8DW2YPCAMLBgAPCwoCDwoLAB4BCR0OHgQVAAseBA==|2add3c41e4f44884d7200dd98c57feb1b07296df |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
common/src/main/java/jdash/common/SecretRewardChkGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package jdash.common; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import static jdash.common.RobTopsWeakEncryption.CHK_REWARDS_XOR_CIPHER; | ||
import static jdash.common.RobTopsWeakEncryption.encode; | ||
|
||
/** | ||
* Function that generates a client CHK for secret rewards. Use {@link #random()} or {@link #fixed(String, String)} to | ||
* customize | ||
* CHK generation behavior. | ||
*/ | ||
@FunctionalInterface | ||
public interface SecretRewardChkGenerator extends Supplier<String> { | ||
|
||
/** | ||
* Function that generates a CHK at random, using a key representing a random number between 100_000 (inclusive) and | ||
* 900_000 (exclusive). | ||
* | ||
* @return a random {@link SecretRewardChkGenerator} | ||
*/ | ||
static SecretRewardChkGenerator random() { | ||
return RobTopsWeakEncryption::generateSecretRewardChk; | ||
} | ||
|
||
/** | ||
* Function that generates a CHK with a fixed input. Use this when you need deterministic behavior. | ||
* | ||
* @param prefix a string that will be prepended to the CHK. Only the first 5 characters are taken, and will be | ||
* padded with 'X' if provided prefix is less than 5 characters. | ||
* @param key the key encoded in the CHK. It is recommended to be 6 characters or highers for the server to | ||
* accept it. | ||
* @return a {@link SecretRewardChkGenerator} with fixed input | ||
*/ | ||
static SecretRewardChkGenerator fixed(String prefix, String key) { | ||
return () -> String.format("%5s", prefix.substring(0, 5)).replace(' ', 'X') + | ||
encode(key, CHK_REWARDS_XOR_CIPHER); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
common/src/test/java/jdash/common/SecretRewardChkGeneratorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package jdash.common; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public final class SecretRewardChkGeneratorTest { | ||
|
||
@Test | ||
public void testFixedChkGenerator() { | ||
assertEquals("ALEX1BAsCDAcD", SecretRewardChkGenerator.fixed("ALEX1", "123456").get()); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
events/src/main/java/jdash/events/object/EventLevelChange.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package jdash.events.object; | ||
|
||
import jdash.common.entity.GDDailyInfo; | ||
|
||
/** | ||
* Event emitted when the Event level changes. | ||
* | ||
* @param before The Event level info before the change. | ||
* @param after The Event level info after the change. | ||
*/ | ||
public record EventLevelChange(GDDailyInfo before, GDDailyInfo after) {} |
25 changes: 25 additions & 0 deletions
25
events/src/main/java/jdash/events/producer/EventLevelProducer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package jdash.events.producer; | ||
|
||
import jdash.client.GDClient; | ||
import jdash.common.entity.GDDailyInfo; | ||
import jdash.events.object.EventLevelChange; | ||
import reactor.core.publisher.Flux; | ||
import reactor.core.publisher.Mono; | ||
|
||
class EventLevelProducer implements GDEventProducer { | ||
|
||
private GDDailyInfo previousEventLevel; | ||
|
||
@Override | ||
public Flux<Object> produce(GDClient client) { | ||
return client.getEventLevelInfo() | ||
.flatMapMany(info -> { | ||
final var previousEventLevel = this.previousEventLevel; | ||
this.previousEventLevel = info; | ||
return Mono.justOrEmpty(previousEventLevel) | ||
.filter(p -> p.number() < info.number()) | ||
.map(p -> new EventLevelChange(p, info)); | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.