-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/net/azisaba/leoncsaddon/DualWieldWeaponListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters