fix missing holograms after server restart

This commit is contained in:
Aurora 2020-08-13 10:44:07 +02:00 committed by Brianna
parent 09cce89d75
commit 5d68d7d886
2 changed files with 38 additions and 0 deletions

View File

@ -146,6 +146,7 @@ public class UltimateKits extends SongodaPlugin {
PluginManager pluginManager = getServer().getPluginManager();
guiManager.init();
pluginManager.registerEvents(new BlockListeners(this), this);
pluginManager.registerEvents(new ChunkListeners(this), this);
pluginManager.registerEvents(new ChatListeners(this), this);
pluginManager.registerEvents(new EntityListeners(this), this);
pluginManager.registerEvents(new InteractListeners(this, guiManager), this);

View File

@ -0,0 +1,37 @@
package com.songoda.ultimatekits.listeners;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.key.Key;
import com.songoda.ultimatekits.kit.Kit;
import com.songoda.ultimatekits.kit.KitBlockData;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.inventory.ItemStack;
/**
* Created by songoda on 2/24/2017.
*/
public class ChunkListeners implements Listener {
private final UltimateKits instance;
public ChunkListeners(UltimateKits instance) {
this.instance = instance;
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onChunkLoad(ChunkLoadEvent event) {
instance.getKitManager().getKitLocations().values().stream()
.filter(l -> l.getLocation().getWorld() == event.getWorld()
&& l.getLocation().getBlockX() >> 4 == event.getChunk().getX()
&& l.getLocation().getBlockZ() >> 4 == event.getChunk().getZ())
.forEach(instance::updateHologram);
}
}