123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- package me.km.plots;
- import me.km.KajetansMod;
- import me.km.api.Module;
- import me.km.permissions.Permissions;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.init.Items;
- import net.minecraft.util.math.BlockPos;
- import net.minecraft.block.Block;
- import net.minecraft.init.Blocks;
- import net.minecraft.world.World;
- import net.minecraftforge.event.world.BlockEvent;
- import net.minecraftforge.fml.common.eventhandler.EventPriority;
- import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
- public class ProtectionBlockAction extends Protection
- {
- public ProtectionBlockAction(Module m)
- {
- super(m);
- }
- @SubscribeEvent(priority = EventPriority.HIGHEST)
- public void onBlockPlace(BlockEvent.PlaceEvent e)
- {
- EntityPlayer p = e.getPlayer();
- if(KajetansMod.perms.hasPermission(p, Permissions.PLOT_BYPASS))
- {
- return;
- }
- if(!this.getProtectionBank().canBuild(e.getWorld(), e.getPos(), p))
- {
- if(this.getProtectionBank().hasTag(e.getWorld(), e.getPos(), "place"))
- {
- return;
- }
- e.setCanceled(true);
- }
- }
-
- @SubscribeEvent(priority = EventPriority.HIGHEST)
- public void onBlockBreak(BlockEvent.BreakEvent e)
- {
- EntityPlayer p = e.getPlayer();
- if(KajetansMod.perms.hasPermission(p, Permissions.PLOT_MARK) && p.getHeldItemMainhand().getItem() == Items.WOODEN_SWORD && p.isCreative())
- {
- e.setCanceled(true);
- return;
- }
- if(KajetansMod.perms.hasPermission(p, Permissions.PLOT_BYPASS))
- {
- return;
- }
- BlockPos pos = e.getPos();
- World w = e.getWorld();
- Block b = e.getState().getBlock();
- if(!this.getProtectionBank().canBuild(w, pos, p))
- {
- if(b == Blocks.PUMPKIN || b == Blocks.MELON_BLOCK)
- {
- if(this.getProtectionBank().hasTag(w, pos, "farm"))
- {
- return;
- }
- }
- else if(b == Blocks.REEDS)
- {
- if(w.getBlockState(pos.down()).getBlock() == Blocks.REEDS)
- {
- if(this.getProtectionBank().hasTag(w, pos, "farm"))
- {
- return;
- }
- }
- }
- if(this.getProtectionBank().hasTag(w, pos, "break"))
- {
- return;
- }
- if(b == Blocks.SNOW_LAYER)
- {
- if(this.getProtectionBank().hasTag(w, pos, "snow"))
- {
- return;
- }
- }
- e.setCanceled(true);
- }
- }
- }
|