Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions configuration/skyblock/collections/combat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ collections:
- type: XP
data:
xp: 4
- type: CUSTOM_AWARD
data:
customAward: GIANT_KILLER_DISCOUNT
- amount: 1000
rewards:
- type: XP
Expand Down Expand Up @@ -669,6 +672,9 @@ collections:
- type: XP
data:
xp: 4
- type: CUSTOM_AWARD
data:
customAward: BANE_OF_ARTHROPODS_DISCOUNT
- amount: 5000
rewards:
- type: XP
Expand Down
3 changes: 3 additions & 0 deletions configuration/skyblock/collections/farming.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,9 @@ collections:
- type: XP
data:
xp: 4
- type: CUSTOM_AWARD
data:
customAward: CUBISM_DISCOUNT
- amount: 2500
rewards:
- type: XP
Expand Down
3 changes: 3 additions & 0 deletions configuration/skyblock/collections/fishing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ collections:
- type: XP
data:
xp: 4
- type: CUSTOM_AWARD
data:
customAward: IMPALING_DISCOUNT
- amount: 25
rewards:
- type: XP
Expand Down
11 changes: 11 additions & 0 deletions configuration/skyblock/collections/mining.yml
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,14 @@ collections:
- type: XP
data:
xp: 4
- type: CUSTOM_AWARD
data:
customAward: FORTUNE_DISCOUNT
- amount: 500000
rewards:
- type: XP
data:
xp: 4
- itemType: LAPIS_LAZULI
rewards:
- amount: 250
Expand Down Expand Up @@ -497,6 +505,9 @@ collections:
- type: XP
data:
xp: 4
- type: CUSTOM_AWARD
data:
customAward: EXECUTE_DISCOUNT
- amount: 250
rewards:
- type: XP
Expand Down
39 changes: 39 additions & 0 deletions configuration/skyblock/items/vanilla/blocks/others.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
items:
- id: BOOKSHELF
material: BOOKSHELF
rarity: COMMON
components:
- id: CUSTOM_DROP
rules:
- conditions:
silk_touch: true
drops:
- item: BOOKSHELF
chance: 1.0
amount: 1
- conditions:
drops:
- item: BOOK
chance: 1.0
amount: 3
- id: PLACEABLE
- id: SELLABLE
value: 20
- id: DEFAULT_CRAFTABLE
recipes:
- type: SHAPED
recipe-type: NONE
pattern:
- AAA
- BBB
- AAA
ingredients:
A:
type: OAK_PLANKS
amount: 1
B:
type: BOOK
amount: 1
result:
type: BOOKSHELF
amount: 1
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public enum CustomCollectionAward {
IMPALING_DISCOUNT("§9Impaling §7Exp Discount §a(-25%)"),
BANE_OF_ARTHROPODS_DISCOUNT("§9Bane of Arthropods §7Exp Discount §a(-25%)"),
CUBISM_DISCOUNT("§9Cubism §7Exp Discount §a(-25%)"),
FORTUNE_DISCOUNT("§9Fortune §7Exp Discount §a(-25%)"),

// BAGS
QUIVER("§aQuiver"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,15 @@ public enum EnchantmentType {
IMPALING(EnchantmentImpaling.class),
BANE_OF_ARTHROPODS(EnchantmentBaneOfArthropods.class),
CUBISM(EnchantmentCubism.class),
FORTUNE(EnchantmentFortune.class),
;

private final Class<? extends Ench> clazz;
private final List<EnchantmentType> conflicts;

private final Ench ench;

@SneakyThrows
EnchantmentType(Class<? extends Ench> ench, EnchantmentType... conflicts) {
EnchantmentType(Class<? extends Ench> ench) {
this.clazz = ench;
this.conflicts = List.of(conflicts);

this.ench = ench.getConstructor().newInstance();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package net.swofty.type.skyblockgeneric.enchantment.abstr;

import net.swofty.type.skyblockgeneric.enchantment.EnchantmentType;

import java.util.List;

public interface ConflictingEnch {
List<EnchantmentType> getConflictingEnchantments();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package net.swofty.type.skyblockgeneric.enchantment.impl;

import net.swofty.commons.statistics.ItemStatistic;
import net.swofty.commons.statistics.ItemStatistics;
import net.swofty.type.skyblockgeneric.collection.CustomCollectionAward;
import net.swofty.type.skyblockgeneric.enchantment.EnchantmentType;
import net.swofty.type.skyblockgeneric.enchantment.abstr.ConflictingEnch;
import net.swofty.type.skyblockgeneric.enchantment.abstr.Ench;
import net.swofty.type.skyblockgeneric.enchantment.abstr.EnchFromTable;
import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer;
import net.swofty.type.skyblockgeneric.utility.groups.EnchantItemGroups;
import org.jetbrains.annotations.NotNull;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class EnchantmentFortune implements Ench, EnchFromTable, ConflictingEnch {

public static final int[] MINING_FORTUNE_BONUS = new int[]{10, 20, 30, 45};

@Override
public String getDescription(int level) {
return "Grants §a+" + MINING_FORTUNE_BONUS[level - 1] + " " + ItemStatistic.MINING_FORTUNE.getDisplayName() +
"§7, which increases your chance for multiple drops.";
}

@Override
public ApplyLevels getLevelsToApply(@NotNull SkyBlockPlayer player) {
HashMap<Integer, Integer> levels = new HashMap<>(Map.of(
4, 0
));

if (player.hasCustomCollectionAward(CustomCollectionAward.FORTUNE_DISCOUNT)) {
levels.replaceAll((k, v) -> (int) (v * 0.75));
}

return new ApplyLevels(levels);
}

@Override
public List<EnchantItemGroups> getGroups() {
return List.of(EnchantItemGroups.GAUNTLET, EnchantItemGroups.PICKAXE, EnchantItemGroups.DRILL);
}

@Override
public ItemStatistics getStatistics(int level) {
return ItemStatistics.builder()
.withBase(ItemStatistic.MINING_FORTUNE, (double) MINING_FORTUNE_BONUS[level - 1])
.build();
}

@Override
public TableLevels getLevelsFromTableToApply(@NotNull SkyBlockPlayer player) {
HashMap<Integer, Integer> levels = new HashMap<>(Map.of(
1, 15,
2, 30,
3, 45
));

if (player.hasCustomCollectionAward(CustomCollectionAward.FORTUNE_DISCOUNT)) {
levels.replaceAll((k, v) -> (int) (v * 0.75));
}

return new TableLevels(levels);
}

@Override
public int getRequiredBookshelfPower() {
return 0;
}

@Override
public List<EnchantmentType> getConflictingEnchantments() {
return List.of(EnchantmentType.SILK_TOUCH);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package net.swofty.type.skyblockgeneric.enchantment.impl;

import lombok.NonNull;
import net.swofty.type.skyblockgeneric.enchantment.EnchantmentType;
import net.swofty.type.skyblockgeneric.enchantment.abstr.ConflictingEnch;
import net.swofty.type.skyblockgeneric.enchantment.abstr.Ench;
import net.swofty.type.skyblockgeneric.enchantment.abstr.EnchFromTable;
import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer;
Expand All @@ -10,7 +12,7 @@
import java.util.List;
import java.util.Map;

public class EnchantmentSilkTouch implements Ench, EnchFromTable {
public class EnchantmentSilkTouch implements Ench, EnchFromTable, ConflictingEnch {

@Override
public String getDescription(int level) {
Expand Down Expand Up @@ -45,4 +47,9 @@ public TableLevels getLevelsFromTableToApply(@NonNull SkyBlockPlayer player) {
public int getRequiredBookshelfPower() {
return 5;
}

@Override
public List<EnchantmentType> getConflictingEnchantments() {
return List.of(EnchantmentType.SMELTING_TOUCH, EnchantmentType.FORTUNE);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package net.swofty.type.skyblockgeneric.enchantment.impl;

import lombok.NonNull;
import net.swofty.type.skyblockgeneric.enchantment.EnchantmentType;
import net.swofty.type.skyblockgeneric.enchantment.abstr.ConflictingEnch;
import net.swofty.type.skyblockgeneric.enchantment.abstr.Ench;
import net.swofty.type.skyblockgeneric.enchantment.abstr.EnchFromTable;
import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer;
Expand All @@ -10,7 +12,7 @@
import java.util.List;
import java.util.Map;

public class EnchantmentSmeltingTouch implements Ench, EnchFromTable {
public class EnchantmentSmeltingTouch implements Ench, EnchFromTable, ConflictingEnch {

@Override
public String getDescription(int level) {
Expand Down Expand Up @@ -45,4 +47,9 @@ public TableLevels getLevelsFromTableToApply(@NonNull SkyBlockPlayer player) {
public int getRequiredBookshelfPower() {
return 0;
}

@Override
public List<EnchantmentType> getConflictingEnchantments() {
return List.of(EnchantmentType.SILK_TOUCH);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import net.swofty.type.skyblockgeneric.enchantment.EnchantmentSource;
import net.swofty.type.skyblockgeneric.enchantment.EnchantmentType;
import net.swofty.type.skyblockgeneric.enchantment.SkyBlockEnchantment;
import net.swofty.type.skyblockgeneric.enchantment.abstr.ConflictingEnch;
import net.swofty.type.skyblockgeneric.enchantment.abstr.Ench;
import net.swofty.type.skyblockgeneric.item.ItemAttributeHandler;
import net.swofty.type.skyblockgeneric.item.SkyBlockItem;
import net.swofty.type.skyblockgeneric.item.components.EnchantableComponent;
Expand Down Expand Up @@ -129,11 +131,13 @@ public ItemStack.Builder getItem(HypixelPlayer p) {
@Override
public void run(InventoryPreClickEvent e, HypixelPlayer p) {
SkyBlockPlayer player = (SkyBlockPlayer) p;
ItemStack stack = p.getInventory().getCursorItem();
ItemStack stack = player.getInventory().getCursorItem();

if (stack.get(DataComponents.CUSTOM_NAME) == null) return;

e.setCancelled(true);
SkyBlockItem item = new SkyBlockItem(stack);
player.getInventory().setCursorItem(ItemStack.AIR);
updateFromItem(item, null);
}

Expand All @@ -156,15 +160,13 @@ public ItemStack.Builder getItem(HypixelPlayer p) {
@Override
public void run(InventoryPreClickEvent e, HypixelPlayer p) {
SkyBlockPlayer player = (SkyBlockPlayer) p;
ItemStack stack = p.getInventory().getCursorItem();
ItemStack stack = player.getInventory().getCursorItem();

if (stack.get(DataComponents.CUSTOM_NAME) == null) {
if (stack == ItemStack.AIR) {
e.setCancelled(true);
player.getInventory().setCursorItem(PlayerItemUpdater.playerUpdate(player, item.getItemStack()).build());
updateFromItem(null, null);
return;
}

SkyBlockItem item = new SkyBlockItem(stack);
updateFromItem(item, null);
}

@Override
Expand Down Expand Up @@ -303,6 +305,15 @@ public ItemStack.Builder getItem(HypixelPlayer p) {

lore.add("§a ");

if (selected.getEnch() instanceof ConflictingEnch conflictingEnch) {
for (EnchantmentType ench : conflictingEnch.getConflictingEnchantments()) {
if (item.getAttributeHandler().hasEnchantment(ench)) {
lore.add("§c§lWARNING: This will remove " + StringUtility.toNormalCase(ench.name()) + ".");
break;
}
}
}

if (finalHasLevel == finalLevel) {
lore.add("§cThis enchantment is already present");
lore.add("§cand can be removed.");
Expand Down Expand Up @@ -368,6 +379,13 @@ public void run(InventoryPreClickEvent e, HypixelPlayer p) {
new SkyBlockEnchantment(selected, finalLevel)
);

if (selected.getEnch() instanceof ConflictingEnch conflictingEnch) {
for (EnchantmentType enchant : conflictingEnch.getConflictingEnchantments()) {
System.out.printf("conflicting enchant: " + enchant.name());
if (item.getAttributeHandler().hasEnchantment(enchant)) item.getAttributeHandler().removeEnchantment(enchant);
}
}

player.setLevel(player.getLevel() - selected.getEnchFromTable().getLevelsFromTableToApply(player).get(finalLevel));
player.sendMessage("§aYou enchanted your " + itemName + " §awith " +
StringUtility.toNormalCase(selected.name()) + " " + StringUtility.getAsRomanNumeral(finalLevel) + "!");
Expand Down
Loading
Loading