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

WeaponMechanicsのバージョンを更新 (3.1.1 → 3.3.1) #46

Merged
merged 1 commit into from
Mar 6, 2024
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
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Binary file removed libs/MechanicsCore-3.1.2.jar
Binary file not shown.
Binary file added libs/MechanicsCore-3.3.1.jar
Binary file not shown.
Binary file removed libs/WeaponMechanics-3.1.1.jar
Binary file not shown.
Binary file added libs/WeaponMechanics-3.3.1.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -20,6 +21,11 @@
*/
public class WeaponMechanicsUtils {

/**
* 銃ダメージイベントの間だけ付与されるメタデータ名
*/
private static final String WEAPON_DAMAGE_EVENT_METADATA = "doing-weapon-damage";

private WeaponMechanicsUtils() {
throw new AssertionError();
}
Expand All @@ -42,7 +48,7 @@ public static Optional<BoundingBox> 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();
Expand Down Expand Up @@ -89,4 +95,17 @@ public static Optional<BoundingBox> getDamagePointBox(@NotNull LivingEntity livi

return Optional.ofNullable(ret);
}

/**
* 銃のダメージイベントかどうか確認<br/>
* 銃ダメージでのイベント中のみ特定のメタデータが付与される仕様<br/>
* もし今後この仕様が変更された場合は、{@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);
}
}
Loading