-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
98 additions
and
46 deletions.
There are no files selected for viewing
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
13 changes: 13 additions & 0 deletions
13
doublejump-api/src/main/java/com/github/imdmk/doublejump/restriction/JumpRestriction.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 com.github.imdmk.doublejump.restriction; | ||
|
||
import java.util.List; | ||
|
||
public record JumpRestriction(JumpRestrictionType type, List<String> list) { | ||
|
||
public boolean isAllowed(String value) { | ||
return switch (this.type) { | ||
case BLACKLIST -> !this.list.contains(value); | ||
case WHITELIST -> this.list.contains(value); | ||
}; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...lejump-api/src/main/java/com/github/imdmk/doublejump/restriction/JumpRestrictionType.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,5 @@ | ||
package com.github.imdmk.doublejump.restriction; | ||
|
||
public enum JumpRestrictionType { | ||
WHITELIST, BLACKLIST | ||
} |
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
35 changes: 35 additions & 0 deletions
35
...src/main/java/com/github/imdmk/doublejump/jump/restriction/JumpRestrictionSerializer.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,35 @@ | ||
package com.github.imdmk.doublejump.jump.restriction; | ||
|
||
import com.github.imdmk.doublejump.restriction.JumpRestriction; | ||
import com.github.imdmk.doublejump.restriction.JumpRestrictionType; | ||
import eu.okaeri.configs.schema.GenericsDeclaration; | ||
import eu.okaeri.configs.serdes.DeserializationData; | ||
import eu.okaeri.configs.serdes.ObjectSerializer; | ||
import eu.okaeri.configs.serdes.SerializationData; | ||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
|
||
import java.util.List; | ||
|
||
public class JumpRestrictionSerializer implements ObjectSerializer<JumpRestriction> { | ||
|
||
@Override | ||
public boolean supports(@NonNull Class<? super JumpRestriction> type) { | ||
return JumpRestriction.class.isAssignableFrom(type); | ||
} | ||
|
||
@Override | ||
public void serialize(@NonNull JumpRestriction jumpRestriction, @NonNull SerializationData data, @NonNull GenericsDeclaration generics) { | ||
data.add("type", jumpRestriction.type(), JumpRestrictionType.class); | ||
data.addCollection("list", jumpRestriction.list(), String.class); | ||
} | ||
|
||
@Override | ||
public JumpRestriction deserialize(@NonNull DeserializationData data, @NonNull GenericsDeclaration generics) { | ||
JumpRestrictionType type = data.get("type", JumpRestrictionType.class); | ||
List<String> list = data.getAsList("list", String.class); | ||
|
||
return new JumpRestriction(type, list); | ||
} | ||
} | ||
|
||
|
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