Skip to content

Commit

Permalink
Added enchanted to selected and added fixed slots spam in YAML.
Browse files Browse the repository at this point in the history
  • Loading branch information
IamTheDefender committed Mar 15, 2023
1 parent 9410c83 commit 6169278
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public static void saveIfNotFound(ConfigType configType, String path ,Object dat

public static void addSlotsList(){
for (CosmeticsType cosmeticsType : CosmeticsType.values()){
cosmeticsType.getConfig().getYml().addDefault("slots", Arrays.asList(10,11,12,13,14,15,16,19,20,21,22,23,24,25,28,29,30,31,32,33,34));
cosmeticsType.getConfig().getYml().addDefault("slots", Arrays.asList(10,11,12,13,14,15,16,19,20,21,22,23,24,25,28,29,30,31,32,33,34).toString());

cosmeticsType.getConfig().save();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public static void loadCosmetics(){
new pigmissile().register();
new squidmissile().register();
new theif().register();
new tornado().register();
new eggexplosion().register();

//Items From Config
new DeathCryItems().registerConfigItems();
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/me/defender/cosmetics/menu/CategoryMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ public CategoryMenu(CosmeticsType type) {
this.config = type.getConfig();
this.cosmeticsType = type;
title = type.getFormatedName();
slots = config.getYml().getIntegerList("slots");
String list = config.getString("slots");
list = list.replace("[", "").replace("]", "");
List<Integer> integerList = new ArrayList<>();
for (String s : list.split("\\s*,\\s*")) {
integerList.add(Integer.parseInt(s));
}
slots = integerList;
if(slots.isEmpty()){
slots = Arrays.asList(10,11,12,13,14,15,16,19,20,21,22,23,24,25,28,29,30,31,32,33,34);
}
Expand Down Expand Up @@ -84,7 +90,7 @@ public void onOpen(@NotNull Player player) {
if(returnValue == 2){
colorCode = "&c";
}
if(returnValue == 0){
if(returnValue == -2 ){ // <- Selected
stack.addUnsafeEnchantment(Enchantment.LUCK, 1);
}
item = new ClickableItem(HCore.itemBuilder(stack).addItemFlags(ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_ATTRIBUTES).name(true, colorCode + formattedName).lores(true, lore1).build(), (e) -> {
Expand Down Expand Up @@ -262,7 +268,7 @@ public int onClick(Player p, CosmeticsType type, int price, String id, boolean i
p.playSound(p.getLocation(), XSound.ENTITY_ENDERMAN_TELEPORT.parseSound(), 1.0f, 1.0f);
}
}
return -1;
return -2;
}

public void previewClick(Player player, CosmeticsType type, String id, int price){
Expand Down

0 comments on commit 6169278

Please sign in to comment.