Merge branch 'development'

This commit is contained in:
ceze88 2023-05-05 11:20:25 +02:00
commit fde297d9f1
32 changed files with 69 additions and 129 deletions

View File

@ -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>2.4.0</version> <version>2.4.1</version>
<build> <build>
<defaultGoal>clean install</defaultGoal> <defaultGoal>clean install</defaultGoal>
<finalName>UltimateStacker-${project.version}</finalName> <finalName>UltimateStacker-${project.version}</finalName>
@ -122,7 +122,7 @@
<dependency> <dependency>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>SongodaCore</artifactId> <artifactId>SongodaCore</artifactId>
<version>2.6.19</version> <version>2.6.20</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>

View File

@ -30,7 +30,15 @@ import com.songoda.ultimatestacker.database.migrations._3_BlockStacks;
import com.songoda.ultimatestacker.database.migrations._6_RemoveStackedEntityTable; import com.songoda.ultimatestacker.database.migrations._6_RemoveStackedEntityTable;
import com.songoda.ultimatestacker.hook.StackerHook; import com.songoda.ultimatestacker.hook.StackerHook;
import com.songoda.ultimatestacker.hook.hooks.JobsHook; import com.songoda.ultimatestacker.hook.hooks.JobsHook;
import com.songoda.ultimatestacker.listeners.*; import com.songoda.ultimatestacker.listeners.BlockListeners;
import com.songoda.ultimatestacker.listeners.BreedListeners;
import com.songoda.ultimatestacker.listeners.ClearLagListeners;
import com.songoda.ultimatestacker.listeners.DeathListeners;
import com.songoda.ultimatestacker.listeners.InteractListeners;
import com.songoda.ultimatestacker.listeners.ShearListeners;
import com.songoda.ultimatestacker.listeners.SheepDyeListeners;
import com.songoda.ultimatestacker.listeners.SpawnerListeners;
import com.songoda.ultimatestacker.listeners.TameListeners;
import com.songoda.ultimatestacker.listeners.entity.EntityCurrentListener; import com.songoda.ultimatestacker.listeners.entity.EntityCurrentListener;
import com.songoda.ultimatestacker.listeners.entity.EntityListeners; import com.songoda.ultimatestacker.listeners.entity.EntityListeners;
import com.songoda.ultimatestacker.listeners.item.ItemCurrentListener; import com.songoda.ultimatestacker.listeners.item.ItemCurrentListener;
@ -49,13 +57,11 @@ import com.songoda.ultimatestacker.stackable.spawner.SpawnerStackManager;
import com.songoda.ultimatestacker.tasks.StackingTask; import com.songoda.ultimatestacker.tasks.StackingTask;
import com.songoda.ultimatestacker.utils.Async; import com.songoda.ultimatestacker.utils.Async;
import com.songoda.ultimatestacker.utils.Methods; import com.songoda.ultimatestacker.utils.Methods;
import io.lumine.mythic.bukkit.listeners.ChunkListeners;
import org.apache.commons.lang.WordUtils; import org.apache.commons.lang.WordUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -67,7 +73,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.Set; import java.util.Set;
public class UltimateStacker extends SongodaPlugin { public class UltimateStacker extends SongodaPlugin {

View File

@ -4,7 +4,6 @@ import com.songoda.core.commands.AbstractCommand;
import com.songoda.core.gui.GuiManager; import com.songoda.core.gui.GuiManager;
import com.songoda.core.utils.TextUtils; import com.songoda.core.utils.TextUtils;
import com.songoda.ultimatestacker.gui.GUIConvert; import com.songoda.ultimatestacker.gui.GUIConvert;
import com.songoda.ultimatestacker.utils.Methods;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -5,7 +5,6 @@ import com.songoda.core.utils.TextUtils;
import com.songoda.ultimatestacker.UltimateStacker; import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.stackable.entity.EntityStack; import com.songoda.ultimatestacker.stackable.entity.EntityStack;
import com.songoda.ultimatestacker.stackable.entity.EntityStackManager; import com.songoda.ultimatestacker.stackable.entity.EntityStackManager;
import com.songoda.ultimatestacker.utils.Methods;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -4,9 +4,6 @@ import com.songoda.core.commands.AbstractCommand;
import com.songoda.core.utils.TextUtils; import com.songoda.core.utils.TextUtils;
import com.songoda.ultimatestacker.UltimateStacker; import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.stackable.entity.EntityStack; import com.songoda.ultimatestacker.stackable.entity.EntityStack;
import com.songoda.ultimatestacker.utils.Methods;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -14,7 +11,6 @@ import org.bukkit.entity.Player;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**

View File

@ -1,13 +1,9 @@
package com.songoda.ultimatestacker.convert; package com.songoda.ultimatestacker.convert;
import com.songoda.ultimatestacker.UltimateStacker; import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.stackable.entity.EntityStackManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import uk.antiperson.stackmob.StackMob; import uk.antiperson.stackmob.StackMob;
import java.util.Map;
import java.util.UUID;
public class StackMobConvert implements Convert { public class StackMobConvert implements Convert {
private final UltimateStacker plugin; private final UltimateStacker plugin;

View File

@ -2,19 +2,12 @@ package com.songoda.ultimatestacker.convert;
import com.bgsoftware.wildstacker.api.WildStackerAPI; import com.bgsoftware.wildstacker.api.WildStackerAPI;
import com.bgsoftware.wildstacker.api.objects.StackedSpawner; import com.bgsoftware.wildstacker.api.objects.StackedSpawner;
import com.songoda.core.database.DatabaseConnector;
import com.songoda.core.database.SQLiteConnector;
import com.songoda.ultimatestacker.UltimateStacker; import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.stackable.entity.EntityStackManager;
import com.songoda.ultimatestacker.stackable.spawner.SpawnerStack; import com.songoda.ultimatestacker.stackable.spawner.SpawnerStack;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.UUID;
public class WildStackerConvert implements Convert { public class WildStackerConvert implements Convert {
private Plugin wildStacker; private Plugin wildStacker;

View File

@ -4,28 +4,21 @@ import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.database.DataManagerAbstract; import com.songoda.core.database.DataManagerAbstract;
import com.songoda.core.database.DatabaseConnector; import com.songoda.core.database.DatabaseConnector;
import com.songoda.core.database.DatabaseType; import com.songoda.core.database.DatabaseType;
import com.songoda.ultimatestacker.settings.Settings;
import com.songoda.ultimatestacker.stackable.block.BlockStack; import com.songoda.ultimatestacker.stackable.block.BlockStack;
import com.songoda.ultimatestacker.stackable.entity.EntityStack;
import com.songoda.ultimatestacker.stackable.entity.StackedEntity;
import com.songoda.ultimatestacker.stackable.spawner.SpawnerStack; import com.songoda.ultimatestacker.stackable.spawner.SpawnerStack;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.checkerframework.common.returnsreceiver.qual.This;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID;
import java.util.function.Consumer; import java.util.function.Consumer;
public class DataManager extends DataManagerAbstract { public class DataManager extends DataManagerAbstract {

View File

@ -4,9 +4,7 @@ import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.gui.Gui; import com.songoda.core.gui.Gui;
import com.songoda.core.gui.GuiUtils; import com.songoda.core.gui.GuiUtils;
import com.songoda.core.utils.TextUtils; import com.songoda.core.utils.TextUtils;
import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.convert.Convert; import com.songoda.ultimatestacker.convert.Convert;
import com.songoda.ultimatestacker.utils.Methods;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -3,7 +3,6 @@ package com.songoda.ultimatestacker.listeners;
import com.songoda.core.compatibility.CompatibleHand; import com.songoda.core.compatibility.CompatibleHand;
import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.hooks.ProtectionManager; import com.songoda.core.hooks.ProtectionManager;
import com.songoda.core.hooks.protection.BentoBoxProtection;
import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem; import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem;
import com.songoda.ultimatestacker.UltimateStacker; import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.events.SpawnerBreakEvent; import com.songoda.ultimatestacker.events.SpawnerBreakEvent;
@ -13,7 +12,6 @@ import com.songoda.ultimatestacker.stackable.block.BlockStack;
import com.songoda.ultimatestacker.stackable.block.BlockStackManager; import com.songoda.ultimatestacker.stackable.block.BlockStackManager;
import com.songoda.ultimatestacker.stackable.spawner.SpawnerStack; import com.songoda.ultimatestacker.stackable.spawner.SpawnerStack;
import com.songoda.ultimatestacker.utils.Methods; import com.songoda.ultimatestacker.utils.Methods;
import io.lumine.mythic.bukkit.utils.menu.ClickAction;
import org.apache.commons.lang.math.NumberUtils; import org.apache.commons.lang.math.NumberUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -35,7 +33,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockStateMeta; import org.bukkit.inventory.meta.BlockStateMeta;
import java.util.List; import java.util.List;
import java.util.Map;
public class BlockListeners implements Listener { public class BlockListeners implements Listener {

View File

@ -3,7 +3,6 @@ package com.songoda.ultimatestacker.listeners;
import com.songoda.ultimatestacker.UltimateStacker; import com.songoda.ultimatestacker.UltimateStacker;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityBreedEvent; import org.bukkit.event.entity.EntityBreedEvent;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
@ -16,7 +15,7 @@ public class BreedListeners implements Listener {
this.plugin = plugin; this.plugin = plugin;
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler
public void onBread(EntityBreedEvent event) { public void onBread(EntityBreedEvent event) {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> { Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
event.getFather().removeMetadata("breedCooldown", plugin); event.getFather().removeMetadata("breedCooldown", plugin);

View File

@ -13,12 +13,10 @@ import org.bukkit.GameRule;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.ChestedHorse; import org.bukkit.entity.ChestedHorse;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
@ -47,7 +45,7 @@ public class DeathListeners implements Listener {
private final Map<UUID, List<ItemStack>> finalItems = new HashMap<>(); private final Map<UUID, List<ItemStack>> finalItems = new HashMap<>();
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler
public void onEntityDamage(EntityDamageEvent event) { public void onEntityDamage(EntityDamageEvent event) {
if (!(event.getEntity() instanceof LivingEntity)) if (!(event.getEntity() instanceof LivingEntity))
return; return;
@ -58,42 +56,44 @@ public class DeathListeners implements Listener {
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler
public void onEntityDeath(EntityDeathEvent event) { public void onEntityDeath(EntityDeathEvent event) {
boolean custom = Settings.CUSTOM_DROPS.getBoolean();
if (!custom) return; //Compatibility with other plugins
LivingEntity entity = event.getEntity(); LivingEntity entity = event.getEntity();
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
&& !entity.getWorld().getGameRuleValue(GameRule.DO_MOB_LOOT)) {
return;
}
if (event.getEntityType() == EntityType.PLAYER if (event.getEntityType() == EntityType.PLAYER
|| event.getEntityType() == EntityType.ARMOR_STAND) return; || event.getEntityType() == EntityType.ARMOR_STAND) return;
//Respect MythicMobs //Respect MythicMobs
if (plugin.getCustomEntityManager().isCustomEntity(entity)) return; if (plugin.getCustomEntityManager().isCustomEntity(entity)) return;
boolean custom = Settings.CUSTOM_DROPS.getBoolean();
List<Drop> drops = custom ? plugin.getLootablesManager().getDrops(event.getEntity())
: event.getDrops().stream().map(Drop::new).collect(Collectors.toList());
if (custom) { List<Drop> drops = plugin.getLootablesManager().getDrops(event.getEntity());
for (ItemStack item : new ArrayList<>(event.getDrops())) {
if (shouldDrop(event.getEntity(), item.getType())) for (ItemStack item : new ArrayList<>(event.getDrops())) {
drops.add(new Drop(item)); if (shouldDrop(event.getEntity(), item.getType()))
} drops.add(new Drop(item));
} }
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
&& !entity.getWorld().getGameRuleValue(GameRule.DO_MOB_LOOT))
drops.clear();
if (plugin.getCustomEntityManager().getCustomEntity(entity) == null) { if (plugin.getCustomEntityManager().getCustomEntity(entity) == null) {
//replace %player% in drop commands with the last player to damage the entity //replace %player% in drop commands with the last player to damage the entity
//Run commands here, or it will be buggy //Run commands here, or it will be buggy
runCommands(entity, drops); runCommands(entity, drops);
if (plugin.getEntityStackManager().isStackedEntity(event.getEntity())) { if (plugin.getEntityStackManager().isStackedEntity(event.getEntity())) {
plugin.getEntityStackManager().getStack(event.getEntity()).onDeath(entity, drops, custom, event.getDroppedExp(), event); plugin.getEntityStackManager().getStack(event.getEntity()).onDeath(entity, drops, true, event.getDroppedExp(), event);
} else { } else {
DropUtils.processStackedDrop(event.getEntity(), drops, event); DropUtils.processStackedDrop(event.getEntity(), drops, event);
} }
} }
finalItems.remove(entity.getUniqueId()); finalItems.remove(entity.getUniqueId());
} }

View File

@ -16,7 +16,6 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Wolf; import org.bukkit.entity.Wolf;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -30,7 +29,7 @@ public class InteractListeners implements Listener {
this.plugin = plugin; this.plugin = plugin;
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler
public void onInteract(PlayerInteractAtEntityEvent event) { public void onInteract(PlayerInteractAtEntityEvent event) {
if (!(event.getRightClicked() instanceof LivingEntity)) return; if (!(event.getRightClicked() instanceof LivingEntity)) return;
Player player = event.getPlayer(); Player player = event.getPlayer();

View File

@ -15,7 +15,6 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.MushroomCow; import org.bukkit.entity.MushroomCow;
import org.bukkit.entity.Sheep; import org.bukkit.entity.Sheep;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerShearEntityEvent; import org.bukkit.event.player.PlayerShearEntityEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -30,7 +29,7 @@ public class ShearListeners implements Listener {
this.plugin = plugin; this.plugin = plugin;
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler
public void onShear(PlayerShearEntityEvent event) { public void onShear(PlayerShearEntityEvent event) {
LivingEntity entity = (LivingEntity)event.getEntity(); LivingEntity entity = (LivingEntity)event.getEntity();

View File

@ -7,7 +7,6 @@ import com.songoda.ultimatestacker.stackable.entity.EntityStackManager;
import com.songoda.ultimatestacker.stackable.entity.Split; import com.songoda.ultimatestacker.stackable.entity.Split;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.SheepDyeWoolEvent; import org.bukkit.event.entity.SheepDyeWoolEvent;
@ -19,7 +18,7 @@ public class SheepDyeListeners implements Listener {
this.plugin = plugin; this.plugin = plugin;
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler
public void onDye(SheepDyeWoolEvent event) { public void onDye(SheepDyeWoolEvent event) {
LivingEntity entity = event.getEntity(); LivingEntity entity = event.getEntity();

View File

@ -51,7 +51,6 @@ public class SpawnerListeners implements Listener {
if (entity.getType() == EntityType.FIREWORK) return; if (entity.getType() == EntityType.FIREWORK) return;
if (entity.getVehicle() != null) { if (entity.getVehicle() != null) {
entity.getVehicle().remove(); entity.getVehicle().remove();
entity.remove();
} }
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) { if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) {
@ -59,16 +58,16 @@ public class SpawnerListeners implements Listener {
for (Entity e : entity.getPassengers()) { for (Entity e : entity.getPassengers()) {
e.remove(); e.remove();
} }
entity.remove();
} }
} }
entity.remove();
Location location = event.getSpawner().getLocation(); Location location = event.getSpawner().getLocation();
SpawnerStack spawnerStack = spawnerStackManager.getSpawner(location); SpawnerStack spawnerStack = spawnerStackManager.getSpawner(location);
int amountToSpawn = spawnerStack.calculateSpawnCount(); int amountToSpawn = spawnerStack.calculateSpawnCount(entity.getType());
if (amountToSpawn <= 1) return;
entity.remove();
spawnerStack.spawn(amountToSpawn, "EXPLOSION_NORMAL", null, (e) -> { spawnerStack.spawn(amountToSpawn, "EXPLOSION_NORMAL", null, (e) -> {
if (Settings.NO_AI.getBoolean()) if (Settings.NO_AI.getBoolean())

View File

@ -5,7 +5,6 @@ import com.songoda.ultimatestacker.stackable.entity.EntityStack;
import com.songoda.ultimatestacker.stackable.entity.EntityStackManager; import com.songoda.ultimatestacker.stackable.entity.EntityStackManager;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityTameEvent; import org.bukkit.event.entity.EntityTameEvent;
@ -17,7 +16,7 @@ public class TameListeners implements Listener {
this.plugin = plugin; this.plugin = plugin;
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler
public void onTame(EntityTameEvent event) { public void onTame(EntityTameEvent event) {
LivingEntity entity = event.getEntity(); LivingEntity entity = event.getEntity();

View File

@ -1,21 +1,12 @@
package com.songoda.ultimatestacker.listeners.entity; package com.songoda.ultimatestacker.listeners.entity;
import com.songoda.ultimatestacker.UltimateStacker; import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.settings.Settings;
import com.songoda.ultimatestacker.stackable.entity.EntityStack; import com.songoda.ultimatestacker.stackable.entity.EntityStack;
import com.songoda.ultimatestacker.stackable.entity.EntityStackManager; import com.songoda.ultimatestacker.stackable.entity.EntityStackManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityTransformEvent; import org.bukkit.event.entity.EntityTransformEvent;
import org.bukkit.event.world.EntitiesLoadEvent;
import java.util.Arrays;
import java.util.List;
public class EntityCurrentListener implements Listener { public class EntityCurrentListener implements Listener {
@ -25,7 +16,7 @@ public class EntityCurrentListener implements Listener {
this.plugin = plugin; this.plugin = plugin;
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler
public void onSpawn(EntityTransformEvent event) { public void onSpawn(EntityTransformEvent event) {
EntityStackManager stackManager = plugin.getEntityStackManager(); EntityStackManager stackManager = plugin.getEntityStackManager();
if (stackManager.isStackedEntity(event.getEntity()) if (stackManager.isStackedEntity(event.getEntity())

View File

@ -22,7 +22,10 @@ import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.*; import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -39,7 +42,7 @@ public class EntityListeners implements Listener {
this.plugin = plugin; this.plugin = plugin;
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler
public void onEgg(ItemSpawnEvent event) { public void onEgg(ItemSpawnEvent event) {
Material material = event.getEntity().getItemStack().getType(); Material material = event.getEntity().getItemStack().getType();
if (material != Material.EGG if (material != Material.EGG
@ -92,7 +95,7 @@ public class EntityListeners implements Listener {
} }
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler
public void onSpawn(CreatureSpawnEvent event) { public void onSpawn(CreatureSpawnEvent event) {
event.getEntity().setMetadata("US_REASON", new FixedMetadataValue(plugin, event.getSpawnReason().name())); event.getEntity().setMetadata("US_REASON", new FixedMetadataValue(plugin, event.getSpawnReason().name()));
} }

View File

@ -8,14 +8,13 @@ import org.bukkit.entity.Arrow;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityPickupItemEvent; import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class ItemCurrentListener implements Listener { public class ItemCurrentListener implements Listener {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler
public void onPickup(EntityPickupItemEvent event) { public void onPickup(EntityPickupItemEvent event) {
if (!Settings.STACK_ITEMS.getBoolean() || event.getItem() instanceof Arrow) return; if (!Settings.STACK_ITEMS.getBoolean() || event.getItem() instanceof Arrow) return;
// Amount here is not the total amount of item (32 if more than 32) but the amount of item the player can retrieve // Amount here is not the total amount of item (32 if more than 32) but the amount of item the player can retrieve

View File

@ -7,14 +7,13 @@ import com.songoda.ultimatestacker.utils.Methods;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class ItemLegacyListener implements Listener { public class ItemLegacyListener implements Listener {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler
public void onPickup(PlayerPickupItemEvent event) { public void onPickup(PlayerPickupItemEvent event) {
if (!Settings.STACK_ITEMS.getBoolean() || event.getItem() instanceof Arrow) return; if (!Settings.STACK_ITEMS.getBoolean() || event.getItem() instanceof Arrow) return;
// Amount here is not the total amount of item (32 if more than 32) but the amount of item the player can retrieve // Amount here is not the total amount of item (32 if more than 32) but the amount of item the player can retrieve

View File

@ -1,14 +1,14 @@
package com.songoda.ultimatestacker.listeners.item; package com.songoda.ultimatestacker.listeners.item;
import com.songoda.core.utils.BlockUtils; import com.songoda.core.nms.NmsManager;
import com.songoda.ultimatestacker.UltimateStacker; import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.settings.Settings; import com.songoda.ultimatestacker.settings.Settings;
import com.songoda.ultimatestacker.utils.Methods; import com.songoda.ultimatestacker.utils.Methods;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.ItemMergeEvent; import org.bukkit.event.entity.ItemMergeEvent;
import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.entity.ItemSpawnEvent;
@ -58,17 +58,22 @@ public class ItemListeners implements Listener {
event.getEntity().remove(); event.getEntity().remove();
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler
public void onInvPickup(InventoryPickupItemEvent event) { public void onInvPickup(InventoryPickupItemEvent event) {
if (!Settings.STACK_ITEMS.getBoolean() || !UltimateStacker.hasCustomAmount(event.getItem())) return; if (!Settings.STACK_ITEMS.getBoolean() || !UltimateStacker.hasCustomAmount(event.getItem())) {
return;
}
event.setCancelled(true); event.setCancelled(true);
Methods.updateInventory(event.getItem(), event.getInventory()); Methods.updateInventory(event.getItem(), event.getInventory());
if (event.getInventory().getHolder() instanceof BlockState) if (event.getInventory().getHolder() instanceof BlockState) {
BlockUtils.updateAdjacentComparators(((BlockState) event.getInventory().getHolder()).getLocation()); Block invHolder = ((BlockState) event.getInventory().getHolder()).getBlock();
NmsManager.getWorld().updateAdjacentComparators(invHolder);
}
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler
public void onExist(ItemSpawnEvent event) { public void onExist(ItemSpawnEvent event) {
if (!Settings.STACK_ITEMS.getBoolean()) return; if (!Settings.STACK_ITEMS.getBoolean()) return;

View File

@ -11,8 +11,6 @@ import com.songoda.core.lootables.loot.LootManager;
import com.songoda.core.lootables.loot.Lootable; import com.songoda.core.lootables.loot.Lootable;
import com.songoda.ultimatestacker.UltimateStacker; import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.settings.Settings; import com.songoda.ultimatestacker.settings.Settings;
import com.songoda.ultimatestacker.stackable.entity.custom.CustomEntity;
import com.songoda.ultimatestacker.stackable.entity.custom.CustomEntityManager;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Ageable; import org.bukkit.entity.Ageable;
import org.bukkit.entity.Creeper; import org.bukkit.entity.Creeper;

View File

@ -5,7 +5,6 @@ import com.songoda.core.utils.TextUtils;
import com.songoda.ultimatestacker.UltimateStacker; import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.settings.Settings; import com.songoda.ultimatestacker.settings.Settings;
import com.songoda.ultimatestacker.stackable.Hologramable; import com.songoda.ultimatestacker.stackable.Hologramable;
import com.songoda.ultimatestacker.utils.Methods;
import com.songoda.ultimatestacker.utils.Stackable; import com.songoda.ultimatestacker.utils.Stackable;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;

View File

@ -3,18 +3,12 @@ package com.songoda.ultimatestacker.stackable.entity;
import com.songoda.core.compatibility.ServerVersion; import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.lootables.loot.Drop; import com.songoda.core.lootables.loot.Drop;
import com.songoda.core.lootables.loot.DropUtils; import com.songoda.core.lootables.loot.DropUtils;
import com.songoda.core.nms.NmsManager;
import com.songoda.core.nms.nbt.NBTEntity;
import com.songoda.ultimatestacker.UltimateStacker; import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.events.EntityStackKillEvent; import com.songoda.ultimatestacker.events.EntityStackKillEvent;
import com.songoda.ultimatestacker.settings.Settings; import com.songoda.ultimatestacker.settings.Settings;
import com.songoda.ultimatestacker.stackable.entity.custom.CustomEntity;
import com.songoda.ultimatestacker.utils.Async; import com.songoda.ultimatestacker.utils.Async;
import com.songoda.ultimatestacker.utils.Methods;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.ExperienceOrb; import org.bukkit.entity.ExperienceOrb;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
@ -22,11 +16,8 @@ import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.ThreadLocalRandom;
public class EntityStack extends StackedEntity { public class EntityStack extends StackedEntity {

View File

@ -1,21 +1,12 @@
package com.songoda.ultimatestacker.stackable.entity; package com.songoda.ultimatestacker.stackable.entity;
import com.songoda.ultimatestacker.UltimateStacker; import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.utils.Methods;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
public class EntityStackManager { public class EntityStackManager {
@ -132,6 +123,7 @@ public class EntityStackManager {
} }
public void setStack(LivingEntity newEntity, int amount) { public void setStack(LivingEntity newEntity, int amount) {
if (amount <= 0) return;
if (isStackedEntity(newEntity)) { if (isStackedEntity(newEntity)) {
EntityStack stack = getStack(newEntity); EntityStack stack = getStack(newEntity);
stack.setAmount(amount); stack.setAmount(amount);

View File

@ -3,7 +3,6 @@ package com.songoda.ultimatestacker.stackable.entity;
import com.songoda.ultimatestacker.UltimateStacker; import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.settings.Settings; import com.songoda.ultimatestacker.settings.Settings;
import com.songoda.ultimatestacker.utils.Methods; import com.songoda.ultimatestacker.utils.Methods;
import org.bukkit.Bukkit;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;

View File

@ -1,6 +1,5 @@
package com.songoda.ultimatestacker.stackable.entity.custom.entities; package com.songoda.ultimatestacker.stackable.entity.custom.entities;
import com.songoda.ultimatestacker.stackable.entity.custom.CustomEntity;
import io.lumine.mythic.api.mobs.MobManager; import io.lumine.mythic.api.mobs.MobManager;
import io.lumine.mythic.bukkit.BukkitAdapter; import io.lumine.mythic.bukkit.BukkitAdapter;
import io.lumine.mythic.bukkit.MythicBukkit; import io.lumine.mythic.bukkit.MythicBukkit;
@ -8,7 +7,6 @@ import io.lumine.mythic.core.mobs.ActiveMob;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
public class MythicMobsCustomEntity extends MythicMobsProvider { public class MythicMobsCustomEntity extends MythicMobsProvider {

View File

@ -1,16 +1,12 @@
package com.songoda.ultimatestacker.stackable.entity.custom.entities; package com.songoda.ultimatestacker.stackable.entity.custom.entities;
import com.songoda.ultimatestacker.stackable.entity.custom.CustomEntity;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.plugin.Plugin;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Objects; import java.util.Objects;
import java.util.UUID; import java.util.UUID;

View File

@ -10,6 +10,7 @@ import com.songoda.ultimatestacker.utils.Stackable;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.entity.EntityType;
import java.util.Random; import java.util.Random;
import java.util.UUID; import java.util.UUID;
@ -47,7 +48,11 @@ public class SpawnerStack extends SSpawner implements Stackable, Hologramable {
plugin.getDataManager().updateSpawner(this); plugin.getDataManager().updateSpawner(this);
} }
public int calculateSpawnCount() { public int calculateSpawnCount(EntityType type) {
if (!UltimateStacker.getInstance().getMobFile().getBoolean("Mobs." + type.name() + ".Enabled")) {
return 0;
}
Random random = new Random(); Random random = new Random();
int count = 0; int count = 0;
for (int i = 0; i < getAmount(); i++) { for (int i = 0; i < getAmount(); i++) {

View File

@ -9,12 +9,9 @@ import com.songoda.ultimatestacker.settings.Settings;
import com.songoda.ultimatestacker.stackable.entity.Check; import com.songoda.ultimatestacker.stackable.entity.Check;
import com.songoda.ultimatestacker.stackable.entity.EntityStack; import com.songoda.ultimatestacker.stackable.entity.EntityStack;
import com.songoda.ultimatestacker.stackable.entity.EntityStackManager; import com.songoda.ultimatestacker.stackable.entity.EntityStackManager;
import com.songoda.ultimatestacker.stackable.entity.StackedEntity;
import com.songoda.ultimatestacker.stackable.entity.custom.CustomEntity; import com.songoda.ultimatestacker.stackable.entity.custom.CustomEntity;
import com.songoda.ultimatestacker.utils.Async;
import com.songoda.ultimatestacker.utils.CachedChunk; import com.songoda.ultimatestacker.utils.CachedChunk;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
@ -45,16 +42,12 @@ import org.bukkit.entity.TropicalFish;
import org.bukkit.entity.Villager; import org.bukkit.entity.Villager;
import org.bukkit.entity.Wolf; import org.bukkit.entity.Wolf;
import org.bukkit.entity.Zombie; import org.bukkit.entity.Zombie;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.EntityEquipment;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -67,7 +60,6 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
public class StackingTask extends TimerTask { public class StackingTask extends TimerTask {
@ -187,6 +179,10 @@ public class StackingTask extends TimerTask {
|| entity.hasMetadata("breedCooldown")) || entity.hasMetadata("breedCooldown"))
return false; return false;
if (!configurationSection.getBoolean("Mobs." + entity.getType().name() + ".Enabled")) {
return false;
}
// Allow spawn if stackreasons are set and match, or if from a spawner // Allow spawn if stackreasons are set and match, or if from a spawner
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;

View File

@ -1,7 +1,6 @@
package com.songoda.ultimatestacker.utils; package com.songoda.ultimatestacker.utils;
import com.songoda.core.world.SWorld; import com.songoda.core.world.SWorld;
import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;