tower-generator #6
@ -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());
|
||||
@ -65,7 +66,7 @@ public class WorldConfig {
|
||||
}
|
||||
|
||||
private static Location parseLocation(ConfigurationSection section) {
|
||||
Location loc = new Location(
|
||||
Location loc = new Location(
|
||||
Bukkit.getWorlds().get(0),
|
||||
section.getDouble("x"),
|
||||
section.getDouble("y"),
|
||||
|
@ -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() {}
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ public class TowerGenerator {
|
||||
|
||||
private static final Random random = new Random();
|
||||
private final WorldConfig.TowerGeneratorConfig config;
|
||||
private List<SchematicNode> allSchematics;
|
||||
private Clipboard roof;
|
||||
private final List<SchematicNode> allSchematics;
|
||||
private final Clipboard roof;
|
||||
|
||||
@Getter
|
||||
private int height;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren