SteamWar/FightSystem
Archiviert
13
1

Remove code duplication

Dieser Commit ist enthalten in:
yoyosource 2021-05-13 23:47:10 +02:00
Ursprung 5ca3217579
Commit bdbb4c510b

Datei anzeigen

@ -42,6 +42,21 @@ public class HellsBells {
this.dz = dz;
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() {
@ -141,19 +156,20 @@ public class HellsBells {
new BukkitRunnable() {
@Override
public void run() {
for (int z = 0; z < width; z++) {
for (int w = 0; w < width; w++) {
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 {
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();
}
}