Skip to content

Commit a9bc49f

Browse files
authored
Merge pull request #565 from ItzKatze/master
fix: dupe bug with enchant/reforge gui
2 parents 21421f7 + 97d1653 commit a9bc49f

13 files changed

Lines changed: 211 additions & 27 deletions

File tree

configuration/skyblock/collections/combat.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,9 @@ collections:
332332
- type: XP
333333
data:
334334
xp: 4
335+
- type: CUSTOM_AWARD
336+
data:
337+
customAward: GIANT_KILLER_DISCOUNT
335338
- amount: 1000
336339
rewards:
337340
- type: XP
@@ -669,6 +672,9 @@ collections:
669672
- type: XP
670673
data:
671674
xp: 4
675+
- type: CUSTOM_AWARD
676+
data:
677+
customAward: BANE_OF_ARTHROPODS_DISCOUNT
672678
- amount: 5000
673679
rewards:
674680
- type: XP

configuration/skyblock/collections/farming.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,9 @@ collections:
10441044
- type: XP
10451045
data:
10461046
xp: 4
1047+
- type: CUSTOM_AWARD
1048+
data:
1049+
customAward: CUBISM_DISCOUNT
10471050
- amount: 2500
10481051
rewards:
10491052
- type: XP

configuration/skyblock/collections/fishing.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,9 @@ collections:
314314
- type: XP
315315
data:
316316
xp: 4
317+
- type: CUSTOM_AWARD
318+
data:
319+
customAward: IMPALING_DISCOUNT
317320
- amount: 25
318321
rewards:
319322
- type: XP

configuration/skyblock/collections/mining.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,14 @@ collections:
350350
- type: XP
351351
data:
352352
xp: 4
353+
- type: CUSTOM_AWARD
354+
data:
355+
customAward: FORTUNE_DISCOUNT
356+
- amount: 500000
357+
rewards:
358+
- type: XP
359+
data:
360+
xp: 4
353361
- itemType: LAPIS_LAZULI
354362
rewards:
355363
- amount: 250
@@ -497,6 +505,9 @@ collections:
497505
- type: XP
498506
data:
499507
xp: 4
508+
- type: CUSTOM_AWARD
509+
data:
510+
customAward: EXECUTE_DISCOUNT
500511
- amount: 250
501512
rewards:
502513
- type: XP
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
items:
2+
- id: BOOKSHELF
3+
material: BOOKSHELF
4+
rarity: COMMON
5+
components:
6+
- id: CUSTOM_DROP
7+
rules:
8+
- conditions:
9+
silk_touch: true
10+
drops:
11+
- item: BOOKSHELF
12+
chance: 1.0
13+
amount: 1
14+
- conditions:
15+
drops:
16+
- item: BOOK
17+
chance: 1.0
18+
amount: 3
19+
- id: PLACEABLE
20+
- id: SELLABLE
21+
value: 20
22+
- id: DEFAULT_CRAFTABLE
23+
recipes:
24+
- type: SHAPED
25+
recipe-type: NONE
26+
pattern:
27+
- AAA
28+
- BBB
29+
- AAA
30+
ingredients:
31+
A:
32+
type: OAK_PLANKS
33+
amount: 1
34+
B:
35+
type: BOOK
36+
amount: 1
37+
result:
38+
type: BOOKSHELF
39+
amount: 1

