Archiviert
13
0

Commits vergleichen

..

Keine gemeinsamen Commits. "99994de4fdd8e4d552662ad1b782b9d21c4ec26e" und "8642a5f4d822305c374a0e860f8091e38c3eb778" haben vollständig unterschiedliche Historien.

8 geänderte Dateien mit 15 neuen und 105 gelöschten Zeilen

Datei anzeigen

@ -30,6 +30,5 @@ SERVER_RESET=
KEY_NAME=§eKey KEY_NAME=§eKey
KEY_FOUND=§a{0} §7found a key§8! KEY_FOUND=§a{0} §7found a key§8!
GAME_TIE=§aThe game ended in a tie§8! GAME_TIE=§aThe game ended in a tie§8!
GAME_TIME=§a{0}:{1}
COMMAND_START=§aThe game will start soon§8! COMMAND_START=§aThe game will start soon§8!

Datei anzeigen

@ -23,7 +23,6 @@ import de.steamwar.message.Message;
import de.steamwar.towerrun.commands.StartCommand; import de.steamwar.towerrun.commands.StartCommand;
import de.steamwar.towerrun.config.WorldConfig; import de.steamwar.towerrun.config.WorldConfig;
import de.steamwar.towerrun.countdowns.EndCountdown; import de.steamwar.towerrun.countdowns.EndCountdown;
import de.steamwar.towerrun.countdowns.GameCountdown;
import de.steamwar.towerrun.countdowns.LobbyCountdown; import de.steamwar.towerrun.countdowns.LobbyCountdown;
import de.steamwar.towerrun.game.TowerRunGame; import de.steamwar.towerrun.game.TowerRunGame;
import de.steamwar.towerrun.generator.TowerGenerator; import de.steamwar.towerrun.generator.TowerGenerator;
@ -56,10 +55,6 @@ public class TowerRun extends JavaPlugin {
@Getter @Getter
private static TowerGenerator towerGenerator = null; private static TowerGenerator towerGenerator = null;
@Getter
private static GameCountdown gameCountdown;
@Override @Override
public void onEnable() { public void onEnable() {
instance = this; instance = this;
@ -77,7 +72,6 @@ public class TowerRun extends JavaPlugin {
final LobbyCountdown lobbyCountdown = new LobbyCountdown(); final LobbyCountdown lobbyCountdown = new LobbyCountdown();
new EndCountdown(lobbyCountdown); new EndCountdown(lobbyCountdown);
new StartCommand(lobbyCountdown); new StartCommand(lobbyCountdown);
gameCountdown = new GameCountdown();
TowerRunGame.reset(); TowerRunGame.reset();
} }

Datei anzeigen

@ -36,8 +36,6 @@ public class Config {
public static final int MIN_PLAYERS; public static final int MIN_PLAYERS;
public static final int LOBBY_TIMER; public static final int LOBBY_TIMER;
public static final Set<Material> DESTROYABLE_BLOCKS; public static final Set<Material> DESTROYABLE_BLOCKS;
public static final int GAME_TIMER;
public static final int GAME_ESCAPE_TIMER;
static { static {
File configFile = new File(TowerRun.getInstance().getDataFolder(), "config.yml"); File configFile = new File(TowerRun.getInstance().getDataFolder(), "config.yml");
@ -50,8 +48,6 @@ public class Config {
MIN_PLAYERS = config.getInt("minPlayers"); MIN_PLAYERS = config.getInt("minPlayers");
LOBBY_TIMER = config.getInt("lobbyTimer"); LOBBY_TIMER = config.getInt("lobbyTimer");
GAME_TIMER = config.getInt("gameTimer", 20 * 60);
GAME_ESCAPE_TIMER = config.getInt("gameEscapeTimer", 60);
DESTROYABLE_BLOCKS = EnumSet.copyOf(config.getStringList("destroyable").stream().map(Material::valueOf).collect(Collectors.toSet())); DESTROYABLE_BLOCKS = EnumSet.copyOf(config.getStringList("destroyable").stream().map(Material::valueOf).collect(Collectors.toSet()));
} }

Datei anzeigen

@ -1,61 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.towerrun.countdowns;
import de.steamwar.towerrun.TowerRun;
import de.steamwar.towerrun.config.Config;
import de.steamwar.towerrun.game.TowerRunGame;
import de.steamwar.towerrun.state.GameStates;
import java.util.EnumSet;
public class GameCountdown extends Countdown {
public GameCountdown() {
super(EnumSet.of(GameStates.INGAME));
}
@Override
int defaultTime() {
return Config.GAME_TIMER;
}
@Override
void timerEnd() {
if (TowerRunGame.PLAYERS_ESCAPED.isEmpty()) {
TowerRunGame.tie();
} else {
TowerRunGame.win(TowerRunGame.PLAYERS_ESCAPED.get(TowerRunGame.PLAYERS_ESCAPED.size() - 1));
}
}
@Override
boolean timerShouldCancel() {
return false;
}
@Override
void run() {
int timeMinutes = Math.floorDiv(time, 60);
int timeSeconds = time % 60;
TowerRun.getMessage().broadcastActionbar("GAME_TIME", String.format("%02d", timeMinutes), String.format("%02d", timeSeconds));
}
}

Datei anzeigen

@ -44,9 +44,6 @@ public record TowerRunPlayer(Player player) {
} }
public void reset() { public void reset() {
player.getInventory().clear();
player.updateInventory();
player.setHealth(20);
if (TowerRun.getTowerGenerator() != null) { if (TowerRun.getTowerGenerator() != null) {
player.teleport(TowerRun.getTowerGenerator().getSpawn()); player.teleport(TowerRun.getTowerGenerator().getSpawn());
} else { } else {

Datei anzeigen

@ -21,6 +21,8 @@ import org.bukkit.Material;
import org.bukkit.block.*; import org.bukkit.block.*;
import org.bukkit.block.data.Bisected; import org.bukkit.block.data.Bisected;
import org.bukkit.block.data.type.Door; import org.bukkit.block.data.type.Door;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import java.io.File; import java.io.File;
@ -44,9 +46,6 @@ public class TowerGenerator {
@Getter @Getter
private Location spawn; private Location spawn;
@Getter
private List<Location> keys = new ArrayList<>();
public TowerGenerator(WorldConfig.TowerGeneratorConfig config) { public TowerGenerator(WorldConfig.TowerGeneratorConfig config) {
File file = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "Roof.schem"); File file = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "Roof.schem");
if (!file.exists()) { if (!file.exists()) {
@ -81,7 +80,6 @@ public class TowerGenerator {
{ {
noBombFloors = random.nextInt(config.maxNoBombFloors - config.minNoBombFloors) + config.minNoBombFloors; noBombFloors = random.nextInt(config.maxNoBombFloors - config.minNoBombFloors) + config.minNoBombFloors;
noKeyFloors = random.nextInt(config.maxNoKeyFloors - config.minNoKeyFloors) + config.minNoKeyFloors; noKeyFloors = random.nextInt(config.maxNoKeyFloors - config.minNoKeyFloors) + config.minNoKeyFloors;
keys.clear();
} }
@Override @Override
@ -139,8 +137,8 @@ public class TowerGenerator {
noKeyFloors--; noKeyFloors--;
if (!chestBlocks.isEmpty() && noKeyFloors < 0 && random.nextDouble() < config.keyChance) { if (!chestBlocks.isEmpty() && noKeyFloors < 0 && random.nextDouble() < config.keyChance) {
noKeyFloors = random.nextInt(config.maxNoKeyFloors - config.minNoKeyFloors) + config.minNoKeyFloors; noKeyFloors = random.nextInt(config.maxNoKeyFloors - config.minNoKeyFloors) + config.minNoKeyFloors;
Container container = chestBlocks.get(random.nextInt(chestBlocks.size())); Inventory inventory = chestBlocks.get(random.nextInt(chestBlocks.size())).getInventory();
keys.add(container.getLocation()); inventory.addItem(new ItemStack(Material.LEVER, 1));
for (WorldConfig.TowerGeneratorDoorBlock doorBlock : config.doorBlocks) { for (WorldConfig.TowerGeneratorDoorBlock doorBlock : config.doorBlocks) {
int x = doorBlock.getX(); int x = doorBlock.getX();
@ -149,7 +147,7 @@ public class TowerGenerator {
Block block = Bukkit.getWorlds().get(0).getBlockAt(x, y, z); Block block = Bukkit.getWorlds().get(0).getBlockAt(x, y, z);
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
if (block.getType().isAir()) { if (block.getType().isAir()) {
block.setType(Material.IRON_BLOCK, false); block.setType(Material.IRON_BLOCK, true);
block = block.getRelative(0, 1, 0); block = block.getRelative(0, 1, 0);
} else { } else {
break; break;
@ -158,21 +156,21 @@ public class TowerGenerator {
Bukkit.getScheduler().runTaskLater(TowerRun.getInstance(), () -> { Bukkit.getScheduler().runTaskLater(TowerRun.getInstance(), () -> {
Block door = Bukkit.getWorlds().get(0).getBlockAt(x, y, z); Block door = Bukkit.getWorlds().get(0).getBlockAt(x, y, z);
door.setType(Material.IRON_DOOR, false); door.setType(Material.IRON_DOOR, true);
door = door.getRelative(0, 1, 0); door = door.getRelative(0, 1, 0);
door.setType(Material.IRON_DOOR, false); door.setType(Material.IRON_DOOR, true);
}, 10); }, 10);
Bukkit.getScheduler().runTaskLater(TowerRun.getInstance(), () -> { Bukkit.getScheduler().runTaskLater(TowerRun.getInstance(), () -> {
Block door = Bukkit.getWorlds().get(0).getBlockAt(x, y, z); Block door = Bukkit.getWorlds().get(0).getBlockAt(x, y, z);
Door doorState = (Door) door.getBlockData(); Door doorState = (Door) door.getBlockData();
doorState.setFacing(BlockFace.EAST); doorState.setFacing(BlockFace.EAST);
door.setBlockData(doorState, false); door.setBlockData(doorState, true);
door = door.getRelative(0, 1, 0); door = door.getRelative(0, 1, 0);
doorState = (Door) door.getBlockData(); doorState = (Door) door.getBlockData();
doorState.setFacing(BlockFace.EAST); doorState.setFacing(BlockFace.EAST);
doorState.setHalf(Bisected.Half.TOP); doorState.setHalf(Bisected.Half.TOP);
door.setBlockData(doorState, false); door.setBlockData(doorState, true);
}, 20); }, 20);
} }
} }

Datei anzeigen

@ -25,7 +25,10 @@ import de.steamwar.towerrun.config.Config;
import de.steamwar.towerrun.config.WorldConfig; import de.steamwar.towerrun.config.WorldConfig;
import de.steamwar.towerrun.state.GameStateBukkitListener; import de.steamwar.towerrun.state.GameStateBukkitListener;
import de.steamwar.towerrun.state.GameStates; import de.steamwar.towerrun.state.GameStates;
import org.bukkit.*; import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -41,7 +44,6 @@ import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import java.util.*; import java.util.*;
import java.util.stream.Stream;
public class IngameListener extends GameStateBukkitListener { public class IngameListener extends GameStateBukkitListener {
@ -86,11 +88,6 @@ public class IngameListener extends GameStateBukkitListener {
@EventHandler @EventHandler
public void onPlayerDeath(PlayerDeathEvent event) { public void onPlayerDeath(PlayerDeathEvent event) {
event.setDeathMessage(null); event.setDeathMessage(null);
if (TowerRun.getTowerGenerator() != null) {
event.getEntity().teleport(TowerRun.getTowerGenerator().getSpawn());
} else {
event.getEntity().teleport(WorldConfig.SPAWN);
}
event.getEntity().setGameMode(GameMode.SPECTATOR); event.getEntity().setGameMode(GameMode.SPECTATOR);
Bukkit.getOnlinePlayers().forEach(player -> { Bukkit.getOnlinePlayers().forEach(player -> {
player.sendTitle("", TowerRun.getMessage().parse("PLAYER_DIED", player, event.getEntity().getPlayer().getName()), 10, 70, 20); player.sendTitle("", TowerRun.getMessage().parse("PLAYER_DIED", player, event.getEntity().getPlayer().getName()), 10, 70, 20);
@ -133,10 +130,6 @@ public class IngameListener extends GameStateBukkitListener {
@EventHandler @EventHandler
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getPlayer().getGameMode() != GameMode.SURVIVAL) {
return;
}
if (event.getAction() != Action.RIGHT_CLICK_BLOCK || !event.hasBlock()) { if (event.getAction() != Action.RIGHT_CLICK_BLOCK || !event.hasBlock()) {
return; return;
} }
@ -145,15 +138,13 @@ public class IngameListener extends GameStateBukkitListener {
return; return;
} }
Stream<Location> locations = TowerRun.getTowerGenerator() == null ? Arrays.stream(WorldConfig.KEYS) : TowerRun.getTowerGenerator().getKeys().stream(); if (Arrays.stream(WorldConfig.KEYS).noneMatch(location -> location.equals(event.getClickedBlock().getLocation()))) {
if (locations.noneMatch(location -> location.equals(event.getClickedBlock().getLocation()))) {
event.getClickedBlock().setType(Material.AIR);
return; return;
} }
event.getPlayer().getInventory().addItem(new SWItem(Material.LEVER, TowerRun.getMessage().parse("KEY_NAME", event.getPlayer())).getItemStack()); event.getPlayer().getInventory().addItem(new SWItem(Material.LEVER, TowerRun.getMessage().parse("KEY_NAME", event.getPlayer())).getItemStack());
event.getClickedBlock().setType(Material.ENDER_CHEST); event.getClickedBlock().setType(Material.AIR);
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.BLOCK_ENDER_CHEST_OPEN, 1, 1); event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.BLOCK_ENDER_CHEST_OPEN, 1, 1);
TowerRun.getMessage().broadcast("KEY_FOUND", event.getPlayer().getName()); TowerRun.getMessage().broadcast("KEY_FOUND", event.getPlayer().getName());
} }

Datei anzeigen

@ -20,7 +20,6 @@
package de.steamwar.towerrun.winconditions; package de.steamwar.towerrun.winconditions;
import de.steamwar.towerrun.TowerRun; import de.steamwar.towerrun.TowerRun;
import de.steamwar.towerrun.config.Config;
import de.steamwar.towerrun.config.WorldConfig; import de.steamwar.towerrun.config.WorldConfig;
import de.steamwar.towerrun.game.TowerRunGame; import de.steamwar.towerrun.game.TowerRunGame;
import de.steamwar.towerrun.game.TowerRunPlayer; import de.steamwar.towerrun.game.TowerRunPlayer;
@ -66,8 +65,5 @@ public abstract class OutsideWincondition extends WinCondition {
TowerRunGame.PLAYERS_ALIVE.remove(towerRunPlayer); TowerRunGame.PLAYERS_ALIVE.remove(towerRunPlayer);
towerRunPlayer.player().setGameMode(GameMode.SPECTATOR); towerRunPlayer.player().setGameMode(GameMode.SPECTATOR);
TowerRun.getMessage().broadcast("PLAYER_ESCAPE", towerRunPlayer.player().getName()); TowerRun.getMessage().broadcast("PLAYER_ESCAPE", towerRunPlayer.player().getName());
if (TowerRunGame.PLAYERS_ESCAPED.size() == 1) {
TowerRun.getGameCountdown().setTime(Config.GAME_ESCAPE_TIMER);
}
} }
} }