Skip to content

Commit

Permalink
EXPERIMENTAL 1.20.6 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Travja committed May 30, 2024
1 parent a3774ad commit fe617d5
Show file tree
Hide file tree
Showing 18 changed files with 206 additions and 511 deletions.
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>studio.magemonkey</groupId>
<artifactId>magemonkey-parent</artifactId>
<version>1.20.4-SNAPSHOT</version>
<version>1.20.6-SNAPSHOT</version>
</parent>

<artifactId>divinity</artifactId>
Expand Down Expand Up @@ -38,6 +38,11 @@
</repositories>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.20.4-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ private void applyShieldDamage(Player player) {
if (shield == null) return;

Damageable shieldMeta = (Damageable) shield.getItemMeta();
int level = shieldMeta.getEnchantLevel(Enchantment.DURABILITY);
int level = shieldMeta.getEnchantLevel(Enchantment.getByName("unbreaking")); // DURABILITY/UNBREAKING
if (Rnd.get(true) <= (100d / (level + 1))) {
shieldMeta.setDamage(shieldMeta.getDamage() + 1);
shield.setItemMeta(shieldMeta);
Expand Down Expand Up @@ -464,19 +464,19 @@ private boolean handleDamagePostEffects(
private double getEnchantModifier(@NotNull LivingEntity zertva, @NotNull DamageCause cause) {
EntityStats stats = EntityStats.get(zertva);

double epfAll = stats.getEnchantProtectFactor(Enchantment.PROTECTION_ENVIRONMENTAL);
double epfAll = stats.getEnchantProtectFactor(Enchantment.getByName("protection")); // PROTECTION_ENVIRONMENTAL/PROTECTION
double epfSpec = 0D;
double epfMod = 1D;

if (cause == DamageCause.FIRE || cause == DamageCause.FIRE_TICK
|| cause == DamageCause.LAVA) {
epfSpec = stats.getEnchantProtectFactor(Enchantment.PROTECTION_FIRE);
epfSpec = stats.getEnchantProtectFactor(Enchantment.getByName("fire_protection")); // PROTECTION_FIRE/FIRE_PROTECTION
} else if (cause == DamageCause.FALL) {
epfSpec = stats.getEnchantProtectFactor(Enchantment.PROTECTION_FALL);
epfSpec = stats.getEnchantProtectFactor(Enchantment.getByName("feather_falling")); // PROTECTION_FALL/FEATHER_FALLING
} else if (cause == DamageCause.PROJECTILE) {
epfSpec = stats.getEnchantProtectFactor(Enchantment.PROTECTION_PROJECTILE);
epfSpec = stats.getEnchantProtectFactor(Enchantment.getByName("projectile_protection")); // PROTECTION_PROJECTILE/PROJECTILE_PROTECTION
} else if (cause == DamageCause.BLOCK_EXPLOSION || cause == DamageCause.ENTITY_EXPLOSION) {
epfSpec = stats.getEnchantProtectFactor(Enchantment.PROTECTION_EXPLOSIONS);
epfSpec = stats.getEnchantProtectFactor(Enchantment.getByName("blast_protection")); // PROTECTION_EXPLOSION/BLAST_PROTECTION
}
epfMod = Math.min(20D, (epfSpec + epfAll));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package studio.magemonkey.divinity.manager.effects.main;

import studio.magemonkey.codex.util.EffectUT;
import studio.magemonkey.divinity.manager.effects.IEffectType;
import studio.magemonkey.divinity.manager.effects.IPeriodicEffect;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.entity.LivingEntity;
import org.jetbrains.annotations.NotNull;
import studio.magemonkey.codex.util.EffectUT;
import studio.magemonkey.divinity.manager.effects.IEffectType;
import studio.magemonkey.divinity.manager.effects.IPeriodicEffect;

import java.util.function.Function;

Expand Down Expand Up @@ -59,7 +59,13 @@ public static class Builder extends IPeriodicEffect.Builder<Builder> {
public Builder(double lifeTime, double interval, @NotNull Function<LivingEntity, Double> damageFunction) {
super(lifeTime, interval);
this.withFunction(damageFunction);
this.withBlood(Particle.BLOCK_CRACK);
Particle particle;
try {
particle = Particle.BLOCK;
} catch (Exception e) {
particle = Particle.valueOf("BLOCK_CRACK");
}
this.withBlood(particle);
this.withColor(Material.REDSTONE_BLOCK.name());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static class Builder extends IPeriodicEffect.Builder<Builder> {

public Builder(double lifeTime) {
super(lifeTime, 1D / 20D);
this.addPotionEffects(new PotionEffect(PotionEffectType.SLOW, (int) (lifeTime * 20), 127));
this.addPotionEffects(new PotionEffect(PotionEffectType.getByName("slowness"), (int) (lifeTime * 20), 127)); // SLOWNESS/SLOW
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public static class Builder extends IPeriodicEffect.Builder<Builder> {
public Builder(double lifeTime) {
super(lifeTime, 1D / 20D);

this.addPotionEffects(new PotionEffect(PotionEffectType.SLOW, (int) (lifeTime * 20), 127));
this.addPotionEffects(new PotionEffect(PotionEffectType.SLOW_DIGGING, (int) (lifeTime * 20), 127));
this.addPotionEffects(new PotionEffect(PotionEffectType.getByName("slowness"), (int) (lifeTime * 20), 127)); // SLOW/SLOWNESS
this.addPotionEffects(new PotionEffect(PotionEffectType.getByName("mining_fatigue"), (int) (lifeTime * 20), 127)); // SLOW_DIGGING/MINING_FATIGUE
this.addPotionEffects(new PotionEffect(PotionEffectType.BLINDNESS, (int) lifeTime * 20, 127));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ protected ItemStack build(@NotNull ItemStack item) {
meta.addItemFlags(this.flags.toArray(new ItemFlag[this.flags.size()]));
meta.setUnbreakable(this.isUnbreakable);
if (this.enchanted) {
meta.addEnchant(Enchantment.ARROW_DAMAGE, 1, true);
meta.addEnchant(Enchantment.getByName("punch"), 1, true); // ARROW_DAMAGE/PUNCH
}

item.setItemMeta(meta);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void onQuantumArrowLaunch(DivinityProjectileLaunchEvent e) {

ItemStack bow = e.getWeapon();
if (e.isBowEvent() && !this.generalAllowInfinity && bow != null) {
if (bow.containsEnchantment(Enchantment.ARROW_INFINITE)) {
if (bow.containsEnchantment(Enchantment.getByName("infinity"))) { // ARROW_INFINITE/INFINITY
arrow.setAmount(arrow.getAmount() - 1);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,14 @@ public void open(
for (int socketSlot : socketSlots) {
ItemStack socketItem = inv.getItem(socketSlot);
if (socketItem != null) {
socketItem.removeEnchantment(Enchantment.ARROW_DAMAGE);
socketItem.removeEnchantment(Enchantment.getByName("punch")); // ARROW_DAMAGE/PUNCH
}
}

// Add glow to selected socket item
ItemStack item1 = e.getCurrentItem();
if (item1 != null) {
item1.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1);
item1.addUnsafeEnchantment(Enchantment.getByName("punch"), 1); // ARROW_DAMAGE/PUNCH
}

ItemStack target1 = getItem(inv, itemSlot);
Expand Down Expand Up @@ -242,7 +242,7 @@ else if (e.isRightClick()) {
Enum<?> type2 = guiItem.getType();
if (type2 != null && type2 == type) {
ItemStack itemGlow = guiItem.getItem();
itemGlow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1);
itemGlow.addUnsafeEnchantment(Enchantment.getByName("punch"), 1); // ARROW_DAMAGE/PUNCH
DataUT.setData(itemGlow, META_KEY_SOCKET_SELECT, "true");
JIcon active = new JIcon(itemGlow);
active.setClick(guiItem.getClick());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
package studio.magemonkey.divinity.modules.list.itemgenerator.editor;

import studio.magemonkey.codex.config.api.JYML;
import studio.magemonkey.codex.core.Version;
import studio.magemonkey.codex.manager.api.menu.Menu;
import studio.magemonkey.codex.util.StringUT;
import studio.magemonkey.divinity.Divinity;
import studio.magemonkey.divinity.modules.list.itemgenerator.ItemGeneratorManager;
import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.Material;
import org.bukkit.entity.HumanEntity;
Expand All @@ -18,6 +12,12 @@
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.Nullable;
import studio.magemonkey.codex.config.api.JYML;
import studio.magemonkey.codex.core.Version;
import studio.magemonkey.codex.manager.api.menu.Menu;
import studio.magemonkey.codex.util.StringUT;
import studio.magemonkey.divinity.Divinity;
import studio.magemonkey.divinity.modules.list.itemgenerator.ItemGeneratorManager;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -68,8 +68,15 @@ protected static ItemStack createItem(ItemStack itemStack, String name, String..
protected static ItemStack createItem(ItemStack itemStack, String name, List<String> lore) {
ItemMeta meta = itemStack.getItemMeta();
if (meta != null) {
ItemFlag hidePotionsFlag;
try {
hidePotionsFlag = ItemFlag.HIDE_ADDITIONAL_TOOLTIP;
} catch (IllegalArgumentException ignored) {
hidePotionsFlag = ItemFlag.valueOf("HIDE_POTION_EFFECTS");
}

meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
meta.addItemFlags(hidePotionsFlag);
if (Version.CURRENT.isHigher(Version.V1_19_R3)) {
meta.addItemFlags(ItemFlag.HIDE_ARMOR_TRIM);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ public void setContents() {
material = Material.OAK_PLANKS;
break;
}
case HIDE_POTION_EFFECTS: {
material = Material.POTION;
break;
}
case HIDE_DYE: {
material = Material.MAGENTA_DYE;
break;
Expand All @@ -74,6 +70,11 @@ public void setContents() {
break;
}
}

if(flag.name().equals("HIDE_POTION_EFFECTS") || flag.name().equals("HIDE_ADDITIONAL_TOOLTIP")) {
material = Material.POTION;
}

String name = flag.name().toLowerCase();
this.setSlot(i, new Slot(createItem(material,
"&e" + name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public void open(
ItemStack itemGlow = guiItem.getItem();
this.replaceCostHave(player, target, itemGlow, repairType);
if (type2 == type) {
itemGlow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1);
itemGlow.addUnsafeEnchantment(Enchantment.getByName("punch"), 1); // ARROW_DAMAGE/PUNCH
DataUT.setData(itemGlow, META_KEY_REPAIR_SELECT, "true");
}

Expand Down

This file was deleted.

Loading

0 comments on commit fe617d5

Please sign in to comment.