Skip to content
Open
Show file tree
Hide file tree
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
16 changes: 14 additions & 2 deletions src/org/yi/acru/bukkit/Lockette/LocketteBlockListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,20 @@

public class LocketteBlockListener implements Listener{
private static Lockette plugin;

final byte faceList[] = {5, 3, 4, 2};
static byte faceList[];
static {
if (BlockFace.NORTH.getModX() == -1) {
faceList[0] = 5;
faceList[1] = 3;
faceList[2] = 4;
faceList[3] = 2;
} else {
faceList[0] = 2;
faceList[1] = 5;
faceList[2] = 3;
faceList[3] = 4;
}
}
final int materialList[] = {Material.CHEST.getId(), Material.DISPENSER.getId(),
Material.FURNACE.getId(), Material.BURNING_FURNACE.getId(),
Material.BREWING_STAND.getId(), Material.TRAP_DOOR.getId(),
Expand Down
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