use of br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPBlockListener in project RedProtect by FabioZumbi12.
the class RPBlockListener method onBlockGrow.
@Listener(order = Order.FIRST, beforeModifications = true)
public void onBlockGrow(ChangeBlockEvent.Grow e) {
RedProtect.get().logger.debug("blocks", "RPBlockListener - Is ChangeBlockEvent.Grow event");
BlockSnapshot b = e.getTransactions().get(0).getOriginal();
Region r = RedProtect.get().rm.getTopRegion(b.getLocation().get());
if (r != null && !r.canGrow()) {
e.setCancelled(true);
RedProtect.get().logger.debug("blocks", "Cancel grow " + b.getState().getName());
}
}
use of br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPBlockListener in project RedProtect by FabioZumbi12.
the class RPGlobalListener method onLeafDecay.
@EventHandler
public void onLeafDecay(LeavesDecayEvent e) {
RedProtect.get().logger.debug("RPBlockListener - Is LeavesDecayEvent event");
Region r = RedProtect.get().rm.getTopRegion(e.getBlock().getLocation());
if (r == null && !RPConfig.getGlobalFlagBool(e.getBlock().getWorld().getName() + ".allow-changes-of.leaves-decay")) {
e.setCancelled(true);
}
}
use of br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPBlockListener in project RedProtect by FabioZumbi12.
the class RedProtect method onServerStart.
@Listener
public void onServerStart(GameStartedServerEvent event) {
try {
String v = Sponge.getGame().getPlatform().getContainer(Component.API).getVersion().get();
instance = this;
if (v.startsWith("5") || v.startsWith("6")) {
pvhelp = (RPVHelper) Class.forName("br.net.fabiozumbi12.RedProtect.Sponge.RPVHelper56").newInstance();
}
if (v.startsWith("7")) {
pvhelp = (RPVHelper) Class.forName("br.net.fabiozumbi12.RedProtect.Sponge.RPVHelper7").newInstance();
}
initVars();
OnlineMode = serv.getOnlineMode();
cmdService.register(container, new RPCommands(), Arrays.asList("redprotect", "rp", "regionp", "regp"));
game.getEventManager().registerListeners(container, new RPGlobalListener());
game.getEventManager().registerListeners(container, new RPBlockListener());
game.getEventManager().registerListeners(container, new RPPlayerListener());
game.getEventManager().registerListeners(container, new RPEntityListener());
game.getEventManager().registerListeners(container, new RPWorldListener());
game.getEventManager().registerListeners(container, new RPMine18());
game.getEventManager().registerListeners(container, new RPAddProtection());
loadRegions();
logger.info("Loading API...");
this.rpAPI = new RedProtectAPI();
logger.info("API Loaded!");
logger.clear("&4 _ _ _ &c _ _ _ _ _ _ _ _ _ __");
logger.clear("&4|_| |_ | \\ &c|_| |_| | | | |_ | | / ");
logger.clear("&4| \\ |_ |_/ &c| | \\ |_| | |_ |_ | /");
logger.clear("&a¯ Redprotect " + container.getVersion().get() + " enabled");
logger.clear("");
} catch (Exception e) {
e.printStackTrace();
logger.severe("Error enabling RedProtect, plugin will shut down.");
}
}
use of br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPBlockListener in project RedProtect by FabioZumbi12.
the class RPBlockListener method onBlockBurn.
@EventHandler
public void onBlockBurn(BlockBurnEvent e) {
RedProtect.get().logger.debug("RPBlockListener - Is BlockBurnEvent event");
if (e.isCancelled()) {
return;
}
Block b = e.getBlock();
Region r = RedProtect.get().rm.getTopRegion(b.getLocation());
if (r != null && !r.canFire()) {
e.setCancelled(true);
return;
}
if (!cont.canWorldBreak(b)) {
e.setCancelled(true);
}
}
use of br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPBlockListener in project RedProtect by FabioZumbi12.
the class RPBlockListener method onVehicleBreak.
@EventHandler
public void onVehicleBreak(VehicleDestroyEvent e) {
RedProtect.get().logger.debug("RPBlockListener - Is VehicleDestroyEvent event");
if (e.isCancelled()) {
return;
}
if (!(e.getAttacker() instanceof Player)) {
return;
}
Vehicle cart = e.getVehicle();
Player p = (Player) e.getAttacker();
Region r = RedProtect.get().rm.getTopRegion(cart.getLocation());
if (r != null && !r.canMinecart(p)) {
RPLang.sendMessage(p, "blocklistener.region.cantbreak");
e.setCancelled(true);
}
}
Aggregations