Skip to content

Commit

Permalink
オフハンドに別のCMDを割り当てる機能を追加(動かない)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arisa9006 committed Dec 7, 2024
1 parent cb94e7b commit c48909a
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 2 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@
<version>0.98.11</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.DeeCaaD</groupId>
<artifactId>CrackShotPlus</artifactId>
<version>1.108</version>
<scope>provided</scope>
</dependency>
</dependencies>

<distributionManagement>
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/net/azisaba/leoncsaddon/DualWieldWeaponListener.java
Original file line number Diff line number Diff line change
@@ -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);

}
}
}

}
1 change: 1 addition & 0 deletions src/main/java/net/azisaba/leoncsaddon/LeonCSAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/net/azisaba/leoncsaddon/WeaponConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<PotionEffect> potionEffectList = new ArrayList<>();

Expand All @@ -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));

});
}
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/net/azisaba/leoncsaddon/WeaponConfigData.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public class WeaponConfigData {
public final int reduceEndTick;
public final double reduceDamage;

public WeaponConfigData(String name, List<String> type, boolean isMain, List<String> 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<PotionEffect> potionEffectList){
public final Integer dualWieldWeaponCMD;

public WeaponConfigData(String name, List<String> type, boolean isMain, List<String> 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<PotionEffect> potionEffectList){
this.type = type;
this.isMain = isMain;
this.requirements = requirements;
Expand All @@ -44,6 +46,7 @@ public WeaponConfigData(String name, List<String> type, boolean isMain, List<Str
this.reduceDamage = reduceDamage;
this.projectileSizeXZ = projectileSizeXZ;
this.projectileSizeY = projectileSizeY;
this.dualWieldWeaponCMD = dualWieldWeaponCMD;
this.allyPotion = potionEffectList;
}

Expand Down

0 comments on commit c48909a

Please sign in to comment.