use of dev.rosewood.rosestacker.stack.StackingThread in project RoseStacker by Rosewood-Development.
the class ClearlagListener method onClear.
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onClear(EntityRemoveEvent event) {
StackManager stackManager = this.rosePlugin.getManager(StackManager.class);
StackingThread stackingThread = stackManager.getStackingThread(event.getWorld());
if (stackingThread == null)
return;
if (Setting.MISC_CLEARLAG_CLEAR_ENTITIES.getBoolean() && stackManager.isEntityStackingEnabled())
stackingThread.removeAllEntityStacks();
if (Setting.MISC_CLEARLAG_CLEAR_ITEMS.getBoolean() && stackManager.isItemStackingEnabled())
stackingThread.removeAllItemStacks();
}
use of dev.rosewood.rosestacker.stack.StackingThread in project RoseStacker by Rosewood-Development.
the class StackManager method unloadWorld.
/**
* Removes a World's StackingThread
*
* @param world to remove the StackingThread of
*/
public void unloadWorld(World world) {
UUID worldUUID = world.getUID();
StackingThread stackingThread = this.stackingThreads.get(worldUUID);
if (stackingThread != null) {
stackingThread.close();
this.stackingThreads.remove(worldUUID);
}
}
use of dev.rosewood.rosestacker.stack.StackingThread in project RoseStacker by Rosewood-Development.
the class StackManager method preStackEntities.
@Override
public void preStackEntities(EntityType entityType, int amount, Location location, SpawnReason spawnReason) {
World world = location.getWorld();
if (world == null)
return;
StackingThread stackingThread = this.getStackingThread(world);
if (stackingThread == null)
return;
stackingThread.preStackEntities(entityType, amount, location, spawnReason);
}
use of dev.rosewood.rosestacker.stack.StackingThread in project RoseStacker by Rosewood-Development.
the class StackManager method addEntityStack.
@Override
public void addEntityStack(StackedEntity stackedEntity) {
StackingThread stackingThread = this.getStackingThread(stackedEntity.getEntity().getWorld());
if (stackingThread == null)
return;
stackingThread.addEntityStack(stackedEntity);
}
use of dev.rosewood.rosestacker.stack.StackingThread in project RoseStacker by Rosewood-Development.
the class StackManager method reload.
@Override
public void reload() {
// Load a new StackingThread per world
Bukkit.getWorlds().forEach(this::loadWorld);
if (Setting.LEGACY_DATA_MIGRATION.getBoolean())
this.pendingChunkTask = Bukkit.getScheduler().runTaskTimer(this.rosePlugin, this::processPendingChunks, 0L, 3L);
this.processingChunks = false;
this.processingChunksTime = System.currentTimeMillis();
// Load all existing stacks
for (StackingThread stackingThread : this.stackingThreads.values()) {
for (Chunk chunk : stackingThread.getTargetWorld().getLoadedChunks()) {
stackingThread.loadChunkBlocks(chunk);
stackingThread.loadChunkEntities(chunk, Arrays.asList(chunk.getEntities()));
this.pendingLoadChunks.put(chunk, System.nanoTime());
}
}
// Kick off autosave task if enabled
long autosaveFrequency = Setting.AUTOSAVE_FREQUENCY.getLong();
if (autosaveFrequency > 0) {
long interval = autosaveFrequency * 20 * 60;
this.autosaveTask = Bukkit.getScheduler().runTaskTimer(this.rosePlugin, () -> this.saveAllData(false), interval, interval);
}
}
Aggregations