diff --git a/build.gradle b/build.gradle index 7f3d03d..bc53750 100644 --- a/build.gradle +++ b/build.gradle @@ -52,8 +52,8 @@ dependencies { compileOnly 'com.sk89q.worldedit:worldedit-bukkit:7.2.15' compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.9' compileOnly "dev.jorel:commandapi-bukkit-core:9.2.0" - compileOnly files("libs/MechanicsCore-3.1.2.jar") - compileOnly files("libs/WeaponMechanics-3.1.1.jar") + compileOnly files("libs/MechanicsCore-3.3.1.jar") + compileOnly files("libs/WeaponMechanics-3.3.1.jar") compileOnly 'me.neznamy:tab-api:4.0.2' shadowIn "xyz.xenondevs.invui:invui:1.15" diff --git a/libs/MechanicsCore-3.1.2.jar b/libs/MechanicsCore-3.1.2.jar deleted file mode 100644 index 9bf781f..0000000 Binary files a/libs/MechanicsCore-3.1.2.jar and /dev/null differ diff --git a/libs/MechanicsCore-3.3.1.jar b/libs/MechanicsCore-3.3.1.jar new file mode 100644 index 0000000..332ac2e Binary files /dev/null and b/libs/MechanicsCore-3.3.1.jar differ diff --git a/libs/WeaponMechanics-3.1.1.jar b/libs/WeaponMechanics-3.1.1.jar deleted file mode 100644 index 9e4c76c..0000000 Binary files a/libs/WeaponMechanics-3.1.1.jar and /dev/null differ diff --git a/libs/WeaponMechanics-3.3.1.jar b/libs/WeaponMechanics-3.3.1.jar new file mode 100644 index 0000000..40d6db8 Binary files /dev/null and b/libs/WeaponMechanics-3.3.1.jar differ diff --git a/src/main/java/dev/felnull/shortlifeplugin/listener/CommonListener.java b/src/main/java/dev/felnull/shortlifeplugin/listener/CommonListener.java index 2ddef22..6172a54 100644 --- a/src/main/java/dev/felnull/shortlifeplugin/listener/CommonListener.java +++ b/src/main/java/dev/felnull/shortlifeplugin/listener/CommonListener.java @@ -9,7 +9,6 @@ import dev.felnull.shortlifeplugin.match.MatchManager; import dev.felnull.shortlifeplugin.match.TeamBaseMatch; import dev.felnull.shortlifeplugin.utils.WeaponMechanicsUtils; -import me.deecaad.weaponmechanics.events.WeaponMechanicsEntityDamageByEntityEvent; import me.deecaad.weaponmechanics.weapon.weaponevents.WeaponDamageEntityEvent; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; @@ -90,7 +89,7 @@ private static void sendTestMessage(Player player) { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onDamage(EntityDamageEvent e) { // WeaponMechanicsのダメージ以外 - if (!(e instanceof WeaponMechanicsEntityDamageByEntityEvent) && e.getEntity() instanceof LivingEntity livingEntity + if (!WeaponMechanicsUtils.isDoingWeaponDamageEvent(e) && e.getEntity() instanceof LivingEntity livingEntity && BloodExpression.isSpawnDamageParticle(livingEntity, e.getDamage())) { spawnDamageParticle(e, livingEntity); } @@ -170,8 +169,8 @@ public void onPlayerDeath(PlayerDeathEvent e) { */ private void sendDeathMessage(PlayerDeathEvent e, Player killed, Player killer) { ItemStack stack = killer.getEquipment().getItemInMainHand(); - Component weapon = !stack.isEmpty() - ? stack.displayName() + Component weapon = !stack.isEmpty() + ? stack.displayName() : Component.text(MsgHandler.get("event-death-bare-hand")).color(NamedTextColor.RED).decorate(TextDecoration.BOLD); NamedTextColor killedColor = TeamBaseMatch.getTeamColor(killed); NamedTextColor killerColor = TeamBaseMatch.getTeamColor(killer); diff --git a/src/main/java/dev/felnull/shortlifeplugin/utils/WeaponMechanicsUtils.java b/src/main/java/dev/felnull/shortlifeplugin/utils/WeaponMechanicsUtils.java index 36131cc..257f501 100644 --- a/src/main/java/dev/felnull/shortlifeplugin/utils/WeaponMechanicsUtils.java +++ b/src/main/java/dev/felnull/shortlifeplugin/utils/WeaponMechanicsUtils.java @@ -1,11 +1,12 @@ package dev.felnull.shortlifeplugin.utils; -import me.deecaad.core.compatibility.CompatibilityAPI; import me.deecaad.core.file.Configuration; import me.deecaad.weaponmechanics.WeaponMechanics; import me.deecaad.weaponmechanics.weapon.damage.DamagePoint; +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.util.BoundingBox; import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; @@ -20,6 +21,11 @@ */ public class WeaponMechanicsUtils { + /** + * 銃ダメージイベントの間だけ付与されるメタデータ名 + */ + private static final String WEAPON_DAMAGE_EVENT_METADATA = "doing-weapon-damage"; + private WeaponMechanicsUtils() { throw new AssertionError(); } @@ -42,7 +48,7 @@ public static Optional getDamagePointBox(@NotNull LivingEntity livi Configuration basicConfiguration = WeaponMechanics.getBasicConfigurations(); EntityType type = livingEntity.getType(); - double entityHeight = CompatibilityAPI.getEntityCompatibility().getHeight(livingEntity); + double entityHeight = livingEntity.getHeight(); // CompatibilityAPI.getEntityCompatibility().getHeight(livingEntity); BoundingBox boundingBox = livingEntity.getBoundingBox(); Vector boxMin = boundingBox.getMin(); Vector boxMax = boundingBox.getMax(); @@ -89,4 +95,17 @@ public static Optional getDamagePointBox(@NotNull LivingEntity livi return Optional.ofNullable(ret); } + + /** + * 銃のダメージイベントかどうか確認
+ * 銃ダメージでのイベント中のみ特定のメタデータが付与される仕様
+ * もし今後この仕様が変更された場合は、{@link me.deecaad.weaponmechanics.weapon.damage.DamageUtil}を参照 + * + * @param e ダメージイベント + * @return 銃ダメージでのイベントかどうか + */ + public static boolean isDoingWeaponDamageEvent(EntityDamageEvent e) { + Entity entity = e.getEntity(); + return entity.hasMetadata(WEAPON_DAMAGE_EVENT_METADATA); + } }