diff --git a/pom.xml b/pom.xml index 1f72836..dc20d67 100644 --- a/pom.xml +++ b/pom.xml @@ -79,6 +79,12 @@ 0.98.11 provided + + me.DeeCaaD + CrackShotPlus + 1.108 + provided + diff --git a/src/main/java/net/azisaba/leoncsaddon/DualWieldWeaponListener.java b/src/main/java/net/azisaba/leoncsaddon/DualWieldWeaponListener.java new file mode 100644 index 0000000..4dfe29c --- /dev/null +++ b/src/main/java/net/azisaba/leoncsaddon/DualWieldWeaponListener.java @@ -0,0 +1,40 @@ +package net.azisaba.leoncsaddon; + +import com.shampaggon.crackshot.CSUtility; +import me.DeeCaaD.CrackShotPlus.Events.WeaponHeldEvent; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerItemHeldEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class DualWieldWeaponListener implements Listener { + + @EventHandler (priority = EventPriority.LOWEST) + public void onChangeItem(PlayerItemHeldEvent e) { + Player player = e.getPlayer(); + ItemStack item = e.getPlayer().getInventory().getItem(e.getNewSlot()); + String weaponTitle = new CSUtility().getWeaponTitle(item); + if(weaponTitle != null){ + WeaponConfigData weaponData = LeonCSAddon.INSTANCE.getWeaponConfig().getWeaponConfigData(weaponTitle); + if(weaponData != null && weaponData.dualWieldWeaponCMD != null){ + Bukkit.getScheduler().runTaskLater(LeonCSAddon.INSTANCE, () -> { + ItemStack offhandItem = player.getInventory().getItemInOffHand(); + if(offhandItem.getType() == Material.AIR){ + Bukkit.getLogger().warning("オフハンドのCMD更新を試みましたが、オフハンドが空です"); + return; + } + ItemMeta meta = offhandItem.getItemMeta(); + meta.setCustomModelData(weaponData.dualWieldWeaponCMD); + offhandItem.setItemMeta(meta); + },20); + + } + } + } + +} diff --git a/src/main/java/net/azisaba/leoncsaddon/LeonCSAddon.java b/src/main/java/net/azisaba/leoncsaddon/LeonCSAddon.java index efe98b0..67a2b3b 100644 --- a/src/main/java/net/azisaba/leoncsaddon/LeonCSAddon.java +++ b/src/main/java/net/azisaba/leoncsaddon/LeonCSAddon.java @@ -19,6 +19,7 @@ public void onEnable() { Bukkit.getPluginManager().registerEvents(new CustomProjectileSizeListener(),this); Bukkit.getPluginManager().registerEvents(new WeaponShootLimitListener(), this); Bukkit.getPluginManager().registerEvents(new WeaponPotionListener(), this); + Bukkit.getPluginManager().registerEvents(new DualWieldWeaponListener(), this); } @Override diff --git a/src/main/java/net/azisaba/leoncsaddon/WeaponConfig.java b/src/main/java/net/azisaba/leoncsaddon/WeaponConfig.java index 3261751..3f5948e 100644 --- a/src/main/java/net/azisaba/leoncsaddon/WeaponConfig.java +++ b/src/main/java/net/azisaba/leoncsaddon/WeaponConfig.java @@ -56,6 +56,8 @@ public void init(){ double reduceDamage = configuration.getDouble(key + ".reduceDamage",0); double projectileSizeXZ = configuration.getDouble(key + ".projectileSize.xz",0); double projectileSizeY = configuration.getDouble(key + ".projectileSize.y",0); + Integer dualWieldWeaponCMD = (Integer) configuration.get(key + ".dualWieldWeaponCMD", null); + String[] allyPotion = configuration.getString(key + ".allypotion", "").split(","); List potionEffectList = new ArrayList<>(); @@ -78,7 +80,7 @@ public void init(){ } } - weaponsMap.put(key,new WeaponConfigData(key, type, isMain, requirements, damage, headshotBonusDamage, criticalBonusDamage, backstabBonusDamage, guardMult, walkSpeed, canSprint, reduceStartTick, reduceEndTick, reduceDamage, projectileSizeXZ, projectileSizeY, potionEffectList)); + weaponsMap.put(key,new WeaponConfigData(key, type, isMain, requirements, damage, headshotBonusDamage, criticalBonusDamage, backstabBonusDamage, guardMult, walkSpeed, canSprint, reduceStartTick, reduceEndTick, reduceDamage, projectileSizeXZ, projectileSizeY, dualWieldWeaponCMD, potionEffectList)); }); } diff --git a/src/main/java/net/azisaba/leoncsaddon/WeaponConfigData.java b/src/main/java/net/azisaba/leoncsaddon/WeaponConfigData.java index 00c3ea7..f65de8d 100644 --- a/src/main/java/net/azisaba/leoncsaddon/WeaponConfigData.java +++ b/src/main/java/net/azisaba/leoncsaddon/WeaponConfigData.java @@ -27,7 +27,9 @@ public class WeaponConfigData { public final int reduceEndTick; public final double reduceDamage; - public WeaponConfigData(String name, List type, boolean isMain, List requirements, double damage, double headshotBonusDamage, double criticalBonusDamage, double backstabBonusDamage, double guardMult, float walkSpeed, boolean canSprint, int reduceStartTick, int reduceEndTick, double reduceDamage, double projectileSizeXZ, double projectileSizeY, List potionEffectList){ + public final Integer dualWieldWeaponCMD; + + public WeaponConfigData(String name, List type, boolean isMain, List requirements, double damage, double headshotBonusDamage, double criticalBonusDamage, double backstabBonusDamage, double guardMult, float walkSpeed, boolean canSprint, int reduceStartTick, int reduceEndTick, double reduceDamage, double projectileSizeXZ, double projectileSizeY, Integer dualWieldWeaponCMD, List potionEffectList){ this.type = type; this.isMain = isMain; this.requirements = requirements; @@ -44,6 +46,7 @@ public WeaponConfigData(String name, List type, boolean isMain, List