tower-generator #6
@ -31,5 +31,6 @@ KEY_NAME=
|
|||||||
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}
|
GAME_TIME=§a{0}:{1}
|
||||||
|
CATCH_UP_WARNING=§4!! §cYou should catch up §4!!
|
||||||
|
|
||||||
COMMAND_START=§aThe game will start soon§8!
|
COMMAND_START=§aThe game will start soon§8!
|
@ -30,4 +30,6 @@ GAME_TIE=
|
|||||||
KEY_NAME=§eSchlüssel
|
KEY_NAME=§eSchlüssel
|
||||||
KEY_FOUND=§a{0} §7hat einen Schlüssel gefunden§8!
|
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!
|
COMMAND_START=§7Das Spiel startet bald§8!
|
@ -37,8 +37,10 @@ public class StartCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void command(@Validator Player player) {
|
public void command(@Validator Player player) {
|
||||||
countdown.setOverride(true);
|
if (countdown.getTime() > 10) {
|
||||||
countdown.setTime(10);
|
countdown.setOverride(true);
|
||||||
|
countdown.setTime(10);
|
||||||
|
}
|
||||||
TowerRun.getMessage().send("COMMAND_START", player);
|
TowerRun.getMessage().send("COMMAND_START", player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ package de.steamwar.towerrun.countdowns;
|
|||||||
import de.steamwar.towerrun.TowerRun;
|
import de.steamwar.towerrun.TowerRun;
|
||||||
import de.steamwar.towerrun.state.GameStateToggleListener;
|
import de.steamwar.towerrun.state.GameStateToggleListener;
|
||||||
import de.steamwar.towerrun.state.GameStates;
|
import de.steamwar.towerrun.state.GameStates;
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
@ -31,6 +32,7 @@ import java.util.EnumSet;
|
|||||||
public abstract class Countdown extends GameStateToggleListener {
|
public abstract class Countdown extends GameStateToggleListener {
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
|
@Getter
|
||||||
protected int time = defaultTime();
|
protected int time = defaultTime();
|
||||||
protected BukkitTask task;
|
protected BukkitTask task;
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ import de.steamwar.inventory.SWItem;
|
|||||||
import de.steamwar.towerrun.TowerRun;
|
import de.steamwar.towerrun.TowerRun;
|
||||||
import de.steamwar.towerrun.config.Config;
|
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.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.*;
|
||||||
@ -37,17 +38,18 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|||||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
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.function.Function;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class IngameListener extends GameStateBukkitListener {
|
public class IngameListener extends GameStateBukkitListener {
|
||||||
|
|
||||||
private int time = 0;
|
private int time = 0;
|
||||||
private final Map<Integer, List<Block>> blocksToMelt = new HashMap<>();
|
private final Map<Integer, List<Block>> blocksToMelt = new HashMap<>();
|
||||||
private BukkitRunnable runnable;
|
private BukkitRunnable blocksToMeltRunnable;
|
||||||
|
private BukkitRunnable antiCampRunnable;
|
||||||
|
|
||||||
public IngameListener() {
|
public IngameListener() {
|
||||||
super(EnumSet.of(GameStates.INGAME));
|
super(EnumSet.of(GameStates.INGAME));
|
||||||
@ -56,7 +58,7 @@ public class IngameListener extends GameStateBukkitListener {
|
|||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
super.enable();
|
super.enable();
|
||||||
runnable = new BukkitRunnable() {
|
blocksToMeltRunnable = new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
List<Block> blocks = blocksToMelt.get(time);
|
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
|
@Override
|
||||||
public void disable() {
|
public void disable() {
|
||||||
super.disable();
|
super.disable();
|
||||||
runnable.cancel();
|
blocksToMeltRunnable.cancel();
|
||||||
runnable = null;
|
blocksToMeltRunnable = null;
|
||||||
blocksToMelt.clear();
|
blocksToMelt.clear();
|
||||||
time = 0;
|
time = 0;
|
||||||
|
|
||||||
|
antiCampRunnable.cancel();
|
||||||
|
antiCampRunnable = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||||
event.setDeathMessage(null);
|
event.setDeathMessage(null);
|
||||||
if (TowerRun.getTowerGenerator() != null) {
|
Bukkit.getScheduler().runTaskLater(TowerRun.getInstance(), () -> {
|
||||||
event.getEntity().teleport(TowerRun.getTowerGenerator().getSpawn());
|
if (TowerRun.getTowerGenerator() != null) {
|
||||||
} else {
|
event.getEntity().teleport(TowerRun.getTowerGenerator().getSpawn());
|
||||||
event.getEntity().teleport(WorldConfig.SPAWN);
|
} else {
|
||||||
}
|
event.getEntity().teleport(WorldConfig.SPAWN);
|
||||||
|
}
|
||||||
|
}, 5
|
||||||
|
);
|
||||||
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);
|
||||||
@ -158,15 +186,6 @@ public class IngameListener extends GameStateBukkitListener {
|
|||||||
TowerRun.getMessage().broadcast("KEY_FOUND", event.getPlayer().getName());
|
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
|
@EventHandler
|
||||||
public void onBlockPhysics(BlockPhysicsEvent event) {
|
public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||||
if (event.getSourceBlock().getType() != Material.LAVA) {
|
if (event.getSourceBlock().getType() != Material.LAVA) {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren