Remove code duplication
Dieser Commit ist enthalten in:
Ursprung
5ca3217579
Commit
bdbb4c510b
@ -42,6 +42,21 @@ public class HellsBells {
|
|||||||
this.dz = dz;
|
this.dz = dz;
|
||||||
this.zLength = zLength;
|
this.zLength = zLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Direction other() {
|
||||||
|
switch (this) {
|
||||||
|
case NORTH:
|
||||||
|
return EAST;
|
||||||
|
case SOUTH:
|
||||||
|
return WEST;
|
||||||
|
case EAST:
|
||||||
|
return NORTH;
|
||||||
|
case WEST:
|
||||||
|
return SOUTH;
|
||||||
|
default:
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public HellsBells() {
|
public HellsBells() {
|
||||||
@ -141,19 +156,20 @@ public class HellsBells {
|
|||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (int z = 0; z < width; z++) {
|
for (int w = 0; w < width; w++) {
|
||||||
if (direction == Direction.NORTH || direction == Direction.WEST) {
|
if (direction == Direction.NORTH || direction == Direction.WEST) {
|
||||||
world.spawnEntity(redStart.subtractAndToLocation(world, direction.dx * length.get(), 0, direction.dz * length.get()), EntityType.PRIMED_TNT);
|
world.spawnEntity(redStart.subtractAndToLocation(world, direction.dx * length.get() + w * direction.other().dx, 0, direction.dz * length.get() + w * direction.other().dz), EntityType.PRIMED_TNT);
|
||||||
|
|
||||||
world.spawnEntity(blueStart.addAndToLocation(world, direction.dx * length.get(), 0, direction.dz * length.get()), EntityType.PRIMED_TNT);
|
world.spawnEntity(blueStart.addAndToLocation(world, direction.dx * length.get() + w * direction.other().dx, 0, direction.dz * length.get() + w * direction.other().dz), EntityType.PRIMED_TNT);
|
||||||
} else {
|
} else {
|
||||||
world.spawnEntity(redStart.addAndToLocation(world, direction.dx * length.get(), 0, direction.dz * length.get()), EntityType.PRIMED_TNT);
|
world.spawnEntity(redStart.addAndToLocation(world, direction.dx * length.get() + w * direction.other().dx, 0, direction.dz * length.get() + w * direction.other().dz), EntityType.PRIMED_TNT);
|
||||||
|
|
||||||
world.spawnEntity(blueStart.subtractAndToLocation(world, direction.dx * length.get(), 0, direction.dz * length.get()), EntityType.PRIMED_TNT);
|
world.spawnEntity(blueStart.subtractAndToLocation(world, direction.dx * length.get() + w * direction.other().dx, 0, direction.dz * length.get() + w * direction.other().dz), EntityType.PRIMED_TNT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length.decrementAndGet() == 0) {
|
length.decrementAndGet();
|
||||||
|
if (length.decrementAndGet() <= 0) {
|
||||||
cancel();
|
cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren