-
-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only update menu files with specifically added keys
- Loading branch information
Showing
4 changed files
with
375 additions
and
198 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
52 changes: 52 additions & 0 deletions
52
bukkit/src/main/java/dev/aurelium/auraskills/bukkit/menus/MenuFileUpdates.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,52 @@ | ||
package dev.aurelium.auraskills.bukkit.menus; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public enum MenuFileUpdates { | ||
|
||
SKILLS_1("skills", 1, Map.of( | ||
"components", List.of("skill_job_active"))), | ||
LEVEL_PROGRESSION_1("level_progression", 1, Map.of( | ||
"items", List.of("job"), | ||
"components", List.of("job_select", "job_active", "job_limit"))); | ||
|
||
private final String menu; | ||
private final int version; | ||
private final Map<String, List<String>> addedKeys; | ||
|
||
MenuFileUpdates(String menu, int version, Map<String, List<String>> addedKeys) { | ||
this.menu = menu; | ||
this.version = version; | ||
this.addedKeys = addedKeys; | ||
} | ||
|
||
public String getMenu() { | ||
return menu; | ||
} | ||
|
||
public int getVersion() { | ||
return version; | ||
} | ||
|
||
public Map<String, List<String>> getAddedKeys() { | ||
return addedKeys; | ||
} | ||
|
||
public static List<MenuFileUpdates> getUpdates(String menu, int currentVersion, int updatedVersion) { | ||
List<MenuFileUpdates> updates = new ArrayList<>(); | ||
for (MenuFileUpdates update : MenuFileUpdates.values()) { | ||
if (!update.getMenu().equals(menu)) continue; | ||
|
||
if (update.getVersion() > currentVersion && update.getVersion() <= updatedVersion) { | ||
updates.add(update); | ||
} | ||
} | ||
// Sort by increasing version | ||
updates.sort(Comparator.comparingInt(MenuFileUpdates::getVersion)); | ||
return updates; | ||
} | ||
|
||
} |
Oops, something went wrong.