Initial commit
This commit is contained in:
44
src/de/anura/core/BlockPlace.java
Normal file
44
src/de/anura/core/BlockPlace.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package de.anura.core;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
|
||||
public class BlockPlace implements Listener
|
||||
{
|
||||
public BlockPlace(AnuraCore plugin)
|
||||
{
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if(plugin.getConfig().getBoolean("no-change-blocks"))
|
||||
{
|
||||
if(!event.getPlayer().hasPermission("core.rules.blocks.place"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
if(plugin.flowerPots.containsValue(event.getBlock().getLocation()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
final Block b = event.getBlock();
|
||||
final int pot = API.getKeyByValue(plugin.flowerPots, b.getLocation());
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
b.setType(Material.BROWN_MUSHROOM);
|
||||
AnuraCore.getInstance().pots.refreshPot(pot);
|
||||
}
|
||||
|
||||
}, 3);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
Reference in New Issue
Block a user