type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/collection/CustomCollectionAward.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public enum CustomCollectionAward {
2626
IMPALING_DISCOUNT("§9Impaling §7Exp Discount §a(-25%)"),
2727
BANE_OF_ARTHROPODS_DISCOUNT("§9Bane of Arthropods §7Exp Discount §a(-25%)"),
2828
CUBISM_DISCOUNT("§9Cubism §7Exp Discount §a(-25%)"),
29+
FORTUNE_DISCOUNT("§9Fortune §7Exp Discount §a(-25%)"),
2930

3031
// BAGS
3132
QUIVER("§aQuiver"),

type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/enchantment/EnchantmentType.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,15 @@ public enum EnchantmentType {
3131
IMPALING(EnchantmentImpaling.class),
3232
BANE_OF_ARTHROPODS(EnchantmentBaneOfArthropods.class),
3333
CUBISM(EnchantmentCubism.class),
34+
FORTUNE(EnchantmentFortune.class),
3435
;
3536

3637
private final Class<? extends Ench> clazz;
37-
private final List<EnchantmentType> conflicts;
38-
3938
private final Ench ench;
4039

4140
@SneakyThrows
42-
EnchantmentType(Class<? extends Ench> ench, EnchantmentType... conflicts) {
41+
EnchantmentType(Class<? extends Ench> ench) {
4342
this.clazz = ench;
44-
this.conflicts = List.of(conflicts);
4543

4644
this.ench = ench.getConstructor().newInstance();
4745
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package net.swofty.type.skyblockgeneric.enchantment.abstr;
2+
3+
import net.swofty.type.skyblockgeneric.enchantment.EnchantmentType;
4+
5+
import java.util.List;
6+
7+
public interface ConflictingEnch {
8+
List<EnchantmentType> getConflictingEnchantments();
9+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package net.swofty.type.skyblockgeneric.enchantment.impl;
2+
3+
import net.swofty.commons.statistics.ItemStatistic;
4+
import net.swofty.commons.statistics.ItemStatistics;
5+
import net.swofty.type.skyblockgeneric.collection.CustomCollectionAward;
6+
import net.swofty.type.skyblockgeneric.enchantment.EnchantmentType;
7+
import net.swofty.type.skyblockgeneric.enchantment.abstr.ConflictingEnch;
8+
import net.swofty.type.skyblockgeneric.enchantment.abstr.Ench;
9+
import net.swofty.type.skyblockgeneric.enchantment.abstr.EnchFromTable;
10+
import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer;
11+
import net.swofty.type.skyblockgeneric.utility.groups.EnchantItemGroups;
12+
import org.jetbrains.annotations.NotNull;
13+
14+
import java.util.HashMap;
15+
import java.util.List;
16+
import java.util.Map;
17+
18+
public class EnchantmentFortune implements Ench, EnchFromTable, ConflictingEnch {
19+
20+
public static final int[] MINING_FORTUNE_BONUS = new int[]{10, 20, 30, 45};
21+
22+
@Override
23+
public String getDescription(int level) {
24+
return "Grants §a+" + MINING_FORTUNE_BONUS[level - 1] + " " + ItemStatistic.MINING_FORTUNE.getDisplayName() +
25+
"§7, which increases your chance for multiple drops.";
26+
}
27+
28+
@Override
29+
public ApplyLevels getLevelsToApply(@NotNull SkyBlockPlayer player) {
30+
HashMap<Integer, Integer> levels = new HashMap<>(Map.of(
31+
4, 0
32+
));
33+
34+
if (player.hasCustomCollectionAward(CustomCollectionAward.FORTUNE_DISCOUNT)) {
35+
levels.replaceAll((k, v) -> (int) (v * 0.75));
36+
}
37+
38+
return new ApplyLevels(levels);
39+
}
40+
41+
@Override
42+
public List<EnchantItemGroups> getGroups() {
43+
return List.of(EnchantItemGroups.GAUNTLET, EnchantItemGroups.PICKAXE, EnchantItemGroups.DRILL);
44+
}
45+
46+
@Override
47+
public ItemStatistics getStatistics(int level) {
48+
return ItemStatistics.builder()
49+
.withBase(ItemStatistic.MINING_FORTUNE, (double) MINING_FORTUNE_BONUS[level - 1])
50+
.build();
51+
}
52+
53+
@Override
54+
public TableLevels getLevelsFromTableToApply(@NotNull SkyBlockPlayer player) {
55+
HashMap<Integer, Integer> levels = new HashMap<>(Map.of(
56+
1, 15,
57+
2, 30,
58+
3, 45
59+
));
60+
61+
if (player.hasCustomCollectionAward(CustomCollectionAward.FORTUNE_DISCOUNT)) {
62+
levels.replaceAll((k, v) -> (int) (v * 0.75));
63+
}
64+
65+
return new TableLevels(levels);
66+
}
67+
68+
@Override
69+
public int getRequiredBookshelfPower() {
70+
return 0;
71+
}
72+
73+
@Override
74+
public List<EnchantmentType> getConflictingEnchantments() {
75+
return List.of(EnchantmentType.SILK_TOUCH);
76+
}
77+
}

type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/enchantment/impl/EnchantmentSilkTouch.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package net.swofty.type.skyblockgeneric.enchantment.impl;
22

33
import lombok.NonNull;
4+
import net.swofty.type.skyblockgeneric.enchantment.EnchantmentType;
5+
import net.swofty.type.skyblockgeneric.enchantment.abstr.ConflictingEnch;
46
import net.swofty.type.skyblockgeneric.enchantment.abstr.Ench;
57
import net.swofty.type.skyblockgeneric.enchantment.abstr.EnchFromTable;
68
import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer;
@@ -10,7 +12,7 @@
1012
import java.util.List;
1113
import java.util.Map;
1214

13-
public class EnchantmentSilkTouch implements Ench, EnchFromTable {
15+
public class EnchantmentSilkTouch implements Ench, EnchFromTable, ConflictingEnch {
1416

1517
@Override
1618
public String getDescription(int level) {
@@ -45,4 +47,9 @@ public TableLevels getLevelsFromTableToApply(@NonNull SkyBlockPlayer player) {
4547
public int getRequiredBookshelfPower() {
4648
return 5;
4749
}
50+
51+
@Override
52+
public List<EnchantmentType> getConflictingEnchantments() {
53+
return List.of(EnchantmentType.SMELTING_TOUCH, EnchantmentType.FORTUNE);
54+
}
4855
}

0 commit comments

Comments
 (0)