1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- package me.km.plots;
- import me.kcm.events.FarmlandTrampleEvent;
- import me.km.KajetansMod;
- import me.km.api.Module;
- import me.km.permissions.Permissions;
- import net.minecraft.block.Block;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.init.Blocks;
- import net.minecraftforge.event.entity.player.PlayerInteractEvent;
- import net.minecraftforge.fml.common.eventhandler.EventPriority;
- import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
- public class ProtectionInteract extends Protection
- {
- public ProtectionInteract(Module m)
- {
- super(m);
- }
-
- @SubscribeEvent(priority = EventPriority.HIGHEST)
- public void onPlayerInteract(PlayerInteractEvent.LeftClickBlock e)
- {
- EntityPlayer p = e.getEntityPlayer();
- if(KajetansMod.perms.hasPermission(p, Permissions.PLOT_BYPASS))
- {
- return;
- }
- Block b = e.getWorld().getBlockState(e.getPos()).getBlock();
- if (b == Blocks.FIRE && !this.getProtectionBank().canBuild(e.getWorld(), e.getPos(), p))
- {
- e.setCanceled(true);
- }
- }
-
- @SubscribeEvent(priority = EventPriority.HIGHEST)
- public void onPlayerInteract(PlayerInteractEvent.RightClickBlock e)
- {
- EntityPlayer p = e.getEntityPlayer();
- if(KajetansMod.perms.hasPermission(p, Permissions.PLOT_BYPASS))
- {
- return;
- }
- Block b = e.getWorld().getBlockState(e.getPos()).getBlock();
- if(b == Blocks.DAYLIGHT_DETECTOR || b == Blocks.DAYLIGHT_DETECTOR_INVERTED ||
- b == Blocks.POWERED_REPEATER || b == Blocks.UNPOWERED_REPEATER ||
- b == Blocks.POWERED_COMPARATOR || b == Blocks.UNPOWERED_COMPARATOR ||
- b == Blocks.DRAGON_EGG)
- {
- if(!this.getProtectionBank().canBuild(e.getWorld(), e.getPos(), p))
- {
- e.setCanceled(true);
- }
- }
- }
-
- @SubscribeEvent(priority = EventPriority.HIGHEST)
- public void protectFromInteract(PlayerInteractEvent.EntityInteract e)
- {
- EntityPlayer p = e.getEntityPlayer();
- if(KajetansMod.perms.hasPermission(p, Permissions.PLOT_BYPASS) ||
- this.getProtectionBank().canBuild(e.getWorld(), e.getTarget().getPosition(), p))
- {
- return;
- }
- e.setCanceled(true);
- }
-
- @SubscribeEvent(priority = EventPriority.HIGHEST)
- public void protectFromInteract(FarmlandTrampleEvent e)
- {
- e.setCanceled(true);
- }
- }
|