From aa9f847fb6ab67c07e0e90d12adcdbf0c9bc4292 Mon Sep 17 00:00:00 2001 From: ryanhamshire Date: Wed, 12 Nov 2014 19:53:07 -0800 Subject: [PATCH] Perf: Bed protections. --- .../GriefPrevention/PlayerEventHandler.java | 32 ++----------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java index 2b1811f..75d7911 100644 --- a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java @@ -976,33 +976,6 @@ class PlayerEventHandler implements Listener } } - //block players from entering beds they don't have permission for - @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) - public void onPlayerBedEnter (PlayerBedEnterEvent bedEvent) - { - if(!GriefPrevention.instance.claimsEnabledForWorld(bedEvent.getBed().getWorld())) return; - - if(!GriefPrevention.instance.config_claims_preventButtonsSwitches) return; - - Player player = bedEvent.getPlayer(); - PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId()); - Block block = bedEvent.getBed(); - - //if the bed is in a claim - Claim claim = this.dataStore.getClaimAt(block.getLocation(), false, playerData.lastClaim); - if(claim != null) - { - playerData.lastClaim = claim; - - //if the player doesn't have access in that claim, tell him so and prevent him from sleeping in the bed - if(claim.allowAccess(player) != null) - { - bedEvent.setCancelled(true); - GriefPrevention.sendMessage(player, TextMode.Err, Messages.NoBedPermission, claim.getOwnerName()); - } - } - } - //block use of buckets within other players' claims @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onPlayerBucketEmpty (PlayerBucketEmptyEvent bucketEvent) @@ -1197,10 +1170,11 @@ class PlayerEventHandler implements Listener } } - //otherwise apply rules for doors, if configured that way + //otherwise apply rules for doors and beds, if configured that way else if( clickedBlock != null && (GriefPrevention.instance.config_claims_lockWoodenDoors && clickedBlockType == Material.WOODEN_DOOR) || - (GriefPrevention.instance.config_claims_lockTrapDoors && clickedBlockType == Material.TRAP_DOOR) || + (GriefPrevention.instance.config_claims_preventButtonsSwitches && clickedBlockType == Material.BED_BLOCK) || + (GriefPrevention.instance.config_claims_lockTrapDoors && clickedBlockType == Material.TRAP_DOOR) || (GriefPrevention.instance.config_claims_lockFenceGates && clickedBlockType == Material.FENCE_GATE)) { if(playerData == null) playerData = this.dataStore.getPlayerData(player.getUniqueId());