2015-12-06 11:04:47 +01:00
|
|
|
package eu.univento.core.listeners;
|
2015-12-05 12:26:39 +01:00
|
|
|
|
2016-02-27 09:08:17 +01:00
|
|
|
import eu.univento.core.api.player.CustomPlayer;
|
|
|
|
import eu.univento.core.commands.Build;
|
2015-12-05 12:26:39 +01:00
|
|
|
import org.bukkit.event.EventHandler;
|
2016-02-27 09:08:17 +01:00
|
|
|
import org.bukkit.event.EventPriority;
|
2015-12-05 12:26:39 +01:00
|
|
|
import org.bukkit.event.Listener;
|
|
|
|
import org.bukkit.event.block.BlockBreakEvent;
|
2016-02-27 09:08:17 +01:00
|
|
|
import org.bukkit.event.block.BlockCanBuildEvent;
|
2015-12-05 12:26:39 +01:00
|
|
|
import org.bukkit.event.block.BlockPlaceEvent;
|
|
|
|
|
|
|
|
/**
|
2016-02-27 09:08:17 +01:00
|
|
|
* some stuff with blocks
|
2015-12-05 12:26:39 +01:00
|
|
|
* @author joethei
|
|
|
|
* @version 1.0
|
|
|
|
*/
|
|
|
|
public class Blocks implements Listener{
|
|
|
|
|
|
|
|
/**
|
2016-02-27 09:08:17 +01:00
|
|
|
* cancels block placement if player is not in build mode
|
2015-12-05 12:26:39 +01:00
|
|
|
* @param e BlockPlaceEvent
|
|
|
|
*/
|
|
|
|
@EventHandler
|
|
|
|
public void onBlockPlace(BlockPlaceEvent e) {
|
2016-02-27 09:08:17 +01:00
|
|
|
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
|
|
|
if(!Build.getPlayers().containsKey(p)) {
|
|
|
|
e.setCancelled(true);
|
2015-12-05 12:26:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-02-27 09:08:17 +01:00
|
|
|
* cancels block breaking if player is not in build mode
|
2015-12-05 12:26:39 +01:00
|
|
|
* @param e BlockBreakEvent
|
|
|
|
*/
|
|
|
|
@EventHandler
|
|
|
|
public void onBlockBreak(BlockBreakEvent e) {
|
2016-02-27 09:08:17 +01:00
|
|
|
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
|
|
|
if(!Build.getPlayers().containsKey(p)) {
|
|
|
|
e.setCancelled(true);
|
2015-12-05 12:26:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2016-02-27 09:08:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
}
|
2015-12-05 12:26:39 +01:00
|
|
|
|
|
|
|
}
|