Archiviert
13
0

tower-generator #6

Zusammengeführt
YoyoNow hat 16 Commits von tower-generator nach master 2023-09-23 21:29:06 +02:00 zusammengeführt
9 geänderte Dateien mit 28 neuen und 22 gelöschten Zeilen
Nur Änderungen aus Commit a1acde76fd werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -58,6 +58,7 @@ public class WorldConfig {
public static final TowerGeneratorConfig TOWER_GENERATOR_CONFIG;
public static final List<WinCondition> WINCONDITIONS = new ArrayList<>();
static {
WINCONDITIONS.add(new LastRemainingWincondition());
WINCONDITIONS.add(new LastOutsideWincondition());

Datei anzeigen

@ -38,9 +38,13 @@ public abstract class Countdown extends GameStateToggleListener {
super(enabledStates);
}
int defaultTime() {return 0;}
int defaultTime() {
return 0;
}
void timerEnd() {}
boolean timerShouldCancel() {return true;}
boolean timerShouldCancel() {
return true;
}
void run() {}
void timerStart() {}
void timerReset() {}

Datei anzeigen

@ -32,7 +32,7 @@ public class EndCountdown extends Countdown {
private final LobbyCountdown lobbyCountdown;
private static boolean RESETS = Objects.requireNonNull(Bukkit.getWorlds().get(0).getWorldFolder().list((dir, name) -> name.equals("backup"))).length > 0;
private static final boolean RESETS = Objects.requireNonNull(Bukkit.getWorlds().get(0).getWorldFolder().list((dir, name) -> name.equals("backup"))).length > 0;
public EndCountdown(LobbyCountdown lobbyCountdown) {
super(EnumSet.of(GameStates.ENDING));

Datei anzeigen

@ -137,33 +137,33 @@ public class TowerRunGame {
});
}
private static double posToChunk(int pos){
private static double posToChunk(int pos) {
return pos / 16.0;
}
private static int getMinChunkX(){
private static int getMinChunkX() {
return (int) Math.floor(posToChunk(WorldConfig.MAP_MIN_X));
}
private static int getMaxChunkX(){
private static int getMaxChunkX() {
return (int) Math.ceil(posToChunk(WorldConfig.MAP_MAX_X));
}
private static int getMinChunkZ(){
private static int getMinChunkZ() {
return (int) Math.floor(posToChunk(WorldConfig.MAP_MIN_Z));
}
private static int getMaxChunkZ(){
private static int getMaxChunkZ() {
return (int) Math.ceil(posToChunk(WorldConfig.MAP_MAX_Z));
}
private static void forEachChunk(ObjIntConsumer<Integer> executor) {
for(int x = getMinChunkX(); x <= getMaxChunkX(); x++)
for(int z = getMinChunkZ(); z <= getMaxChunkZ(); z++)
for (int x = getMinChunkX(); x <= getMaxChunkX(); x++)
for (int z = getMinChunkZ(); z <= getMaxChunkZ(); z++)
executor.accept(x, z);
}
private static void resetWorld(){
private static void resetWorld() {
world.getEntities().stream().filter(entity -> entity.getType() != EntityType.PLAYER).forEach(Entity::remove);
World backup = new WorldCreator(world.getName() + "/backup").createWorld();
@ -178,7 +178,7 @@ public class TowerRunGame {
System.arraycopy(backupChunk.d(), 0, chunk.d(), 0, chunk.d().length);
for(Player p : Bukkit.getOnlinePlayers())
for (Player p : Bukkit.getOnlinePlayers())
CraftbukkitWrapper.impl.sendChunk(p, x, z);
}
}

Datei anzeigen

@ -31,8 +31,8 @@ public class TowerGenerator {
YoyoNow markierte diese Unterhaltung als gelöst Veraltet
Veraltet
Review

Could be final,
Could be static

Could be final, Could be static
private static final Random random = new Random();
YoyoNow markierte diese Unterhaltung als gelöst Veraltet
Veraltet
Review

could be final

could be final
private final WorldConfig.TowerGeneratorConfig config;
YoyoNow markierte diese Unterhaltung als gelöst Veraltet
Veraltet
Review

Attribute sind im camelCase

Attribute sind im camelCase
private List<SchematicNode> allSchematics;
private Clipboard roof;
private final List<SchematicNode> allSchematics;
private final Clipboard roof;
@Getter
private int height;

Datei anzeigen

@ -48,7 +48,7 @@ import java.util.*;
public class IngameListener extends GameStateBukkitListener {
private int time = 0;
private Map<Integer, List<Block>> blocksToMelt = new HashMap<>();
private final Map<Integer, List<Block>> blocksToMelt = new HashMap<>();
private BukkitRunnable runnable;
public IngameListener() {
@ -123,7 +123,7 @@ public class IngameListener extends GameStateBukkitListener {
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
if(event.getDamager().getType() == EntityType.PLAYER) {
if (event.getDamager().getType() == EntityType.PLAYER) {
event.setCancelled(true);
}
}

Datei anzeigen

@ -57,7 +57,7 @@ public class LobbyListener extends GameStateBukkitListener {
if (TowerRun.getTowerGenerator() != null) {
return;
}
if(event.getTo().getY() < WorldConfig.SPAWN.getY() - 10) {
if (event.getTo().getY() < WorldConfig.SPAWN.getY() - 10) {
event.getPlayer().teleport(WorldConfig.SPAWN);
}
}

Datei anzeigen

@ -28,12 +28,13 @@ public abstract class GameStateToggleListener extends GameStateListener {
protected GameStateToggleListener(EnumSet<GameStates> enabledStates) {
super();
this.enabledStates = enabledStates;
if(enabledStates.contains(GameState.getCurrentState())) {
if (enabledStates.contains(GameState.getCurrentState())) {
enable();
}
}
public abstract void enable();
public abstract void disable();
@Override

Datei anzeigen

@ -26,7 +26,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.PlayerDeathEvent;
public class LastOutsideWincondition extends OutsideWincondition{
public class LastOutsideWincondition extends OutsideWincondition {
public LastOutsideWincondition() {
super("LAST_OUTSIDE");
}
@ -42,8 +42,8 @@ public class LastOutsideWincondition extends OutsideWincondition{
@EventHandler(priority = EventPriority.LOW)
public void onPlayerDeath(PlayerDeathEvent event) {
if(TowerRunGame.PLAYERS_ALIVE.isEmpty()) {
if(TowerRunGame.PLAYERS_ESCAPED.isEmpty()) {
if (TowerRunGame.PLAYERS_ALIVE.isEmpty()) {
if (TowerRunGame.PLAYERS_ESCAPED.isEmpty()) {
TowerRunGame.tie();
return;
}