-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement customizable rarities, no longer hardcoded
- Loading branch information
1 parent
bf9e575
commit 45ce71a
Showing
6 changed files
with
94 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,41 @@ | ||
package com.ilm9001.cosmetics.rarity; | ||
|
||
import com.ilm9001.cosmetics.Cosmetics; | ||
import com.ilm9001.cosmetics.util.Cosmetic; | ||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.format.TextColor; | ||
import net.kyori.adventure.text.format.TextDecoration; | ||
import org.bukkit.configuration.file.FileConfiguration; | ||
|
||
public enum Rarities { | ||
COMMON (new Rarity("COMMON", Component.text("\uF80A") | ||
.decoration(TextDecoration.ITALIC,false) | ||
.color(TextColor.color(255,255,255)), TextColor.color(0x9c9c9f))), | ||
UNCOMMON (new Rarity("UNCOMMON", Component.text("\uF80B") | ||
.decoration(TextDecoration.ITALIC,false) | ||
.color(TextColor.color(255,255,255)),TextColor.color(0x71cc1b))), | ||
RARE (new Rarity("RARE", Component.text("\uF80C") | ||
.decoration(TextDecoration.ITALIC,false) | ||
.color(TextColor.color(255,255,255)),TextColor.color(0x2bd0f2))), | ||
EPIC (new Rarity("EPIC", Component.text("\uF80D") | ||
.decoration(TextDecoration.ITALIC,false) | ||
.color(TextColor.color(255,255,255)),TextColor.color(0x6060FF))), | ||
LEGENDARY (new Rarity("LEGENDARY", Component.text("\uF80E") | ||
.decoration(TextDecoration.ITALIC,false) | ||
.color(TextColor.color(255,255,255)),TextColor.color(0xffb920))); | ||
|
||
private final Rarity rarity; | ||
|
||
Rarities(Rarity rarity) { | ||
this.rarity = rarity; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class Rarities { | ||
private static final List<Rarity> rarities = new ArrayList<>(); | ||
|
||
public static void setRaritiesFromFile() { | ||
List<Cosmetic> cosmeticsList = new ArrayList<>(); | ||
Cosmetics.refreshFiles(); | ||
FileConfiguration config = Cosmetics.getRarities(); | ||
|
||
for (String internalname : config.getConfigurationSection("Rarities").getKeys(false)) { | ||
Component displayName; | ||
TextColor color; | ||
Map<String,Object> valuesmap = config.getConfigurationSection("Cosmetics."+internalname).getValues(false);; | ||
List<Number> colorList; | ||
if(valuesmap.get("color") instanceof List && valuesmap.get("color") != null) { | ||
colorList = (List<Number>) valuesmap.get("color");; | ||
} else throw new IllegalArgumentException("Color list is not a list, or is null"); | ||
|
||
displayName = Component.text((String) valuesmap.get("display")); | ||
color = TextColor.color(colorList.get(0).intValue(), colorList.get(1).intValue(), colorList.get(2).intValue()); | ||
|
||
Rarity rarity = new Rarity(internalname, displayName, color); | ||
rarities.add(rarity); | ||
} | ||
} | ||
|
||
public Rarity getRarity() { | ||
return rarity; | ||
public static List<Rarity> getRarities() { | ||
return rarities; | ||
} | ||
} |
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,16 @@ | ||
Rarities: | ||
COMMON: # Internally used name, something you can recognize across plugins, something like "COMMON, UNCOMMON, RARE, EPIC, LEGENDARY" | ||
display: "\uF80A" # String to display as lore. You may use custom fonts as long as you format the unicode character correctly (such as "\uF80A") May be empty to not display rarity. | ||
color: [156,156,156] # Color of the rarity. RGB 0-255. | ||
UNCOMMON: | ||
display: "\uF80B" | ||
color: [ 113,204,27 ] | ||
RARE: | ||
display: "\uF80C" | ||
color: [ 43,208,242 ] | ||
EPIC: | ||
display: "\uF80D" | ||
color: [ 96,96,255 ] | ||
LEGENDARY: | ||
display: "\uF80E" | ||
color: [ 255,185,32 ] |