Skip to content

Commit

Permalink
shootlimitlandmine
Browse files Browse the repository at this point in the history
  • Loading branch information
matsu1213 committed Jun 23, 2024
1 parent bafc089 commit 41fde80
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.azisaba.leoncsaddon;

import com.shampaggon.crackshot.CSUtility;
import com.shampaggon.crackshot.events.WeaponPlaceMineEvent;
import com.shampaggon.crackshot.events.WeaponPreShootEvent;
import com.shampaggon.crackshot.events.WeaponPrepareShootEvent;
import org.bukkit.event.EventHandler;
Expand All @@ -21,7 +22,7 @@ public void onPreShoot(WeaponPrepareShootEvent e){
if(weaponTitle != null){
WeaponConfigData otherData = LeonCSAddon.INSTANCE.getWeaponConfig().getWeaponConfigData(weaponTitle);
if(otherData != null && otherData.isMain){
if(Collections.disjoint(data.requirements, otherData.type)){
if(data.requirements != null && otherData.type != null && Collections.disjoint(data.requirements, otherData.type)){
e.setCancelled(true);
}
}
Expand All @@ -30,4 +31,24 @@ public void onPreShoot(WeaponPrepareShootEvent e){
}
}

@EventHandler
public void onPlaceLandmine(WeaponPlaceMineEvent e){
WeaponConfigData data = LeonCSAddon.INSTANCE.getWeaponConfig().getWeaponConfigData(e.getWeaponTitle());
if(data != null && !data.isMain){
for(int i = 0; i < 9; i++){
ItemStack item = e.getPlayer().getInventory().getItem(i);
String weaponTitle = new CSUtility().getWeaponTitle(item);
if(weaponTitle != null){
WeaponConfigData otherData = LeonCSAddon.INSTANCE.getWeaponConfig().getWeaponConfigData(weaponTitle);
if(otherData != null && otherData.isMain){
if(data.requirements != null && otherData.type != null && Collections.disjoint(data.requirements, otherData.type)){
e.getMine().remove();
}
}
}
}
}
}
}

}

0 comments on commit 41fde80

Please sign in to comment.