Minor fixes (v3.5.1)

This commit is contained in:
BuildTools 2023-07-18 23:44:43 +05:00
parent 7635ab4082
commit 6bd2119de6
9 changed files with 51 additions and 40 deletions

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.5.0</version>
<version>3.5.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -21,40 +21,25 @@
<id>md_5-releases</id>
<url>https://repo.md-5.net/content/repositories/releases/</url>
</repository>
<repository>
<id>sk89q-repo</id>
<url>https://maven.enginehub.org/repo/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>dmulloy2-repo</id>
<url>https://repo.dmulloy2.net/repository/public/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>lumine-repo</id>
<url>https://mvn.lumine.io/repository/maven-public/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>lumine-snapshot</id>
<url>http://mvn.lumine.io/repository/maven-snapshots/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
@ -79,7 +64,8 @@
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>5.0.0-SNAPSHOT</version>
<version>5.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
@ -95,27 +81,27 @@
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId>
<version>3.5.0</version>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_17_R1</artifactId>
<version>3.5.0</version>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_18_R2</artifactId>
<version>3.5.0</version>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_19_R3</artifactId>
<version>3.5.0</version>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_20_R1</artifactId>
<version>3.5.0</version>
<version>3.5.1</version>
</dependency>
</dependencies>

View File

@ -36,8 +36,13 @@ public class Placeholders extends su.nexmedia.engine.utils.Placeholders {
public static final String ENCHANTMENT_CHARGES_RECHARGE_AMOUNT = "%enchantment_charges_recharge_amount%";
public static final String ENCHANTMENT_CHARGES_FUEL_ITEM = "%enchantment_charges_fuel_item%";
public static final String TIER_ID = "%tier_id%";
public static final String TIER_NAME = "%tier_name%";
public static final String TIER_ID = "%tier_id%";
public static final String TIER_NAME = "%tier_name%";
public static final String TIER_OBTAIN_CHANCE_ENCHANTING = "%tier_obtain_chance_enchanting%";
public static final String TIER_OBTAIN_CHANCE_VILLAGER = "%tier_obtain_chance_villager%";
public static final String TIER_OBTAIN_CHANCE_LOOT_GENERATION = "%tier_obtain_chance_loot_generation%";
public static final String TIER_OBTAIN_CHANCE_FISHING = "%tier_obtain_chance_fishing%";
public static final String TIER_OBTAIN_CHANCE_MOB_SPAWNING = "%tier_obtain_chance_mob_spawning%";
}

View File

@ -9,7 +9,6 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.command.AbstractCommand;
import su.nexmedia.engine.api.command.CommandResult;
import su.nexmedia.engine.lang.LangManager;
import su.nexmedia.engine.utils.CollectionsUtil;
import su.nexmedia.engine.utils.PlayerUtil;
import su.nexmedia.engine.utils.random.Rnd;
@ -75,7 +74,7 @@ public class BookCommand extends AbstractCommand<ExcellentEnchants> {
PlayerUtil.addItem(player, item);
plugin.getMessage(Lang.COMMAND_BOOK_DONE)
.replace(Placeholders.GENERIC_ENCHANT, LangManager.getEnchantment(enchantment))
.replace(Placeholders.GENERIC_ENCHANT, EnchantUtils.getLocalized(enchantment))
.replace(Placeholders.forPlayer(player))
.send(sender);
}

View File

@ -91,6 +91,7 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme
map.add(Placeholders.ENCHANTMENT_POTION_DURATION, () -> NumberUtil.format(potioned.getEffectDuration(level) / 20D));
map.add(Placeholders.ENCHANTMENT_POTION_TYPE, () -> LangManager.getPotionType(potioned.getEffectType()));
}
map.add(this.getTier().getPlaceholders());
this.placeholdersMap.put(level, map);
}

View File

