Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
21b2603
Improve lootgen and add cached Config class
RVSkeLe May 5, 2026
e9480a3
Use fastutil
RVSkeLe May 11, 2026
7e663a7
Other fastutil stuff
RVSkeLe May 12, 2026
8f17604
Scary inventory optimization
RVSkeLe May 12, 2026
c7e398e
Dumb sort button caching
RVSkeLe May 12, 2026
2daa759
Remove signatureCache as caching was actually slower
RVSkeLe May 12, 2026
f1513cc
Cleanup for the whole display rewrite
RVSkeLe May 12, 2026
19f51d2
Start optimizing createButton itself
RVSkeLe May 12, 2026
2981565
Make LRUCache a Guava wrapper and use it in SortButton
RVSkeLe May 13, 2026
681501d
Optimize the UI further
RVSkeLe May 13, 2026
64f3250
Improve ItemSignature by caching the Material
RVSkeLe May 13, 2026
73b6b3d
Improve start times and addItems logic
RVSkeLe May 13, 2026
31adc45
LinkedHashMap is better
RVSkeLe May 14, 2026
916d184
Optimize navigation buttons
RVSkeLe May 14, 2026
70991ab
Do not check mappingFunction
RVSkeLe May 14, 2026
bfd09f8
Improve hashCode and equals in SortButtonCacheKey
RVSkeLe May 14, 2026
1a9e61d
Add -DEV to the version
RVSkeLe May 14, 2026
2d46fca
Very scary: Completely remove physical ItemStacks in the lootgen logic
RVSkeLe May 14, 2026
da1dc86
Improve ItemSignature
RVSkeLe May 14, 2026
f5fea85
Merge remote-tracking branch 'origin/main' into perf/improve-lootgen
RVSkeLe May 28, 2026
020e836
Remove leftover comment in ItemSignature
RVSkeLe May 28, 2026
b22a2bc
Less diff
RVSkeLe May 28, 2026
3118b5b
Merge remote-tracking branch 'origin/main' into perf/improve-lootgen
RVSkeLe May 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ allprojects {
apply(plugin = "maven-publish")

group = "github.nighter"
version = "1.6.7"
version = "1.6.7-DEV"

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import github.nighter.smartspawner.spawner.properties.SpawnerData;
import github.nighter.smartspawner.spawner.properties.VirtualInventory;
import github.nighter.smartspawner.utils.BlockPos;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
Expand Down Expand Up @@ -64,36 +65,47 @@ private void transferItems(Location hopperLoc, Location spawnerLoc) {
var state = hopperLoc.getBlock().getState(false);
if (!(state instanceof Hopper hopper)) return;

Map<Integer, ItemStack> displayItems = virtualInv.getDisplayInventory();
if (displayItems == null || displayItems.isEmpty()) return;

Inventory hopperInv = hopper.getInventory();

int transferred = 0;

int rangeStart = 0;
int rangeSize = Math.max(plugin.getHopperConfig().getStackPerTransfer(), 9);
List<ItemStack> removed = new ArrayList<>();

for (ItemStack item : displayItems.values()) {
if (transferred >= plugin.getHopperConfig().getStackPerTransfer()) break;
if (item == null || item.getType() == Material.AIR) continue;
while (transferred < plugin.getHopperConfig().getStackPerTransfer()) {
Int2ObjectMap<ItemStack> displayItems = virtualInv.getDisplayRange(rangeStart, rangeSize);
if (displayItems.isEmpty()) {
break;
}

for (ItemStack item : displayItems.values()) {
if (transferred >= plugin.getHopperConfig().getStackPerTransfer()) {
break;
}
if (item == null || item.getType() == Material.AIR) {
continue;
}

ItemStack clone = item.clone();
int originalAmount = clone.getAmount();
ItemStack clone = item.clone();
int originalAmount = clone.getAmount();

HashMap<Integer, ItemStack> leftovers = hopperInv.addItem(clone);
HashMap<Integer, ItemStack> leftovers = hopperInv.addItem(clone);

int insertedAmount = originalAmount;
int insertedAmount = originalAmount;

if (!leftovers.isEmpty()) {
insertedAmount -= leftovers.values().iterator().next().getAmount();
}
if (!leftovers.isEmpty()) {
insertedAmount -= leftovers.values().iterator().next().getAmount();
}

if (insertedAmount > 0) {
ItemStack toRemove = item.clone();
toRemove.setAmount(insertedAmount);
removed.add(toRemove);
transferred++;
if (insertedAmount > 0) {
ItemStack toRemove = item.clone();
toRemove.setAmount(insertedAmount);
removed.add(toRemove);
transferred++;
}
}

rangeStart += rangeSize;
}

if (!removed.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package github.nighter.smartspawner.language;

import github.nighter.smartspawner.SmartSpawner;
import github.nighter.smartspawner.utils.LRUCache;
import lombok.Getter;
import org.bukkit.ChatColor;
import org.bukkit.Material;
Expand All @@ -17,7 +18,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.text.Normalizer;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,13 +437,7 @@ private SpawnerData loadSpawnerFromConfig(String spawnerId, boolean logErrors, b
int amount = entry.getValue();

if (item != null && amount > 0) {
while (amount > 0) {
int batchSize = Math.min(amount, item.getMaxStackSize());
ItemStack batch = item.clone();
batch.setAmount(batchSize);
virtualInv.addItems(Collections.singletonList(batch));
amount -= batchSize;
}
virtualInv.addItem(item, amount);
}
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -680,13 +680,7 @@ private void loadInventoryFromJson(String jsonData, VirtualInventory virtualInv)
int amount = entry.getValue();

if (item != null && amount > 0) {
while (amount > 0) {
int batchSize = Math.min(amount, item.getMaxStackSize());
ItemStack batch = item.clone();
batch.setAmount(batchSize);
virtualInv.addItems(Collections.singletonList(batch));
amount -= batchSize;
}
virtualInv.addItem(item, amount);
}
}
} catch (Exception e) {
Expand Down
Loading
Loading