Skip to content

Commit ec5c928

Browse files
author
Dalton Caron
committed
1.19
1 parent e5cd60b commit ec5c928

File tree

6 files changed

+81
-291
lines changed

6 files changed

+81
-291
lines changed

pom.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,16 @@
4646
<scope>test</scope>
4747
</dependency>
4848
<dependency>
49-
<groupId>com.destroystokyo.paper</groupId>
49+
<groupId>io.papermc.paper</groupId>
5050
<artifactId>paper-api</artifactId>
51-
<version>1.16.4-R0.1-SNAPSHOT</version>
51+
<version>1.19-R0.1-SNAPSHOT</version>
5252
<scope>provided</scope>
5353
</dependency>
54+
<dependency>
55+
<groupId>org.projectlombok</groupId>
56+
<artifactId>lombok</artifactId>
57+
<version>1.18.24</version>
58+
<scope>provided</scope>
59+
</dependency>
5460
</dependencies>
5561
</project>

src/main/java/org/reliqcraft/Directions.java

Lines changed: 0 additions & 79 deletions
This file was deleted.

src/main/java/org/reliqcraft/Portcullis.java

Lines changed: 11 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,15 @@
2020
import org.bukkit.Material;
2121
import org.bukkit.block.BlockFace;
2222

23+
import lombok.EqualsAndHashCode;
24+
import lombok.Getter;
25+
import lombok.Setter;
26+
2327
/**
2428
*
2529
* @author pepijn
2630
*/
31+
@EqualsAndHashCode
2732
public class Portcullis {
2833
public Portcullis(String worldName, int x, int z, int y, int width, int height, BlockFace direction, Material type) {
2934
this.worldName = worldName;
@@ -36,91 +41,15 @@ public Portcullis(String worldName, int x, int z, int y, int width, int height,
3641
this.type = type;
3742
}
3843

39-
public String getWorldName() {
40-
return worldName;
41-
}
42-
43-
public BlockFace getDirection() {
44-
return direction;
45-
}
46-
47-
public int getHeight() {
48-
return height;
49-
}
50-
51-
public int getWidth() {
52-
return width;
53-
}
54-
55-
public int getX() {
56-
return x;
57-
}
58-
59-
public int getY() {
60-
return y;
61-
}
62-
63-
public void setY(int y) {
64-
this.y = y;
65-
}
66-
67-
public int getZ() {
68-
return z;
69-
}
70-
71-
public Material getType() {
72-
return type;
73-
}
74-
75-
@Override
76-
public boolean equals(Object obj) {
77-
if (obj == null) {
78-
return false;
79-
}
80-
if (getClass() != obj.getClass()) {
81-
return false;
82-
}
83-
final Portcullis other = (Portcullis) obj;
84-
if ((this.worldName == null) ? (other.worldName != null) : !this.worldName.equals(other.worldName)) {
85-
return false;
86-
}
87-
if (this.x != other.x) {
88-
return false;
89-
}
90-
if (this.z != other.z) {
91-
return false;
92-
}
93-
if (this.y != other.y) {
94-
return false;
95-
}
96-
if (this.width != other.width) {
97-
return false;
98-
}
99-
if (this.height != other.height) {
100-
return false;
101-
}
102-
if (this.direction != other.direction) {
103-
return false;
104-
}
105-
return true;
106-
}
107-
108-
@Override
109-
public int hashCode() {
110-
int hash = 3;
111-
hash = 29 * hash + (this.worldName != null ? this.worldName.hashCode() : 0);
112-
hash = 29 * hash + this.x;
113-
hash = 29 * hash + this.z;
114-
hash = 29 * hash + this.y;
115-
hash = 29 * hash + this.width;
116-
hash = 29 * hash + this.height;
117-
hash = 29 * hash + (this.direction != null ? this.direction.hashCode() : 0);
118-
return hash;
119-
}
120-
44+
@Getter
12145
private final String worldName;
46+
@Getter
12247
private final int x, z, width, height;
48+
@Getter
12349
private final Material type;
50+
@Getter
51+
@Setter
12452
private int y;
53+
@Getter
12554
private final BlockFace direction;
12655
}

src/main/java/org/reliqcraft/PortcullisBlockListener.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
import static org.bukkit.block.BlockFace.*;
3434
import org.bukkit.event.block.BlockRedstoneEvent;
3535

36-
import static org.reliqcraft.Directions.*;
37-
3836
/**
3937
*
4038
* @author pepijn
@@ -132,14 +130,13 @@ public void onBlockRedstoneChange(final BlockRedstoneEvent event) {
132130
}
133131

134132
private Portcullis findPortcullisInDirection(final Block block, final BlockFace direction) {
135-
final BlockFace actualDirection = actual(direction);
136-
final Block powerBlock = block.getRelative(actualDirection);
133+
final Block powerBlock = block.getRelative(direction);
137134
final Material powerBlockType = powerBlock.getBlockData().getMaterial();
138135
if (isPotentialPowerBlock(powerBlockType)) {
139136
if (logger.isLoggable(Level.FINE)) {
140137
logger.fine("[PorteCoulissante] Potential power block found (type: " + powerBlockType + ")");
141138
}
142-
final Block firstPortcullisBlock = powerBlock.getRelative(actualDirection);
139+
final Block firstPortcullisBlock = powerBlock.getRelative(direction);
143140
if (isPotentialPortcullisBlock(firstPortcullisBlock)) {
144141
final Material portcullisType = firstPortcullisBlock.getBlockData().getMaterial();
145142
if (logger.isLoggable(Level.FINE)) {
@@ -152,14 +149,14 @@ private Portcullis findPortcullisInDirection(final Block block, final BlockFace
152149
}
153150
return null;
154151
}
155-
Block lastPortCullisBlock = firstPortcullisBlock.getRelative(actualDirection);
152+
Block lastPortCullisBlock = firstPortcullisBlock.getRelative(direction);
156153
if (isPortcullisBlock(portcullisType,lastPortCullisBlock)) {
157154
int width = 2;
158-
Block nextBlock = lastPortCullisBlock.getRelative(actualDirection);
155+
Block nextBlock = lastPortCullisBlock.getRelative(direction);
159156
while (isPortcullisBlock(portcullisType, nextBlock)) {
160157
width++;
161158
lastPortCullisBlock = nextBlock;
162-
nextBlock = lastPortCullisBlock.getRelative(actualDirection);
159+
nextBlock = lastPortCullisBlock.getRelative(direction);
163160
}
164161
// At least two fences found in a row. Now search up and down
165162
int highestY = firstPortcullisBlock.getLocation().getBlockY();
@@ -190,8 +187,8 @@ private Portcullis findPortcullisInDirection(final Block block, final BlockFace
190187
if ((((i == -1) || (i == width)) && (dy != -1) && (dy != height))
191188
|| (((dy == -1) || (dy == height)) && (i != -1) && (i != width))) {
192189
// This is one of the blocks to the sides or above or below of the portcullis
193-
final Block frameBlock = world.getBlockAt(x + i * actualDirection.getModX(), y + dy,
194-
z + i * actualDirection.getModZ());
190+
final Block frameBlock = world.getBlockAt(x + i * direction.getModX(), y + dy,
191+
z + i * direction.getModZ());
195192
if (isPortcullisBlock(portcullisType, frameBlock)) {
196193
if (logger.isLoggable(Level.FINE)) {
197194
logger.fine(
@@ -201,8 +198,8 @@ private Portcullis findPortcullisInDirection(final Block block, final BlockFace
201198
}
202199
} else if ((i >= 0) && (i < width) && (dy >= 0) && (dy < height)) {
203200
// This is a portcullis block
204-
final Block portcullisBlock = world.getBlockAt(x + i * actualDirection.getModX(),
205-
y + dy, z + i * actualDirection.getModZ());
201+
final Block portcullisBlock = world.getBlockAt(x + i * direction.getModX(),
202+
y + dy, z + i * direction.getModZ());
206203
if (!isPortcullisBlock(portcullisType, portcullisBlock)) {
207204
if (logger.isLoggable(Level.FINE)) {
208205
logger.fine("[PorteCoulissante] Block of wrong type ("

0 commit comments

Comments
 (0)