12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- package me.km.plots;
- 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.has(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.has(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.has(p, Permissions.PLOT_BYPASS) ||
- this.getProtectionBank().canBuild(e.getWorld(), e.getTarget().getPosition(), p))
- {
- return;
- }
- e.setCanceled(true);
- }
- }
|