Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add favorite filter [skip ci] (#2376)
* feat: Add favorite filter * fix: Fix revealed favorite items not rendering star * ci: spotless formatting --------- Co-authored-by: JamieCallan117 <JamieCallan117@users.noreply.github.com>
- Loading branch information
1 parent
2929a43
commit 2f55163
Showing
8 changed files
with
107 additions
and
8 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
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
common/src/main/java/com/wynntils/services/itemfilter/filters/BooleanStatFilter.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 @@ | ||
/* | ||
* Copyright © Wynntils 2024. | ||
* This file is released under LGPLv3. See LICENSE for full license details. | ||
*/ | ||
package com.wynntils.services.itemfilter.filters; | ||
|
||
import com.wynntils.services.itemfilter.type.StatFilter; | ||
import com.wynntils.services.itemfilter.type.StatFilterFactory; | ||
import java.util.Optional; | ||
|
||
public class BooleanStatFilter extends StatFilter<Boolean> { | ||
private final boolean value; | ||
|
||
BooleanStatFilter(boolean value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public boolean matches(Boolean value) { | ||
return this.value == value; | ||
} | ||
|
||
public static class BooleanStatFilterFactory extends StatFilterFactory<BooleanStatFilter> { | ||
@Override | ||
public Optional<BooleanStatFilter> create(String inputString) { | ||
if (inputString.equalsIgnoreCase("true")) { | ||
return Optional.of(new BooleanStatFilter(true)); | ||
} else if (inputString.equalsIgnoreCase("false")) { | ||
return Optional.of(new BooleanStatFilter(false)); | ||
} else { | ||
return Optional.empty(); | ||
} | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...on/src/main/java/com/wynntils/services/itemfilter/statproviders/FavoriteStatProvider.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,27 @@ | ||
/* | ||
* Copyright © Wynntils 2024. | ||
* This file is released under LGPLv3. See LICENSE for full license details. | ||
*/ | ||
package com.wynntils.services.itemfilter.statproviders; | ||
|
||
import com.wynntils.core.components.Services; | ||
import com.wynntils.models.items.WynnItem; | ||
import com.wynntils.models.items.properties.NamedItemProperty; | ||
import com.wynntils.services.itemfilter.type.ItemStatProvider; | ||
import java.util.List; | ||
|
||
public class FavoriteStatProvider extends ItemStatProvider<Boolean> { | ||
@Override | ||
public List<Boolean> getValue(WynnItem wynnItem) { | ||
if (wynnItem instanceof NamedItemProperty namedItem) { | ||
return List.of(Services.Favorites.isFavorite(namedItem.getName())); | ||
} | ||
|
||
return List.of(false); | ||
} | ||
|
||
@Override | ||
public List<String> getAliases() { | ||
return List.of("fav"); | ||
} | ||
} |
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