12
1

HellsBells #275

Manuell gemergt
Lixfel hat 19 Commits von Hells_bells nach master 2021-06-25 07:17:45 +02:00 zusammengeführt
Nur Änderungen aus Commit bdbb4c510b werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -42,6 +42,21 @@ public class HellsBells {
this.dz = dz;
this.zLength = zLength;
}
Veraltet
Review

Subklassen bitte nach dem Inhalt der Hauptklasse.

Subklassen bitte nach dem Inhalt der Hauptklasse.
Direction other() {
switch (this) {
case NORTH:
return EAST;
case SOUTH:
return WEST;
Veraltet
Review

Warum das nochmal extra vorhalten? In getRandom kann ja auch values() aufgerufen werden...

Warum das nochmal extra vorhalten? In getRandom kann ja auch values() aufgerufen werden...
Veraltet
Review

values() auf einem Enum erzeugt immer eine kopie der Enum Elemente intern, daher recht inefficient.

values() auf einem Enum erzeugt immer eine kopie der Enum Elemente intern, daher recht inefficient.
Veraltet
Review

Ich finde, es ist ineffizienter, eine Kopie ständig im RAM zu halten, als alle x Minuten mal eine neue Kopie des 4! Elemente großen Array anzulegen. Ist zudem kürzer und einfacher, einfach neu zu kopieren.

Ich finde, es ist ineffizienter, eine Kopie ständig im RAM zu halten, als alle x Minuten mal eine neue Kopie des 4! Elemente großen Array anzulegen. Ist zudem kürzer und einfacher, einfach neu zu kopieren.
case EAST:
return NORTH;
case WEST:
return SOUTH;
default:
return this;
}
}
}
public HellsBells() {
@ -141,19 +156,20 @@ public class HellsBells {
new BukkitRunnable() {
YoyoNow markierte diese Unterhaltung als gelöst Veraltet
Veraltet
Review

Üblicherweise verwenden wir eher Bukkit...getScheduler().runTaskTimer(Plugin, lambda-Methode, Zeit(en))

Üblicherweise verwenden wir eher Bukkit...getScheduler().runTaskTimer(Plugin, lambda-Methode, Zeit(en))
@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();
}
}