Add missing link and item deletion when removing hoppers

This commit is contained in:
ceze88 2024-02-12 21:17:13 +01:00
parent 16c0da830e
commit 44e5060c6a
2 changed files with 11 additions and 0 deletions

View File

@ -10,6 +10,7 @@ import com.craftaro.epichoppers.hopper.HopperImpl;
import com.craftaro.epichoppers.hopper.HopperBuilder;
import com.craftaro.epichoppers.hopper.levels.Level;
import com.craftaro.epichoppers.settings.Settings;
import com.craftaro.epichoppers.utils.DataHelper;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Material;
@ -175,6 +176,8 @@ public class BlockListeners implements Listener {
this.plugin.getHopperManager().removeHopper(block.getLocation());
this.plugin.getDataManager().delete(hopper);
DataHelper.deleteLinks(hopper);
DataHelper.deleteItems(hopper);
this.plugin.getPlayerDataManager().getPlayerData(player).setSyncType(null);
}

View File

@ -104,4 +104,12 @@ public class DataHelper {
.execute();
});
}
public static void deleteItems(HopperImpl hopper) {
EpicHoppers.getPlugin(EpicHoppers.class).getDataManager().getDatabaseConnector().connectDSL(dslContext -> {
dslContext.deleteFrom(DSL.table(EpicHoppers.getPlugin(EpicHoppers.class).getDataManager().getTablePrefix() + "items"))
.where(DSL.field("hopper_id").eq(hopper.getId()))
.execute();
});
}
}