tower-generator #6
@ -31,5 +31,6 @@ KEY_NAME=
|
||||
KEY_FOUND=§a{0} §7found a key§8!
|
||||
GAME_TIE=§aThe game ended in a tie§8!
|
||||
GAME_TIME=§a{0}:{1}
|
||||
CATCH_UP_WARNING=§4!! §cYou should catch up §4!!
|
||||
|
||||
COMMAND_START=§aThe game will start soon§8!
|
@ -30,4 +30,6 @@ GAME_TIE=
|
||||
KEY_NAME=§eSchlüssel
|
||||
KEY_FOUND=§a{0} §7hat einen Schlüssel gefunden§8!
|
||||
|
||||
CATCH_UP_WARNING=§4!! §cDu solltest aufholen §4!!
|
||||
|
||||
COMMAND_START=§7Das Spiel startet bald§8!
|
@ -37,8 +37,10 @@ public class StartCommand extends SWCommand {
|
||||
|
||||
@Register
|
||||
public void command(@Validator Player player) {
|
||||
countdown.setOverride(true);
|
||||
countdown.setTime(10);
|
||||
if (countdown.getTime() > 10) {
|
||||
countdown.setOverride(true);
|
||||
countdown.setTime(10);
|
||||
}
|
||||
TowerRun.getMessage().send("COMMAND_START", player);
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ package de.steamwar.towerrun.countdowns;
|
||||
import de.steamwar.towerrun.TowerRun;
|
||||
import de.steamwar.towerrun.state.GameStateToggleListener;
|
||||
import de.steamwar.towerrun.state.GameStates;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
@ -31,6 +32,7 @@ import java.util.EnumSet;
|
||||
public abstract class Countdown extends GameStateToggleListener {
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
protected int time = defaultTime();
|
||||
protected BukkitTask task;
|
||||
|
||||
|
@ -23,6 +23,7 @@ import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.towerrun.TowerRun;
|
||||
import de.steamwar.towerrun.config.Config;
|
||||
import de.steamwar.towerrun.config.WorldConfig;
|
||||
import de.steamwar.towerrun.game.TowerRunGame;
|
||||
import de.steamwar.towerrun.state.GameStateBukkitListener;
|
||||
import de.steamwar.towerrun.state.GameStates;
|
||||
import org.bukkit.*;
|
||||
@ -37,17 +38,18 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class IngameListener extends GameStateBukkitListener {
|
||||
|
||||
private int time = 0;
|
||||
private final Map<Integer, List<Block>> blocksToMelt = new HashMap<>();
|
||||
private BukkitRunnable runnable;
|
||||
private BukkitRunnable blocksToMeltRunnable;
|
||||
private BukkitRunnable antiCampRunnable;
|
||||
|
||||
public IngameListener() {
|
||||
super(EnumSet.of(GameStates.INGAME));
|
||||
@ -56,7 +58,7 @@ public class IngameListener extends GameStateBukkitListener {
|
||||
@Override
|
||||
public void enable() {
|
||||
super.enable();
|
||||
runnable = new BukkitRunnable() {
|
||||
blocksToMeltRunnable = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
List<Block> blocks = blocksToMelt.get(time);
|
||||
@ -71,26 +73,52 @@ public class IngameListener extends GameStateBukkitListener {
|
||||
});
|
||||
}
|
||||
};
|
||||
runnable.runTaskTimer(TowerRun.getInstance(), 0, 1);
|
||||
blocksToMeltRunnable.runTaskTimer(TowerRun.getInstance(), 0, 1);
|
||||
|
||||
antiCampRunnable = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
double minY = TowerRunGame.PLAYERS_ALIVE.stream()
|
||||
.map(p -> p.player().getLocation().getY())
|
||||
.min(Comparator.comparing(Function.identity()))
|
||||
.orElse(0.0);
|
||||
|
||||
TowerRunGame.PLAYERS_ALIVE.forEach(towerRunPlayer -> {
|
||||
if (towerRunPlayer.player().getLocation().getY() - minY > 20) {
|
||||
towerRunPlayer.player().sendTitle("§a", TowerRun.getMessage().parse("CATCH_UP_WARNING", towerRunPlayer.player()), 5, 30, 5);
|
||||
}
|
||||
if (towerRunPlayer.player().getLocation().getY() - minY > 30) {
|
||||
towerRunPlayer.player().damage(1.0);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
antiCampRunnable.runTaskTimer(TowerRun.getInstance(), 100, 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
super.disable();
|
||||
runnable.cancel();
|
||||
runnable = null;
|
||||
blocksToMeltRunnable.cancel();
|
||||
blocksToMeltRunnable = null;
|
||||
blocksToMelt.clear();
|
||||
time = 0;
|
||||
|
||||
antiCampRunnable.cancel();
|
||||
antiCampRunnable = null;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||
event.setDeathMessage(null);
|
||||
if (TowerRun.getTowerGenerator() != null) {
|
||||
event.getEntity().teleport(TowerRun.getTowerGenerator().getSpawn());
|
||||
} else {
|
||||
event.getEntity().teleport(WorldConfig.SPAWN);
|
||||
}
|
||||
Bukkit.getScheduler().runTaskLater(TowerRun.getInstance(), () -> {
|
||||
if (TowerRun.getTowerGenerator() != null) {
|
||||
event.getEntity().teleport(TowerRun.getTowerGenerator().getSpawn());
|
||||
YoyoNow markierte diese Unterhaltung als gelöst
Veraltet
|
||||
} else {
|
||||
event.getEntity().teleport(WorldConfig.SPAWN);
|
||||
}
|
||||
}, 5
|
||||
);
|
||||
event.getEntity().setGameMode(GameMode.SPECTATOR);
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
player.sendTitle("", TowerRun.getMessage().parse("PLAYER_DIED", player, event.getEntity().getPlayer().getName()), 10, 70, 20);
|
||||
@ -158,15 +186,6 @@ public class IngameListener extends GameStateBukkitListener {
|
||||
TowerRun.getMessage().broadcast("KEY_FOUND", event.getPlayer().getName());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
if (TowerRun.getTowerGenerator() != null) {
|
||||
event.setRespawnLocation(TowerRun.getTowerGenerator().getSpawn());
|
||||
} else {
|
||||
event.setRespawnLocation(WorldConfig.SPAWN);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||
if (event.getSourceBlock().getType() != Material.LAVA) {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren
vllt. in den TowerGenerator ne höhen angepasste Location reinlegen, dann muss man die nicht immer neuberechnen