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

inventory関連のエラー対処 #178

Merged
merged 1 commit into from
Nov 1, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.event.player.*;
import org.bukkit.inventory.CraftingInventory;
Expand Down Expand Up @@ -695,12 +696,11 @@ public void onInventoryClick(InventoryClickEvent event){
if(event.getWhoClicked() instanceof Player player){
new EquipmentLimit().debuffEquipmentLimit(player);
int destinationSlot = event.getRawSlot();
int slot = event.getSlot();
ItemStack item = event.getCurrentItem();

if(item != null && item.hasItemMeta()){
Gun newGun = Gun.getGun(item);
if(newGun != null){
player.getInventory().setItem(slot, null);
return;
}
}
Expand All @@ -719,14 +719,15 @@ public void onInventoryClick(InventoryClickEvent event){
return;
}

if(destinationSlot == 45){
if(event.getInventory().getType().equals(InventoryType.CRAFTING) && destinationSlot == 45){
// オフハンド
Message.sendWarningMessage(player, "[武器AI]", "オフハンドに武器を持つことはできません。");
event.setCancelled(true);
player.getInventory().addItem(oldItem);
return;
}
if(destinationSlot <= 35) {

if(!event.getSlotType().equals(InventoryType.SlotType.QUICKBAR)){
return;
}

Expand All @@ -748,8 +749,10 @@ public void onInventoryClick(InventoryClickEvent event){

if(gun.getEquipmentType() == GunType.PRIMARY && !result[0]){
new EquipmentLimit().setEquipmentEffect(player, true);
Message.sendWarningMessage(player, "[武器AI]", "プライマリの所持制限を超えています。");
}else if(gun.getEquipmentType() == GunType.SECONDARY && !result[1]){
new EquipmentLimit().setEquipmentEffect(player, true);
Message.sendWarningMessage(player, "[武器AI]", "セカンダリの所持制限を超えています。");
}
}
}
Expand Down