From 5da577387923de6f24d27cc01e4477b792750542 Mon Sep 17 00:00:00 2001 From: Acrobot Date: Thu, 19 Apr 2012 15:51:50 +0200 Subject: [PATCH] Added getDefaultProtection() method so the objects gets created only once --- com/Acrobot/ChestShop/Protection/Security.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/com/Acrobot/ChestShop/Protection/Security.java b/com/Acrobot/ChestShop/Protection/Security.java index 7323a83..c2a08c6 100644 --- a/com/Acrobot/ChestShop/Protection/Security.java +++ b/com/Acrobot/ChestShop/Protection/Security.java @@ -3,6 +3,7 @@ package com.Acrobot.ChestShop.Protection; import com.Acrobot.ChestShop.Config.Config; import com.Acrobot.ChestShop.Config.Property; import com.Acrobot.ChestShop.Listeners.blockBreak; +import com.Acrobot.ChestShop.Protection.Plugins.Default; import com.Acrobot.ChestShop.Utils.uLongName; import com.Acrobot.ChestShop.Utils.uSign; import org.bukkit.Material; @@ -20,22 +21,33 @@ public class Security { private static final BlockFace[] faces = {BlockFace.UP, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH}; private static final BlockFace[] blockFaces = {BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH}; public static ArrayList protections = new ArrayList(); + private static Default defaultProtection = new Default(); + + public static Default getDefaultProtection() { + return defaultProtection; + } public static boolean protect(String name, Block block) { boolean works = false; - for (int i = 0; i < protections.size() && !works; i++) works = protections.get(i).protect(name, block); + for (int i = 0; i < protections.size() && !works; i++){ + works = protections.get(i).protect(name, block); + } return works; } public static boolean canAccess(Player player, Block block) { boolean works = true; - for (int i = 0; i < protections.size() && works; i++) works = protections.get(i).canAccess(player, block); + for (int i = 0; i < protections.size() && works; i++){ + works = protections.get(i).canAccess(player, block); + } return works; } public static boolean isProtected(Block block) { boolean isProt = false; - for (int i = 0; i < protections.size() && !isProt; i++) isProt = protections.get(i).isProtected(block); + for (int i = 0; i < protections.size() && !isProt; i++){ + isProt = protections.get(i).isProtected(block); + } return isProt; }