mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-11-26 03:55:56 +01:00
Move ChunkLoadEvent to separate ChunkListener class
This commit is contained in:
parent
4bf2d9b479
commit
f234cdd73e
@ -281,6 +281,7 @@ public class UltimateStacker extends SongodaPlugin {
|
||||
}
|
||||
}
|
||||
});
|
||||
getServer().getPluginManager().registerEvents(new ChunkListener(this), this);
|
||||
}
|
||||
|
||||
public void addExp(Player player, EntityStack stack) {
|
||||
|
@ -47,14 +47,6 @@ public class BlockListeners implements Listener {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChunkLoad(ChunkLoadEvent event) {
|
||||
if (!Settings.STACK_BLOCKS.getBoolean()) return;
|
||||
Chunk chunk = event.getChunk();
|
||||
BlockStackManager blockStackManager = plugin.getBlockStackManager();
|
||||
blockStackManager.getStacks().stream().filter(stack -> stack.getLocation().getChunk().equals(chunk)).forEach(plugin::updateHologram);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onBlockInteract(PlayerInteractEvent event) {
|
||||
if (event.useInteractedBlock() == Event.Result.DENY) return;
|
||||
|
@ -0,0 +1,28 @@
|
||||
package com.songoda.ultimatestacker.listeners;
|
||||
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.settings.Settings;
|
||||
import com.songoda.ultimatestacker.stackable.block.BlockStackManager;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
|
||||
public class ChunkListener implements Listener {
|
||||
|
||||
private final BlockStackManager blockStackManager;
|
||||
private final UltimateStacker plugin;
|
||||
|
||||
public ChunkListener(UltimateStacker plugin) {
|
||||
this.blockStackManager = plugin.getBlockStackManager();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChunkLoad(ChunkLoadEvent event) {
|
||||
if (!Settings.STACK_BLOCKS.getBoolean()) return;
|
||||
Chunk chunk = event.getChunk();
|
||||
BlockStackManager blockStackManager = plugin.getBlockStackManager();
|
||||
blockStackManager.getStacks().stream().filter(stack -> stack.getLocation().getChunk().equals(chunk)).forEach(plugin::updateHologram);
|
||||
}
|
||||
}
|
@ -8,10 +8,11 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class BlockStackManager {
|
||||
|
||||
private final Map<Location, BlockStack> registeredBlocks = new HashMap<>();
|
||||
private final Map<Location, BlockStack> registeredBlocks = new ConcurrentHashMap<>();
|
||||
|
||||
public void addBlocks(Map<Location, BlockStack> blocks) {
|
||||
this.registeredBlocks.putAll(blocks);
|
||||
|
Loading…
Reference in New Issue
Block a user