Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enchantment glint set #94

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19-R0.1-SNAPSHOT</version>
<version>1.20.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.github.Slimefun</groupId>
<artifactId>Slimefun4</artifactId>
<version>1aeb0e8</version>
<version>03e5b9ab1e</version>
<scope>provided</scope>
</dependency>

Expand Down
80 changes: 0 additions & 80 deletions src/main/java/dev/j3fftw/litexpansion/GlowEnchant.java

This file was deleted.

84 changes: 46 additions & 38 deletions src/main/java/dev/j3fftw/litexpansion/Items.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;

import java.util.List;

public final class Items {

//region Category
Expand Down Expand Up @@ -64,12 +66,15 @@ public final class Items {
"GLASS_CUTTER",
Material.GHAST_TEAR,
"&bGlass Cutter",
"",
"&7> &eLeft Click &7- Cut glass quickly",
"&7> &eRight Click &7- Cut glass slowly",
"",
"&c&o&8\u21E8 &e\u26A1 &70 / 300 J"
);
meta -> {
meta.setEnchantmentGlintOverride(true);
meta.setLore(List.of(
"",
"&7> &eLeft Click &7- Cut glass quickly",
"&7> &eRight Click &7- Cut glass slowly",
"",
"&c&o&8\u21E8 &e\u26A1 &70 / 300 J"));
});
public static final SlimefunItemStack MINING_DRILL = new SlimefunItemStack(
"MINING_DRILL",
Material.IRON_SHOVEL,
Expand All @@ -84,12 +89,16 @@ public final class Items {
"DIAMOND_DRILL",
Material.DIAMOND_SHOVEL,
"&bDiamond Drill",
"",
"&7Instantly breaks obsidian, stone, and stone variants",
"&7Right click to break block slower",
"",
"&c&o&8\u21E8 &e\u26A1 &70 / 1000 J"
);
meta -> {
meta.setEnchantmentGlintOverride(true);
meta.setLore(List.of(
"",
"&7Instantly breaks obsidian, stone, and stone variants",
"&7Right click to break block slower",
"",
"&c&o&8\u21E8 &e\u26A1 &70 / 1000 J"
));
});
public static final SlimefunItemStack TREETAP = new SlimefunItemStack(
"TREETAP",
Material.WOODEN_HOE,
Expand Down Expand Up @@ -228,7 +237,8 @@ public final class Items {
public static final SlimefunItemStack ADVANCED_CIRCUIT = new SlimefunItemStack(
"ADVANCED_CIRCUIT",
Material.COBWEB,
"&7Advanced Circuit"
"&7Advanced Circuit",
meta -> {meta.setEnchantmentGlintOverride(true);}
);
//endregion

Expand Down Expand Up @@ -272,8 +282,10 @@ public final class Items {
public static final SlimefunItemStack LAPOTRON_CRYSTAL = new SlimefunItemStack(
"LAPOTRON_CRYSTAL",
Material.DIAMOND,
"&7Lapotron Crystal"
);
"&7Lapotron Crystal",
meta -> {
meta.setEnchantmentGlintOverride(true);
});
public static final SlimefunItemStack REINFORCED_STONE = new SlimefunItemStack(
"REINFORCED_STONE",
Material.STONE,
Expand Down Expand Up @@ -443,20 +455,26 @@ public final class Items {
public static final SlimefunItemStack ADVANCEDLX_SOLAR_HELMET = new SlimefunItemStack(
"ADVANCEDLX_SOLAR_HELMET",
Material.DIAMOND_HELMET,
"&7Super Advanced Solar Helmet"
);
"&7Super Advanced Solar Helmet",
meta -> {
meta.setEnchantmentGlintOverride(true);
});

public static final SlimefunItemStack HYBRID_SOLAR_HELMET = new SlimefunItemStack(
"HYBRID_SOLAR_HELMET",
Material.DIAMOND_HELMET,
"&7Hybrid Solar Helmet"
);
"&7Hybrid Solar Helmet",
meta -> {
meta.setEnchantmentGlintOverride(true);
});

public static final SlimefunItemStack ULTIMATE_SOLAR_HELMET = new SlimefunItemStack(
"ULTIMATE_SOLAR_HELMET",
Material.DIAMOND_HELMET,
"&7Ultimate Solar Helmet"
);
"&7Ultimate Solar Helmet",
meta -> {
meta.setEnchantmentGlintOverride(true);
});

public static final SlimefunItemStack FOOD_SYNTHESIZER = new SlimefunItemStack(
"FOOD_SYNTHESIZER",
Expand Down Expand Up @@ -550,24 +568,14 @@ public final class Items {
Material.COAL_BLOCK,
"&7Converter"
);

private static final Enchantment glowEnchant = Enchantment.getByKey(Constants.GLOW_ENCHANT);


static {
ADVANCED_SOLAR_HELMET.addEnchantment(Enchantment.DURABILITY, 1);
CARBONADO_SOLAR_HELMET.addEnchantment(Enchantment.DURABILITY, 2);
ENERGIZED_SOLAR_HELMET.addEnchantment(Enchantment.DURABILITY, 3);
ADVANCEDLX_SOLAR_HELMET.addUnsafeEnchantment(Enchantment.DURABILITY, 4);
HYBRID_SOLAR_HELMET.addUnsafeEnchantment(Enchantment.DURABILITY, 5);
ULTIMATE_SOLAR_HELMET.addUnsafeEnchantment(Enchantment.DURABILITY, 6);
ADVANCED_CIRCUIT.addEnchantment(glowEnchant, 1);
GLASS_CUTTER.addEnchantment(glowEnchant, 1);

DIAMOND_DRILL.addEnchantment(glowEnchant, 1);
LAPOTRON_CRYSTAL.addEnchantment(glowEnchant, 1);
ADVANCEDLX_SOLAR_HELMET.addEnchantment(glowEnchant, 1);
HYBRID_SOLAR_HELMET.addEnchantment(glowEnchant, 1);
ULTIMATE_SOLAR_HELMET.addEnchantment(glowEnchant, 1);
ADVANCED_SOLAR_HELMET.addEnchantment(Enchantment.UNBREAKING, 1);
CARBONADO_SOLAR_HELMET.addEnchantment(Enchantment.UNBREAKING, 2);
ENERGIZED_SOLAR_HELMET.addEnchantment(Enchantment.UNBREAKING, 3);
ADVANCEDLX_SOLAR_HELMET.addUnsafeEnchantment(Enchantment.UNBREAKING, 4);
HYBRID_SOLAR_HELMET.addUnsafeEnchantment(Enchantment.UNBREAKING, 5);
ULTIMATE_SOLAR_HELMET.addUnsafeEnchantment(Enchantment.UNBREAKING, 6);
}

private Items() {}
Expand Down
19 changes: 0 additions & 19 deletions src/main/java/dev/j3fftw/litexpansion/LiteXpansion.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ public void onEnable() {
new BlobBuildUpdater(this, getFile(), "LiteXpansion", "Dev").start();
}

registerEnchantments();

if (getConfig().getBoolean("options.nerf-other-addons", true)) {
getServer().getScheduler().runTask(this, this::nerfCrap);
}
Expand All @@ -65,23 +63,6 @@ public void onDisable() {
setInstance(null);
}

private void registerEnchantments() {
if (!Enchantment.isAcceptingRegistrations()) {
Reflections.setStaticField(Enchantment.class, "acceptingNew", true);
}

Enchantment glowEnchantment = new GlowEnchant(Constants.GLOW_ENCHANT, new String[] {
"ADVANCED_CIRCUIT", "NANO_BLADE", "GLASS_CUTTER", "LAPOTRON_CRYSTAL",
"ADVANCEDLX_SOLAR_HELMET", "HYBRID_SOLAR_HELMET", "ULTIMATE_SOLAR_HELMET",
"DIAMOND_DRILL"
});

// Prevent double-registration errors
if (Enchantment.getByKey(glowEnchantment.getKey()) == null) {
Enchantment.registerEnchantment(glowEnchantment);
}
}

private void nerfCrap() {
// Vanilla SF
final SlimefunItem energizedPanel = SlimefunItem.getById("SOLAR_GENERATOR_4");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ public AdvancedSolarHelmet(Type type) {
type.getGenerationRate()
);
this.type = type;
Items.ADVANCED_SOLAR_HELMET.addEnchantment(Enchantment.DURABILITY, 1);
Items.CARBONADO_SOLAR_HELMET.addEnchantment(Enchantment.DURABILITY, 2);
Items.ENERGIZED_SOLAR_HELMET.addEnchantment(Enchantment.DURABILITY, 3);
Items.ADVANCEDLX_SOLAR_HELMET.addUnsafeEnchantment(Enchantment.DURABILITY, 4);
Items.HYBRID_SOLAR_HELMET.addUnsafeEnchantment(Enchantment.DURABILITY, 5);
Items.ULTIMATE_SOLAR_HELMET.addUnsafeEnchantment(Enchantment.DURABILITY, 6);
Items.ADVANCED_SOLAR_HELMET.addEnchantment(Enchantment.UNBREAKING, 1);
Items.CARBONADO_SOLAR_HELMET.addEnchantment(Enchantment.UNBREAKING, 2);
Items.ENERGIZED_SOLAR_HELMET.addEnchantment(Enchantment.UNBREAKING, 3);
Items.ADVANCEDLX_SOLAR_HELMET.addUnsafeEnchantment(Enchantment.UNBREAKING, 4);
Items.HYBRID_SOLAR_HELMET.addUnsafeEnchantment(Enchantment.UNBREAKING, 5);
Items.ULTIMATE_SOLAR_HELMET.addUnsafeEnchantment(Enchantment.UNBREAKING, 6);
}

@Getter
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/dev/j3fftw/litexpansion/utils/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
import org.bukkit.NamespacedKey;

public final class Constants {

public static final NamespacedKey GLOW_ENCHANT = new NamespacedKey(LiteXpansion.getInstance(),
"glow_enchant");

public static final NamespacedKey NANO_BLADE_ENABLED = new NamespacedKey(LiteXpansion.getInstance(),
"nano_blade_enabled");

Expand Down
9 changes: 4 additions & 5 deletions src/main/java/dev/j3fftw/litexpansion/weapons/NanoBlade.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,12 @@ public float getMaxItemCharge(ItemStack item) {
public ItemUseHandler getItemHandler() {
return event -> {
final ItemMeta nanoBladeMeta = event.getItem().getItemMeta();
final Enchantment enchantment = Enchantment.getByKey(Constants.GLOW_ENCHANT);
boolean enabled = !nanoBladeMeta.removeEnchant(enchantment);
boolean enabled = !nanoBladeMeta.getEnchantmentGlintOverride();

int damage;

if (enabled && getItemCharge(event.getItem()) > getRemovedChargePerTick()) {
nanoBladeMeta.addEnchant(enchantment, 1, false);
nanoBladeMeta.setEnchantmentGlintOverride(true);
nanoBladeMeta.setDisplayName(ChatColor.DARK_GREEN + "Nano Blade" + ChatColor.GREEN + " (On)");

damage = 13; // Base is 7 so 7 + 13 = 20
Expand Down Expand Up @@ -89,7 +88,7 @@ public float getCapacity() {
@Override
public boolean isEnabled(@Nonnull ItemMeta meta) {
final Optional<Boolean> opt = Utils.getOptionalBoolean(meta, Constants.NANO_BLADE_ENABLED);

return (opt.isPresent() && opt.get()) || meta.hasEnchant(Enchantment.getByKey(Constants.GLOW_ENCHANT));
final Boolean hasOverride = meta.getEnchantmentGlintOverride();
return (opt.isPresent() && opt.get()) || hasOverride;
}
}
Loading