@ -10,10 +10,11 @@ import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.block.BlockCanBuildEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.particle.SimpleParticle;
@ -89,9 +90,9 @@ public class FlareEnchant extends ExcellentEnchant implements Chanced, Arrowed,
if (!relative.getType().isAir()) return false;
if (projectile.getShooter() instanceof Player player) {
BlockCanBuildEvent event = new BlockCanBuildEvent(relative, player, Material.TORCH.createBlockData(), true);
BlockPlaceEvent event = new BlockPlaceEvent(relative, relative.getState(), block, new ItemStack(Material.TORCH), player,true, EquipmentSlot.HAND);
plugin.getPluginManager().callEvent(event);
if (!event.isBuildable()) return false;
if (event.isCancelled() || !event.canBuild()) return false;
}
if (face == BlockFace.UP) {

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.menu;
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
@ -13,7 +12,6 @@ import su.nexmedia.engine.api.menu.click.ItemClick;
import su.nexmedia.engine.api.menu.impl.ConfigMenu;
import su.nexmedia.engine.api.menu.impl.MenuOptions;
import su.nexmedia.engine.api.menu.impl.MenuViewer;
import su.nexmedia.engine.lang.LangManager;
import su.nexmedia.engine.utils.Colorizer;
import su.nexmedia.engine.utils.ItemUtil;
import su.nexmedia.engine.utils.PDCUtil;
@ -22,6 +20,7 @@ import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.Placeholders;
import su.nightexpress.excellentenchants.enchantment.EnchantRegistry;
import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant;
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
import java.util.*;
import java.util.function.Predicate;
@ -84,7 +83,7 @@ public class EnchantmentsListMenu extends ConfigMenu<ExcellentEnchants> implemen
public List<ExcellentEnchant> getObjects(@NotNull Player player) {
return new ArrayList<>(EnchantRegistry.getRegistered().stream()
.filter(Predicate.not(enchant -> enchant.getDefaults().isHiddenFromList()))
.sorted(Comparator.comparing(ExcellentEnchant::getName)).toList());
.sorted(Comparator.comparing(e -> Colorizer.strip(e.getDisplayName()))).toList());
}
@Override
@ -125,8 +124,7 @@ public class EnchantmentsListMenu extends ConfigMenu<ExcellentEnchants> implemen
if (lore == null) lore = new ArrayList<>();
List<String> conflicts = enchant.getConflicts().isEmpty() ? Collections.emptyList() : new ArrayList<>(this.enchantLoreConflicts);
List<String> conflictNames = enchant.getConflicts().stream().map(key -> Enchantment.getByKey(NamespacedKey.minecraft(key)))
.filter(Objects::nonNull).map(LangManager::getEnchantment).toList();
List<String> conflictNames = enchant.getConflicts().stream().map(EnchantUtils::getLocalized).toList();
conflicts = StringUtil.replace(conflicts, Placeholders.ENCHANTMENT_NAME, true, conflictNames);
List<String> charges = enchant.isChargesEnabled() ? new ArrayList<>(this.enchantLoreCharges) : Collections.emptyList();

View File

@ -13,6 +13,7 @@ import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import su.nexmedia.engine.lang.LangManager;
import su.nexmedia.engine.utils.CollectionsUtil;
import su.nexmedia.engine.utils.EntityUtil;
import su.nexmedia.engine.utils.ItemUtil;
@ -44,6 +45,20 @@ public class EnchantUtils {
return NamespacedKey.minecraft(id.toLowerCase());
}
@NotNull
public static String getLocalized(@NotNull String keyRaw) {
Enchantment enchantment = Enchantment.getByKey(NamespacedKey.minecraft(keyRaw));
return enchantment == null ? "null" : getLocalized(enchantment);
}
@NotNull
public static String getLocalized(@NotNull Enchantment enchantment) {
if (enchantment instanceof ExcellentEnchant excellentEnchant) {
return excellentEnchant.getDisplayName();
}
return LangManager.getEnchantment(enchantment);
}
public static boolean isEnchantable(@NotNull ItemStack item) {
if (item.getType().isAir()) return false;

View File

@ -5,6 +5,7 @@ import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.placeholder.Placeholder;
import su.nexmedia.engine.api.placeholder.PlaceholderMap;
import su.nexmedia.engine.utils.Colorizer;
import su.nexmedia.engine.utils.NumberUtil;
import su.nightexpress.excellentenchants.Placeholders;
import su.nightexpress.excellentenchants.enchantment.type.ObtainType;
@ -29,6 +30,11 @@ public class Tier implements Placeholder {
this.placeholderMap = new PlaceholderMap()
.add(Placeholders.TIER_ID, this::getId)
.add(Placeholders.TIER_NAME, this::getName)
.add(Placeholders.TIER_OBTAIN_CHANCE_ENCHANTING, () -> NumberUtil.format(this.getChance(ObtainType.ENCHANTING)))
.add(Placeholders.TIER_OBTAIN_CHANCE_VILLAGER, () -> NumberUtil.format(this.getChance(ObtainType.VILLAGER)))
.add(Placeholders.TIER_OBTAIN_CHANCE_LOOT_GENERATION, () -> NumberUtil.format(this.getChance(ObtainType.LOOT_GENERATION)))
.add(Placeholders.TIER_OBTAIN_CHANCE_FISHING, () -> NumberUtil.format(this.getChance(ObtainType.FISHING)))
.add(Placeholders.TIER_OBTAIN_CHANCE_MOB_SPAWNING, () -> NumberUtil.format(this.getChance(ObtainType.MOB_SPAWNING)))
;
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.5.0</version>
<version>3.5.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -27,7 +27,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<version>1.20.1-R0.1-SNAPSHOT</version>
</dependency>
</dependencies>