53 lines
1.4 KiB
Java
53 lines
1.4 KiB
Java
package eu.univento.core.listeners;
|
|
|
|
import eu.univento.core.api.player.CustomPlayer;
|
|
import eu.univento.core.commands.Build;
|
|
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.BlockCanBuildEvent;
|
|
import org.bukkit.event.block.BlockPlaceEvent;
|
|
|
|
/**
|
|
* some stuff with blocks
|
|
* @author joethei
|
|
* @version 1.0
|
|
*/
|
|
public class Blocks implements Listener{
|
|
|
|
/**
|
|
* cancels block placement if player is not in build mode
|
|
* @param e BlockPlaceEvent
|
|
*/
|
|
@EventHandler
|
|
public void onBlockPlace(BlockPlaceEvent e) {
|
|
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
|
if(!Build.getPlayers().containsKey(p)) {
|
|
e.setCancelled(true);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* cancels block breaking if player is not in build mode
|
|
* @param e BlockBreakEvent
|
|
*/
|
|
@EventHandler
|
|
public void onBlockBreak(BlockBreakEvent e) {
|
|
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
|
if(!Build.getPlayers().containsKey(p)) {
|
|
e.setCancelled(true);
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* sets buildable true so players can place blocks, even if vanished player is standing there
|
|
* @param e BlockCanBuildEvent
|
|
*/
|
|
@EventHandler(priority = EventPriority.LOW)
|
|
public void onBlockCanBuildEvent(BlockCanBuildEvent e){
|
|
e.setBuildable(true);
|
|
}
|
|
|
|
} |