diff --git a/pom.xml b/pom.xml
index 24b9d04..a47928f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,6 +11,8 @@
UTF-8
+ 1.7
+ 1.7
diff --git a/src/de/craftinc/gates/Gate.java b/src/de/craftinc/gates/Gate.java
index 9089306..3c8f1fd 100644
--- a/src/de/craftinc/gates/Gate.java
+++ b/src/de/craftinc/gates/Gate.java
@@ -29,18 +29,23 @@ import java.util.*;
public class Gate implements ConfigurationSerializable {
protected Location location; /* saving both location and gateBlockLocations is redundant but makes it easy to allow players to reshape gates */
- protected Set gateBlockLocations = new HashSet(); /* Locations of the blocks inside the gate */
- protected Set gateFrameBlocks = new HashSet();
+ private Set gateBlockLocations = new HashSet<>(); /* Locations of the blocks inside the gate */
+
+ private Set gateFrameBlocks = new HashSet<>();
protected Location exit;
- protected boolean isHidden = false;
- protected boolean isOpen = false;
+ private boolean isHidden = false;
+ private boolean isOpen = false;
- protected boolean allowsVehicles = true;
+ private boolean allowsVehicles = true;
protected String id;
+ public static String getGateBlocksKey() {
+ return gateBlocksKey;
+ }
+
/**
* You should never create two gates with the same 'id'. Also see 'setId(String id)'.
*
@@ -77,12 +82,11 @@ public class Gate implements ConfigurationSerializable {
findPortalBlocks();
validate();
} else {
- this.gateBlockLocations = new HashSet();
- this.gateFrameBlocks = new HashSet();
+ this.gateBlockLocations = new HashSet<>();
+ this.gateFrameBlocks = new HashSet<>();
}
}
-
/**
* @return This method might return a 'null' value.
*/
@@ -90,7 +94,6 @@ public class Gate implements ConfigurationSerializable {
return exit;
}
-
/**
* @param exit Supplying 'null' is permitted.
* @throws Exception An exception will be thrown if 'null' data is supplied and this gate is open. Note that the
@@ -102,7 +105,6 @@ public class Gate implements ConfigurationSerializable {
validate();
}
-
/**
* @return This method will never return 'null'.
*/
@@ -110,7 +112,6 @@ public class Gate implements ConfigurationSerializable {
return id;
}
-
/**
* Every gate should have an unique 'id'. You should therefore check if another gate with the same 'id' exists.
* Note that this method will not check if another gate with the same 'id' exists!
@@ -125,23 +126,19 @@ public class Gate implements ConfigurationSerializable {
this.id = id.toLowerCase();
}
-
public boolean isHidden() {
return isHidden;
}
-
public void setHidden(boolean isHidden) throws Exception {
this.isHidden = isHidden;
this.validate();
}
-
public boolean isOpen() {
return isOpen;
}
-
public void setOpen(boolean isOpen) throws Exception {
if (isOpen && !this.isOpen) {
findPortalBlocks();
@@ -151,17 +148,14 @@ public class Gate implements ConfigurationSerializable {
validate();
}
-
public void setAllowsVehicles(boolean allowsVehicles) {
this.allowsVehicles = allowsVehicles;
}
-
public boolean getAllowsVehicles() {
return this.allowsVehicles;
}
-
/**
* @return Will never return 'null' but might return an empty Set.
*/
@@ -169,7 +163,6 @@ public class Gate implements ConfigurationSerializable {
return gateBlockLocations;
}
-
/**
* @return Will never return 'null' but might return an empty Set.
*/
@@ -177,9 +170,8 @@ public class Gate implements ConfigurationSerializable {
return gateFrameBlocks;
}
-
- protected void findPortalBlocks() {
- gateBlockLocations = new HashSet();
+ private void findPortalBlocks() {
+ gateBlockLocations = new HashSet<>();
Set gateBlocks = FloodUtil.getGatePortalBlocks(location.getBlock());
if (gateBlocks != null) {
@@ -191,35 +183,34 @@ public class Gate implements ConfigurationSerializable {
gateFrameBlocks = FloodUtil.getFrame(gateBlocks);
}
-
/**
* Checks if values attributes do add up; will close gate on wrong values.
*/
- public void validate() throws Exception {
+ void validate() throws Exception {
if (!isOpen) {
return;
}
if (location == null) {
isOpen = false;
- this.gateBlockLocations = new HashSet();
- this.gateFrameBlocks = new HashSet();
+ this.gateBlockLocations = new HashSet<>();
+ this.gateFrameBlocks = new HashSet<>();
throw new Exception("Gate got closed. It has no location.");
}
if (exit == null) {
isOpen = false;
- this.gateBlockLocations = new HashSet();
- this.gateFrameBlocks = new HashSet();
+ this.gateBlockLocations = new HashSet<>();
+ this.gateFrameBlocks = new HashSet<>();
throw new Exception("Gate got closed. It has no exit.");
}
if (gateBlockLocations.size() == 0) {
isOpen = false;
- this.gateBlockLocations = new HashSet();
- this.gateFrameBlocks = new HashSet();
+ this.gateBlockLocations = new HashSet<>();
+ this.gateFrameBlocks = new HashSet<>();
throw new Exception("Gate got closed. The frame is missing or broken. (no gate blocks)");
}
@@ -230,8 +221,8 @@ public class Gate implements ConfigurationSerializable {
if (b.getType() == Material.AIR) {
isOpen = false;
- this.gateBlockLocations = new HashSet();
- this.gateFrameBlocks = new HashSet();
+ this.gateBlockLocations = new HashSet<>();
+ this.gateFrameBlocks = new HashSet<>();
throw new Exception("Gate got closed. The frame is missing or broken. (missing frame block(s))");
}
@@ -243,17 +234,17 @@ public class Gate implements ConfigurationSerializable {
/*
* INTERFACE: ConfigurationSerializable
*/
- static protected String idKey = "id";
- static protected String locationKey = "location";
- static protected String gateBlocksKey = "gateBlocks";
- static protected String exitKey = "exit";
- static protected String isHiddenKey = "hidden";
- static protected String isOpenKey = "open";
- static protected String locationYawKey = "locationYaw";
- static protected String locationPitchKey = "locationPitch";
- static protected String exitYawKey = "exitYaw";
- static protected String exitPitchKey = "exitPitch";
- static protected String allowsVehiclesKey = "allowsVehiclesKey";
+ static private String idKey = "id";
+ static private String locationKey = "location";
+ static private String gateBlocksKey = "gateBlocks";
+ static private String exitKey = "exit";
+ static private String isHiddenKey = "hidden";
+ static private String isOpenKey = "open";
+ static private String locationYawKey = "locationYaw";
+ static private String locationPitchKey = "locationPitch";
+ static private String exitYawKey = "exitYaw";
+ static private String exitPitchKey = "exitPitch";
+ static private String allowsVehiclesKey = "allowsVehiclesKey";
@SuppressWarnings("unchecked")
@@ -281,7 +272,7 @@ public class Gate implements ConfigurationSerializable {
allowsVehicles = (Boolean) map.get(allowsVehiclesKey);
}
- gateBlockLocations = new HashSet();
+ gateBlockLocations = new HashSet<>();
List