Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/org/yi/acru/bukkit/Lockette/LockettePlayerListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.bukkit.event.Listener;
import org.bukkit.event.Event.Result;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.PluginManager;

Expand Down Expand Up @@ -176,16 +177,15 @@ else if(text.equals("[more users]") || text.equalsIgnoreCase(Lockette.altMoreUse

@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerInteract(PlayerInteractEvent event){
if(!event.hasBlock()) return;

Action action = event.getAction();
Player player = event.getPlayer();
Block block = event.getClickedBlock();
int type = block.getTypeId();
int type = block != null ? block.getTypeId() : -1;
BlockFace face = event.getBlockFace();


if(action == Action.RIGHT_CLICK_BLOCK){

if(Lockette.protectTrapDoors) if(type == Material.TRAP_DOOR.getId()){
if(interactDoor(block, player)) return;

Expand Down Expand Up @@ -276,6 +276,7 @@ public void onPlayerInteract(PlayerInteractEvent event){
}
}
}

else if(action == Action.LEFT_CLICK_BLOCK){
if(Lockette.protectTrapDoors) if(type == Material.TRAP_DOOR.getId()){
if(interactDoor(block, player)) return;
Expand All @@ -292,6 +293,17 @@ else if(action == Action.LEFT_CLICK_BLOCK){
event.setUseItemInHand(Result.DENY);
return;
}
} else if (action == Action.RIGHT_CLICK_AIR && event.isCancelled()){
block = player.getTargetBlock(null, 4);
if (block != null) {
type = block.getTypeId();
if(Lockette.protectDoors) if((type == Material.WOODEN_DOOR.getId()) || (type == Material.IRON_DOOR_BLOCK.getId()) || (type == materialFenceGate)){
if (interactDoor(block, player)) return;
event.setUseInteractedBlock(Result.DENY);
event.setUseItemInHand(Result.DENY);
return;
}
}
}
}

Expand All @@ -304,7 +316,8 @@ public void onPlayerQuit(PlayerQuitEvent event){
plugin.playerList.remove(player.getName());
}




//********************************************************************************************************************
// Start of interact section

Expand Down