mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-12-28 03:17:47 +01:00
Merge branch 'development'
This commit is contained in:
commit
1593eb377f
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>UltimateStacker</artifactId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>2.0.5</version>
|
||||
<version>2.0.6</version>
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<finalName>UltimateStacker-${project.version}</finalName>
|
||||
|
@ -28,6 +28,8 @@ import com.songoda.ultimatestacker.database.migrations._3_BlockStacks;
|
||||
import com.songoda.ultimatestacker.hook.StackerHook;
|
||||
import com.songoda.ultimatestacker.hook.hooks.JobsHook;
|
||||
import com.songoda.ultimatestacker.listeners.*;
|
||||
import com.songoda.ultimatestacker.listeners.entity.EntityCurrentListener;
|
||||
import com.songoda.ultimatestacker.listeners.entity.EntityListeners;
|
||||
import com.songoda.ultimatestacker.listeners.item.ItemCurrentListener;
|
||||
import com.songoda.ultimatestacker.listeners.item.ItemLegacyListener;
|
||||
import com.songoda.ultimatestacker.listeners.item.ItemListeners;
|
||||
@ -168,6 +170,9 @@ public class UltimateStacker extends SongodaPlugin {
|
||||
pluginManager.registerEvents(new DeathListeners(this), this);
|
||||
pluginManager.registerEvents(new ShearListeners(this), this);
|
||||
pluginManager.registerEvents(new InteractListeners(this), this);
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13))
|
||||
pluginManager.registerEvents(new EntityCurrentListener(this), this);
|
||||
|
||||
pluginManager.registerEvents(new EntityListeners(this), this);
|
||||
pluginManager.registerEvents(new ItemListeners(this), this);
|
||||
|
||||
|
@ -136,16 +136,13 @@ public class DataManager extends DataManagerAbstract {
|
||||
|
||||
public void createStackedEntities(ColdEntityStack hostStack, List<StackedEntity> stackedEntities) {
|
||||
this.queueAsync(() -> this.databaseConnector.connect(connection -> {
|
||||
String createSerializedEntity = "INSERT INTO " + this.getTablePrefix() + "stacked_entities (uuid, host, serialized_entity) VALUES (?, ?, ?)" +
|
||||
"ON CONFLICT(uuid) DO UPDATE SET host = ?, serialized_entity = ?";
|
||||
String createSerializedEntity = "REPLACE INTO " + this.getTablePrefix() + "stacked_entities (uuid, host, serialized_entity) VALUES (?, ?, ?)";
|
||||
try (PreparedStatement statement = connection.prepareStatement(createSerializedEntity)) {
|
||||
if (hostStack.getHostUniqueId() == null) return;
|
||||
for (StackedEntity entity : stackedEntities) {
|
||||
statement.setString(1, entity.getUniqueId().toString());
|
||||
statement.setInt(2, hostStack.getId());
|
||||
statement.setBytes(3, entity.getSerializedEntity());
|
||||
statement.setInt(4, hostStack.getId());
|
||||
statement.setBytes(5, entity.getSerializedEntity());
|
||||
statement.addBatch();
|
||||
}
|
||||
statement.executeBatch();
|
||||
|
@ -0,0 +1,32 @@
|
||||
package com.songoda.ultimatestacker.listeners.entity;
|
||||
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.stackable.entity.EntityStack;
|
||||
import com.songoda.ultimatestacker.stackable.entity.EntityStackManager;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityTransformEvent;
|
||||
|
||||
public class EntityCurrentListener implements Listener {
|
||||
|
||||
private final UltimateStacker plugin;
|
||||
|
||||
public EntityCurrentListener(UltimateStacker plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onSpawn(EntityTransformEvent event) {
|
||||
EntityStackManager stackManager = plugin.getEntityStackManager();
|
||||
if (stackManager.isStackedAndLoaded(event.getEntity().getUniqueId())
|
||||
&& event.getEntity() instanceof LivingEntity
|
||||
&& event.getTransformedEntity() instanceof LivingEntity) {
|
||||
EntityStack stack = stackManager.updateStack((LivingEntity) event.getEntity(),
|
||||
(LivingEntity) event.getTransformedEntity());
|
||||
stack.releaseHost();
|
||||
stack.updateStack();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.ultimatestacker.listeners;
|
||||
package com.songoda.ultimatestacker.listeners.entity;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
@ -41,20 +41,6 @@ public class EntityListeners implements Listener {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onSpawn(EntityTransformEvent event) {
|
||||
EntityStackManager stackManager = plugin.getEntityStackManager();
|
||||
if (stackManager.isStackedAndLoaded(event.getEntity().getUniqueId())
|
||||
&& event.getEntity() instanceof LivingEntity
|
||||
&& event.getTransformedEntity() instanceof LivingEntity) {
|
||||
EntityStack stack = stackManager.updateStack((LivingEntity) event.getEntity(),
|
||||
(LivingEntity) event.getTransformedEntity());
|
||||
stack.releaseHost();
|
||||
stack.updateStack();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onEgg(ItemSpawnEvent event) {
|
||||
Material material = event.getEntity().getItemStack().getType();
|
Loading…
Reference in New Issue
Block a user