Lobby/src/eu/univento/lobby/listeners/StatusSigns.java

38 lines
1.1 KiB
Java

package eu.univento.lobby.listeners;
import eu.univento.core.api.Servers;
import eu.univento.lobby.Lobby;
import eu.univento.lobby.utils.StatusSignUtil;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
/**
* handles status sign clicking
* @author joethei
* @version 1.0
*/
public class StatusSigns implements Listener{
/**
* clicking status signs
* @param e PlayerInteractEvent
*/
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e)
{
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
Block block = e.getClickedBlock();
if ((block.getType() != Material.SIGN) && (block.getType() != Material.SIGN_POST) && (block.getType() != Material.WALL_SIGN)) return;
for (StatusSignUtil s : Lobby.returnSigns())
if (s.getLocation().equals(block.getLocation()))
Servers.connectServer(e.getPlayer(), s.getName());
}
}