mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-26 04:12:22 +00:00
51 lines
1.1 KiB
Java
51 lines
1.1 KiB
Java
package de.epiceric.shopchest.event;
|
|
|
|
import org.bukkit.Location;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.event.EventHandler;
|
|
import org.bukkit.event.Listener;
|
|
import org.bukkit.event.player.PlayerMoveEvent;
|
|
|
|
import de.epiceric.shopchest.config.Config;
|
|
import de.epiceric.shopchest.shop.Shop;
|
|
import de.epiceric.shopchest.utils.ShopUtils;
|
|
|
|
public class UpdateHolograms implements Listener{
|
|
|
|
public UpdateHolograms() {}
|
|
|
|
@EventHandler
|
|
public void onPlayerMove(PlayerMoveEvent e) {
|
|
|
|
Player p = e.getPlayer();
|
|
Location playerLocation = p.getLocation();
|
|
|
|
for (Shop shop : ShopUtils.getShops()) {
|
|
|
|
Location shopLocation = shop.getLocation();
|
|
|
|
if (playerLocation.getWorld().equals(shopLocation.getWorld())) {
|
|
|
|
if (playerLocation.distance(shop.getHologram().getLocation()) <= Config.maximal_distance()) {
|
|
|
|
if (!shop.getHologram().isVisible(p)) {
|
|
shop.getHologram().showPlayer(p);
|
|
}
|
|
|
|
} else {
|
|
|
|
if (shop.getHologram().isVisible(p)) {
|
|
shop.getHologram().hidePlayer(p);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|