mirror of
https://github.com/songoda/UltimateStacker.git
synced 2025-01-05 23:37:44 +01:00
Merge branch 'development'
This commit is contained in:
commit
6ccc329bf3
6
pom.xml
6
pom.xml
@ -2,7 +2,7 @@
|
|||||||
<groupId>com.songoda</groupId>
|
<groupId>com.songoda</groupId>
|
||||||
<artifactId>UltimateStacker</artifactId>
|
<artifactId>UltimateStacker</artifactId>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<version>1.10.23</version>
|
<version>1.11</version>
|
||||||
<build>
|
<build>
|
||||||
<defaultGoal>clean install</defaultGoal>
|
<defaultGoal>clean install</defaultGoal>
|
||||||
<finalName>UltimateStacker-${project.version}</finalName>
|
<finalName>UltimateStacker-${project.version}</finalName>
|
||||||
@ -105,8 +105,8 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.14.4-R0.1-SNAPSHOT</version>
|
<version>1.15</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -108,15 +108,15 @@ public class DeathListeners implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityHit(EntityDamageByEntityEvent event) {
|
public void onEntityHit(EntityDamageByEntityEvent event) {
|
||||||
if (!(event.getDamager() instanceof Player)) return;
|
if (!(event.getDamager() instanceof Player) || ServerVersion.isServerVersionAtOrBelow(ServerVersion.V1_12)) return;
|
||||||
if (!instance.getEntityStackManager().isStacked(event.getEntity())) return;
|
if (!instance.getEntityStackManager().isStacked(event.getEntity())) return;
|
||||||
EntityStack stack = instance.getEntityStackManager().getStack(event.getEntity());
|
EntityStack stack = instance.getEntityStackManager().getStack(event.getEntity());
|
||||||
|
|
||||||
if (Settings.KILL_WHOLE_STACK_ON_DEATH.getBoolean() && Settings.REALISTIC_DAMAGE.getBoolean()) {
|
if (Settings.KILL_WHOLE_STACK_ON_DEATH.getBoolean() && Settings.REALISTIC_DAMAGE.getBoolean()) {
|
||||||
Player player = (Player) event.getDamager();
|
Player player = (Player) event.getDamager();
|
||||||
ItemStack tool = player.getInventory().getItemInHand();
|
ItemStack tool = player.getInventory().getItemInHand();
|
||||||
if (tool.getType().getMaxDurability() < 1 || (tool.getItemMeta() != null && (tool.getItemMeta().spigot().isUnbreakable()
|
if (tool.getType().getMaxDurability() < 1 || (tool.getItemMeta() != null && (tool.getItemMeta().isUnbreakable()
|
||||||
|| (ServerProject.isServer(ServerProject.SPIGOT, ServerProject.PAPER) && tool.getItemMeta().spigot().isUnbreakable()))))
|
|| (ServerProject.isServer(ServerProject.SPIGOT, ServerProject.PAPER) && tool.getItemMeta().isUnbreakable()))))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int unbreakingLevel = tool.getEnchantmentLevel(Enchantment.DURABILITY);
|
int unbreakingLevel = tool.getEnchantmentLevel(Enchantment.DURABILITY);
|
||||||
|
@ -32,6 +32,9 @@ public class StackingTask extends BukkitRunnable {
|
|||||||
private final int minEntityStackSize = Settings.MIN_STACK_ENTITIES.getInt();
|
private final int minEntityStackSize = Settings.MIN_STACK_ENTITIES.getInt();
|
||||||
private final int maxPerTypeStacksPerChunk = Settings.MAX_PER_TYPE_STACKS_PER_CHUNK.getInt();
|
private final int maxPerTypeStacksPerChunk = Settings.MAX_PER_TYPE_STACKS_PER_CHUNK.getInt();
|
||||||
private final List<String> disabledWorlds = Settings.DISABLED_WORLDS.getStringList();
|
private final List<String> disabledWorlds = Settings.DISABLED_WORLDS.getStringList();
|
||||||
|
private final boolean onlyStackFromSpawners = Settings.ONLY_STACK_FROM_SPAWNERS.getBoolean();
|
||||||
|
private final List<String> stackReasons = Settings.STACK_REASONS.getStringList();
|
||||||
|
private final boolean onlyStackOnSurface = Settings.ONLY_STACK_ON_SURFACE.getBoolean();
|
||||||
|
|
||||||
public StackingTask(UltimateStacker plugin) {
|
public StackingTask(UltimateStacker plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
@ -59,8 +62,10 @@ public class StackingTask extends BukkitRunnable {
|
|||||||
for (Entity entity : entities) {
|
for (Entity entity : entities) {
|
||||||
// Get entity location to pass around as its faster this way.
|
// Get entity location to pass around as its faster this way.
|
||||||
Location location = entity.getLocation();
|
Location location = entity.getLocation();
|
||||||
|
|
||||||
// Check to see if entity is stackable.
|
// Check to see if entity is stackable.
|
||||||
if (!isEntityStackable(entity, location)) continue;
|
if (!isEntityStackable(entity, location)) continue;
|
||||||
|
|
||||||
// Make sure our entity has not already been processed.
|
// Make sure our entity has not already been processed.
|
||||||
// Skip it if it has been.
|
// Skip it if it has been.
|
||||||
if (this.processed.contains(entity.getUniqueId())) continue;
|
if (this.processed.contains(entity.getUniqueId())) continue;
|
||||||
@ -99,11 +104,11 @@ public class StackingTask extends BukkitRunnable {
|
|||||||
final String spawnReason = entity.hasMetadata("US_REASON") && !entity.getMetadata("US_REASON").isEmpty()
|
final String spawnReason = entity.hasMetadata("US_REASON") && !entity.getMetadata("US_REASON").isEmpty()
|
||||||
? entity.getMetadata("US_REASON").get(0).asString() : null;
|
? entity.getMetadata("US_REASON").get(0).asString() : null;
|
||||||
List<String> stackReasons;
|
List<String> stackReasons;
|
||||||
if (Settings.ONLY_STACK_FROM_SPAWNERS.getBoolean()) {
|
if (onlyStackFromSpawners) {
|
||||||
// If only stack from spawners is enabled, make sure the entity spawned from a spawner.
|
// If only stack from spawners is enabled, make sure the entity spawned from a spawner.
|
||||||
if (!"SPAWNER".equals(spawnReason))
|
if (!"SPAWNER".equals(spawnReason))
|
||||||
return false;
|
return false;
|
||||||
} else if (!(stackReasons = Settings.STACK_REASONS.getStringList()).isEmpty() && !stackReasons.contains(spawnReason))
|
} else if (!(stackReasons = this.stackReasons).isEmpty() && !stackReasons.contains(spawnReason))
|
||||||
// Only stack if on the list of events to stack
|
// Only stack if on the list of events to stack
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -111,7 +116,7 @@ public class StackingTask extends BukkitRunnable {
|
|||||||
LivingEntity livingEntity = (LivingEntity) entity;
|
LivingEntity livingEntity = (LivingEntity) entity;
|
||||||
|
|
||||||
// If only stack on surface is enabled make sure the entity is on a surface then entity is stackable.
|
// If only stack on surface is enabled make sure the entity is on a surface then entity is stackable.
|
||||||
return !Settings.ONLY_STACK_ON_SURFACE.getBoolean()
|
return !onlyStackOnSurface
|
||||||
|| Methods.canFly(livingEntity)
|
|| Methods.canFly(livingEntity)
|
||||||
|| entity.getType().name().equals("SHULKER")
|
|| entity.getType().name().equals("SHULKER")
|
||||||
|| (livingEntity.isOnGround() || location.getBlock().isLiquid());
|
|| (livingEntity.isOnGround() || location.getBlock().isLiquid());
|
||||||
|
@ -119,6 +119,7 @@ public class Methods {
|
|||||||
case BLAZE:
|
case BLAZE:
|
||||||
case PHANTOM:
|
case PHANTOM:
|
||||||
case BAT:
|
case BAT:
|
||||||
|
case BEE:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user