mirror of
https://github.com/songoda/UltimateStacker.git
synced 2025-01-03 22:37:41 +01:00
Added option to not count weapons as equipment.
This commit is contained in:
parent
cd6e2753b5
commit
23d846f937
@ -145,6 +145,11 @@ public class Settings {
|
|||||||
"With this enabled any metadata assigned from supported plugins such",
|
"With this enabled any metadata assigned from supported plugins such",
|
||||||
"as EpicSpawners and mcMMO will be preserved when the entity is killed.");
|
"as EpicSpawners and mcMMO will be preserved when the entity is killed.");
|
||||||
|
|
||||||
|
public static final ConfigSetting WEAPONS_ARENT_EQUIPMENT = new ConfigSetting(config, "Entities.Weapons Arent Equipment", false,
|
||||||
|
"This allows entities holding weapons to stack. Enchanted weapons are excluded.",
|
||||||
|
"If you would like to disable the stacked entity check you can do that by removing",
|
||||||
|
"\"HAS_EQUIPMENT\", from the list above.");
|
||||||
|
|
||||||
public static final ConfigSetting ONLY_STACK_ON_SURFACE = new ConfigSetting(config, "Entities.Only Stack On Surface", true,
|
public static final ConfigSetting ONLY_STACK_ON_SURFACE = new ConfigSetting(config, "Entities.Only Stack On Surface", true,
|
||||||
"Should entities only be stacked if they are touching the ground",
|
"Should entities only be stacked if they are touching the ground",
|
||||||
"or swimming? This does not effect flying entities.");
|
"or swimming? This does not effect flying entities.");
|
||||||
|
@ -10,6 +10,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.*;
|
||||||
|
import org.bukkit.inventory.EntityEquipment;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -19,10 +20,11 @@ public class EntityUtils {
|
|||||||
UltimateStacker plugin = UltimateStacker.getInstance();
|
UltimateStacker plugin = UltimateStacker.getInstance();
|
||||||
|
|
||||||
private final List<String> checks = Settings.STACK_CHECKS.getStringList();
|
private final List<String> checks = Settings.STACK_CHECKS.getStringList();
|
||||||
private final boolean stackFlyingDown = Settings.ONLY_STACK_FLYING_DOWN.getBoolean();
|
private final boolean stackFlyingDown = Settings.ONLY_STACK_FLYING_DOWN.getBoolean(),
|
||||||
private final boolean keepFire = Settings.KEEP_FIRE.getBoolean();
|
keepFire = Settings.KEEP_FIRE.getBoolean(),
|
||||||
private final boolean keepPotion = Settings.KEEP_POTION.getBoolean();
|
keepPotion = Settings.KEEP_POTION.getBoolean(),
|
||||||
private final boolean stackWholeChunk = Settings.STACK_WHOLE_CHUNK.getBoolean();
|
stackWholeChunk = Settings.STACK_WHOLE_CHUNK.getBoolean(),
|
||||||
|
weaponsArentEquipment = Settings.WEAPONS_ARENT_EQUIPMENT.getBoolean();
|
||||||
private final int searchRadius = Settings.SEARCH_RADIUS.getInt();
|
private final int searchRadius = Settings.SEARCH_RADIUS.getInt();
|
||||||
|
|
||||||
private final Map<CachedChunk, Entity[]> cachedChunks = new HashMap<>();
|
private final Map<CachedChunk, Entity[]> cachedChunks = new HashMap<>();
|
||||||
@ -503,16 +505,15 @@ public class EntityUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEquipped(LivingEntity initialEntity) {
|
public boolean isEquipped(LivingEntity initialEntity) {
|
||||||
return initialEntity.getEquipment() != null
|
if (initialEntity.getEquipment() == null) return false;
|
||||||
&& (initialEntity.getEquipment().getItemInHand().getType() != Material.AIR
|
EntityEquipment equipment = initialEntity.getEquipment();
|
||||||
|| (initialEntity.getEquipment().getHelmet() != null
|
|
||||||
&& initialEntity.getEquipment().getHelmet().getType() != Material.AIR)
|
return (equipment.getItemInHand().getType() != Material.AIR
|
||||||
|| (initialEntity.getEquipment().getChestplate() != null
|
&& !weaponsArentEquipment && !equipment.getItemInHand().getEnchantments().isEmpty()
|
||||||
&& initialEntity.getEquipment().getChestplate().getType() != Material.AIR)
|
|| (equipment.getHelmet() != null && equipment.getHelmet().getType() != Material.AIR)
|
||||||
|| (initialEntity.getEquipment().getLeggings() != null
|
|| (equipment.getChestplate() != null && equipment.getChestplate().getType() != Material.AIR)
|
||||||
&& initialEntity.getEquipment().getLeggings().getType() != Material.AIR)
|
|| (equipment.getLeggings() != null && equipment.getLeggings().getType() != Material.AIR)
|
||||||
|| (initialEntity.getEquipment().getBoots() != null
|
|| (equipment.getBoots() != null && equipment.getBoots().getType() != Material.AIR));
|
||||||
&& initialEntity.getEquipment().getBoots().getType() != Material.AIR));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void splitFromStack(LivingEntity entity) {
|
public void splitFromStack(LivingEntity entity) {
|
||||||
|
Loading…
Reference in New Issue
Block a user