Search in sources :

Example 6 with RPBlockListener

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());
    }
}
Also used : BlockSnapshot(org.spongepowered.api.block.BlockSnapshot) Region(br.net.fabiozumbi12.RedProtect.Sponge.Region) Listener(org.spongepowered.api.event.Listener)

Example 7 with RPBlockListener

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);
    }
}
Also used : Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) EventHandler(org.bukkit.event.EventHandler)

Example 8 with RPBlockListener

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.");
    }
}
Also used : RPBlockListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPBlockListener) RPPlayerListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPPlayerListener) RPWorldListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPWorldListener) RPEntityListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPEntityListener) RedProtectAPI(br.net.fabiozumbi12.RedProtect.Sponge.API.RedProtectAPI) RPGlobalListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPGlobalListener) RPAddProtection(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPAddProtection) RPMine18(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPMine18) RPCommands(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPCommands) RPGlobalListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPGlobalListener) RPWorldListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPWorldListener) RPEntityListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPEntityListener) RPBlockListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPBlockListener) RPPlayerListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPPlayerListener) Listener(org.spongepowered.api.event.Listener)

Example 9 with RPBlockListener

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);
    }
}
Also used : Block(org.bukkit.block.Block) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) EventHandler(org.bukkit.event.EventHandler)

Example 10 with RPBlockListener

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);
    }
}
Also used : Vehicle(org.bukkit.entity.Vehicle) Player(org.bukkit.entity.Player) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Region (br.net.fabiozumbi12.RedProtect.Bukkit.Region)13 EventHandler (org.bukkit.event.EventHandler)13 Block (org.bukkit.block.Block)7 Listener (org.spongepowered.api.event.Listener)3 Region (br.net.fabiozumbi12.RedProtect.Sponge.Region)2 World (org.bukkit.World)2 BlockState (org.bukkit.block.BlockState)2 Player (org.bukkit.entity.Player)2 BlockSnapshot (org.spongepowered.api.block.BlockSnapshot)2 RedProtectAPI (br.net.fabiozumbi12.RedProtect.Bukkit.API.RedProtectAPI)1 MPListener (br.net.fabiozumbi12.RedProtect.Bukkit.hooks.MPListener)1 McMMoListener (br.net.fabiozumbi12.RedProtect.Bukkit.hooks.McMMoListener)1 RPDynmap (br.net.fabiozumbi12.RedProtect.Bukkit.hooks.RPDynmap)1 RPFactions (br.net.fabiozumbi12.RedProtect.Bukkit.hooks.RPFactions)1 RPPlaceHoldersAPI (br.net.fabiozumbi12.RedProtect.Bukkit.hooks.RPPlaceHoldersAPI)1 SkillAPIListener (br.net.fabiozumbi12.RedProtect.Bukkit.hooks.SkillAPIListener)1 RPAddProtection (br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPAddProtection)1 RPBlockListener (br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPBlockListener)1 RPCommands (br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPCommands)1 RPEntityListener (br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPEntityListener)1