Commits vergleichen
5 Commits
0e9ba50cde
...
24a5c3e995
Autor | SHA1 | Datum | |
---|---|---|---|
|
24a5c3e995 | ||
|
bbaefaac8f | ||
|
98147fe721 | ||
|
2f9c035925 | ||
|
aa2290dac8 |
@ -16,6 +16,49 @@ tower:
|
|||||||
keys: []
|
keys: []
|
||||||
lavaY: 76
|
lavaY: 76
|
||||||
laveSpace: 9
|
laveSpace: 9
|
||||||
|
meltingBlocks:
|
||||||
|
SMOOTH_STONE: 120
|
||||||
|
SMOOTH_STONE_SLAB: 60
|
||||||
|
ANDESITE: 120
|
||||||
|
JUKEBOX: 10
|
||||||
|
IRON_BLOCK: 240
|
||||||
|
END_STONE: 240
|
||||||
|
REDSTONE_LAMP: 30
|
||||||
|
GLASS: 30
|
||||||
|
GLASS_PANE: 3
|
||||||
|
TINTED_GLASS: 30
|
||||||
|
WHITE_STAINED_GLASS: 30
|
||||||
|
WHITE_STAINED_GLASS_PANE: 3
|
||||||
|
ORANGE_STAINED_GLASS: 30
|
||||||
|
ORANGE_STAINED_GLASS_PANE: 3
|
||||||
|
MAGENTA_STAINED_GLASS: 30
|
||||||
|
MAGENTA_STAINED_GLASS_PANE: 3
|
||||||
|
LIGHT_BLUE_STAINED_GLASS: 30
|
||||||
|
LIGHT_BLUE_STAINED_GLASS_PANE: 3
|
||||||
|
YELLOW_STAINED_GLASS: 30
|
||||||
|
YELLOW_STAINED_GLASS_PANE: 3
|
||||||
|
LIME_STAINED_GLASS: 30
|
||||||
|
LIME_STAINED_GLASS_PANE: 3
|
||||||
|
PINK_STAINED_GLASS: 30
|
||||||
|
PINK_STAINED_GLASS_PANE: 3
|
||||||
|
GRAY_STAINED_GLASS: 30
|
||||||
|
GRAY_STAINED_GLASS_PANE: 3
|
||||||
|
LIGHT_GRAY_STAINED_GLASS: 30
|
||||||
|
LIGHT_GRAY_STAINED_GLASS_PANE: 3
|
||||||
|
CYAN_STAINED_GLASS: 30
|
||||||
|
CYAN_STAINED_GLASS_PANE: 3
|
||||||
|
PURPLE_STAINED_GLASS: 30
|
||||||
|
PURPLE_STAINED_GLASS_PANE: 3
|
||||||
|
BLUE_STAINED_GLASS: 30
|
||||||
|
BLUE_STAINED_GLASS_PANE: 3
|
||||||
|
BROWN_STAINED_GLASS: 30
|
||||||
|
BROWN_STAINED_GLASS_PANE: 3
|
||||||
|
GREEN_STAINED_GLASS: 30
|
||||||
|
GREEN_STAINED_GLASS_PANE: 3
|
||||||
|
RED_STAINED_GLASS: 30
|
||||||
|
RED_STAINED_GLASS_PANE: 3
|
||||||
|
BLACK_STAINED_GLASS: 30
|
||||||
|
BLACK_STAINED_GLASS_PANE: 3
|
||||||
|
|
||||||
towerGenerator:
|
towerGenerator:
|
||||||
x: 0
|
x: 0
|
||||||
@ -45,10 +88,10 @@ towerGenerator:
|
|||||||
percentage: 1.0
|
percentage: 1.0
|
||||||
material: MANGROVE_ROOTS
|
material: MANGROVE_ROOTS
|
||||||
|
|
||||||
minX: -40
|
minX: -28
|
||||||
maxX: 109
|
maxX: 98
|
||||||
minZ: -40
|
minZ: -27
|
||||||
maxZ: 119
|
maxZ: 107
|
||||||
|
|
||||||
winconditions:
|
winconditions:
|
||||||
- LAST_REMAINING
|
- LAST_REMAINING
|
||||||
|
@ -33,17 +33,17 @@ import de.steamwar.towerrun.listener.NotLobbyListener;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.plugin.java.annotation.dependency.Dependency;
|
import org.bukkit.plugin.java.annotation.dependency.Dependency;
|
||||||
|
import org.bukkit.plugin.java.annotation.plugin.ApiVersion;
|
||||||
import org.bukkit.plugin.java.annotation.plugin.Description;
|
import org.bukkit.plugin.java.annotation.plugin.Description;
|
||||||
import org.bukkit.plugin.java.annotation.plugin.Plugin;
|
import org.bukkit.plugin.java.annotation.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.annotation.plugin.author.Author;
|
import org.bukkit.plugin.java.annotation.plugin.author.Author;
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Plugin(name = "TowerRun", version = "1.0.0")
|
@Plugin(name = "TowerRun", version = "1.0.0")
|
||||||
@Dependency(value = "SpigotCore")
|
@Dependency("SpigotCore")
|
||||||
@Author(value = "YoyoNow")
|
@Author("YoyoNow")
|
||||||
@Author(value = "Chaoscaot")
|
@Author("Chaoscaot")
|
||||||
@Description(value = "SteamWar TowerRun Plugin")
|
@Description("SteamWar TowerRun Plugin")
|
||||||
|
@ApiVersion(ApiVersion.Target.v1_19)
|
||||||
public class TowerRun extends JavaPlugin {
|
public class TowerRun extends JavaPlugin {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@ -35,8 +35,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class WorldConfig {
|
public class WorldConfig {
|
||||||
@ -55,6 +54,7 @@ public class WorldConfig {
|
|||||||
public static final int MAP_MIN_Z;
|
public static final int MAP_MIN_Z;
|
||||||
public static final int MAP_MAX_X;
|
public static final int MAP_MAX_X;
|
||||||
public static final int MAP_MAX_Z;
|
public static final int MAP_MAX_Z;
|
||||||
|
public static final Map<Material, Integer> MELTING_TIMES;
|
||||||
public static final TowerGeneratorConfig TOWER_GENERATOR_CONFIG;
|
public static final TowerGeneratorConfig TOWER_GENERATOR_CONFIG;
|
||||||
|
|
||||||
public static final List<WinCondition> WINCONDITIONS = new ArrayList<>();
|
public static final List<WinCondition> WINCONDITIONS = new ArrayList<>();
|
||||||
@ -160,6 +160,17 @@ public class WorldConfig {
|
|||||||
MAP_MAX_X = config.getInt("maxX");
|
MAP_MAX_X = config.getInt("maxX");
|
||||||
MAP_MAX_Z = config.getInt("maxZ");
|
MAP_MAX_Z = config.getInt("maxZ");
|
||||||
|
|
||||||
|
ConfigurationSection meltingBlocksSection = tower.getConfigurationSection("meltingBlocks");
|
||||||
|
if (meltingBlocksSection != null) {
|
||||||
|
Map<Material, Integer> meltingTimes = new HashMap<>();
|
||||||
|
meltingBlocksSection.getKeys(false).forEach(s -> {
|
||||||
|
meltingTimes.put(Material.valueOf(s), meltingBlocksSection.getInt(s));
|
||||||
|
});
|
||||||
|
MELTING_TIMES = Collections.unmodifiableMap(meltingTimes);
|
||||||
|
} else {
|
||||||
|
MELTING_TIMES = Collections.emptyMap();
|
||||||
|
}
|
||||||
|
|
||||||
ACTIVE_WINCONDITIONS = config.getStringList("winconditions");
|
ACTIVE_WINCONDITIONS = config.getStringList("winconditions");
|
||||||
WINCONDITIONS.stream().filter(winCondition -> ACTIVE_WINCONDITIONS.contains(winCondition.getName())).forEach(winCondition -> winCondition.setActive(true));
|
WINCONDITIONS.stream().filter(winCondition -> ACTIVE_WINCONDITIONS.contains(winCondition.getName())).forEach(winCondition -> winCondition.setActive(true));
|
||||||
|
|
||||||
@ -203,7 +214,7 @@ public class WorldConfig {
|
|||||||
public final int y;
|
public final int y;
|
||||||
public final int z;
|
public final int z;
|
||||||
public final SchematicType schematicType;
|
public final SchematicType schematicType;
|
||||||
public final TowerGeneratorFillRegion[] FILL_REGIONS;
|
public final TowerGeneratorFillRegion[] fillRegions;
|
||||||
|
|
||||||
public TowerGeneratorConfig(ConfigurationSection section) {
|
public TowerGeneratorConfig(ConfigurationSection section) {
|
||||||
x = section.getInt("x");
|
x = section.getInt("x");
|
||||||
@ -217,12 +228,12 @@ public class WorldConfig {
|
|||||||
.map(fillRegionsSection::getConfigurationSection)
|
.map(fillRegionsSection::getConfigurationSection)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
FILL_REGIONS = new TowerGeneratorFillRegion[fillRegions.size()];
|
this.fillRegions = new TowerGeneratorFillRegion[fillRegions.size()];
|
||||||
for (int i = 0; i < fillRegions.size(); i++) {
|
for (int i = 0; i < fillRegions.size(); i++) {
|
||||||
FILL_REGIONS[i] = new TowerGeneratorFillRegion(fillRegions.get(i));
|
this.fillRegions[i] = new TowerGeneratorFillRegion(fillRegions.get(i));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FILL_REGIONS = new TowerGeneratorFillRegion[0];
|
fillRegions = new TowerGeneratorFillRegion[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class LobbyCountdown extends Countdown {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
void timerEnd() {
|
void timerEnd() {
|
||||||
TowerRunGame.prepareTower();
|
TowerRunGame.prepareTowerOrStart();
|
||||||
override = false;
|
override = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ public class TowerRunGame {
|
|||||||
return PLAYERS_ALIVE.contains(player);
|
return PLAYERS_ALIVE.contains(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void prepareTower() {
|
public static void prepareTowerOrStart() {
|
||||||
if (GameState.getCurrentState() == GameStates.LOBBY) {
|
if (GameState.getCurrentState() == GameStates.LOBBY) {
|
||||||
GameState.nextState();
|
GameState.nextState();
|
||||||
if (TowerRun.getTowerGenerator() == null) {
|
if (TowerRun.getTowerGenerator() == null) {
|
||||||
@ -56,13 +56,13 @@ public class TowerRunGame {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TowerRun.getTowerGenerator().generate(TowerRunGame::start);
|
TowerRun.getTowerGenerator().generate();
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("Game is already running!");
|
throw new IllegalStateException("Game is already running!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void start() {
|
public static void start() {
|
||||||
if (GameState.getCurrentState() == GameStates.GENERATING_TOWER) {
|
if (GameState.getCurrentState() == GameStates.GENERATING_TOWER) {
|
||||||
PLAYERS_ALIVE.addAll(TowerRunPlayer.getAll());
|
PLAYERS_ALIVE.addAll(TowerRunPlayer.getAll());
|
||||||
PLAYERS_ALIVE.forEach(p -> {
|
PLAYERS_ALIVE.forEach(p -> {
|
||||||
|
@ -45,7 +45,7 @@ public record TowerRunPlayer(Player player) {
|
|||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
if (TowerRun.getTowerGenerator() != null) {
|
if (TowerRun.getTowerGenerator() != null) {
|
||||||
player.teleport(WorldConfig.SPAWN.clone().add(0, TowerRun.getTowerGenerator().getHeight(), 0));
|
player.teleport(TowerRun.getTowerGenerator().getSpawn());
|
||||||
} else {
|
} else {
|
||||||
player.teleport(WorldConfig.SPAWN);
|
player.teleport(WorldConfig.SPAWN);
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,12 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
import de.steamwar.sql.SchematicData;
|
import de.steamwar.sql.SchematicData;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import de.steamwar.sql.SchematicType;
|
|
||||||
import de.steamwar.towerrun.TowerRun;
|
import de.steamwar.towerrun.TowerRun;
|
||||||
import de.steamwar.towerrun.config.WorldConfig;
|
import de.steamwar.towerrun.config.WorldConfig;
|
||||||
|
import de.steamwar.towerrun.game.TowerRunGame;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
@ -28,24 +29,27 @@ import java.util.Random;
|
|||||||
|
|
||||||
public class TowerGenerator {
|
public class TowerGenerator {
|
||||||
|
|
||||||
private Random random = new Random();
|
private static final Random random = new Random();
|
||||||
private WorldConfig.TowerGeneratorConfig config;
|
private final WorldConfig.TowerGeneratorConfig config;
|
||||||
private List<SchematicNode> ALL_SCHEMATICS;
|
private List<SchematicNode> allSchematics;
|
||||||
private Clipboard roof;
|
private Clipboard roof;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private int height;
|
private int height;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private Location spawn;
|
||||||
|
|
||||||
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()) {
|
||||||
Bukkit.shutdown();
|
Bukkit.shutdown();
|
||||||
return;
|
throw new SecurityException("TowerRun schematic not found");
|
||||||
}
|
}
|
||||||
roof = loadSchematic(file);
|
roof = loadSchematic(file);
|
||||||
|
|
||||||
this.config = config;
|
this.config = config;
|
||||||
ALL_SCHEMATICS = SchematicNode.getAllSchematicsOfType(config.schematicType);
|
allSchematics = SchematicNode.getAllSchematicsOfType(config.schematicType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Clipboard loadSchematic(File file) {
|
private Clipboard loadSchematic(File file) {
|
||||||
@ -59,7 +63,7 @@ public class TowerGenerator {
|
|||||||
return clipboard;
|
return clipboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generate(Runnable finishRunnable) {
|
public void generate() {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
int height = random.nextInt(50) + 200;
|
int height = random.nextInt(50) + 200;
|
||||||
int y = TowerGenerator.this.config.y;
|
int y = TowerGenerator.this.config.y;
|
||||||
@ -71,7 +75,7 @@ public class TowerGenerator {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (height > 0) {
|
if (height > 0) {
|
||||||
SchematicNode schematicNode = ALL_SCHEMATICS.get(random.nextInt(ALL_SCHEMATICS.size()));
|
SchematicNode schematicNode = allSchematics.get(random.nextInt(allSchematics.size()));
|
||||||
SchematicData schematicData = new SchematicData(schematicNode);
|
SchematicData schematicData = new SchematicData(schematicNode);
|
||||||
int currentY;
|
int currentY;
|
||||||
try {
|
try {
|
||||||
@ -84,11 +88,12 @@ public class TowerGenerator {
|
|||||||
y += clipboard.getDimensions().getY();
|
y += clipboard.getDimensions().getY();
|
||||||
height -= clipboard.getDimensions().getY();
|
height -= clipboard.getDimensions().getY();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
ALL_SCHEMATICS.remove(schematicNode);
|
allSchematics.remove(schematicNode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
spawn = WorldConfig.SPAWN.clone().add(0, y, 0);
|
||||||
|
|
||||||
for (WorldConfig.TowerGeneratorFillRegion fillRegion : config.FILL_REGIONS) {
|
for (WorldConfig.TowerGeneratorFillRegion fillRegion : config.fillRegions) {
|
||||||
for (int x = fillRegion.getMinX(); x < fillRegion.getMaxX(); x++) {
|
for (int x = fillRegion.getMinX(); x < fillRegion.getMaxX(); x++) {
|
||||||
for (int z = fillRegion.getMinZ(); z < fillRegion.getMaxZ(); z++) {
|
for (int z = fillRegion.getMinZ(); z < fillRegion.getMaxZ(); z++) {
|
||||||
for (int y = currentY; y < this.y; y++) {
|
for (int y = currentY; y < this.y; y++) {
|
||||||
@ -109,7 +114,7 @@ public class TowerGenerator {
|
|||||||
ClipboardHolder ch = new ClipboardHolder(roof);
|
ClipboardHolder ch = new ClipboardHolder(roof);
|
||||||
Operations.completeBlindly(ch.createPaste(e).to(BlockVector3.at(config.x, y, config.z)).build());
|
Operations.completeBlindly(ch.createPaste(e).to(BlockVector3.at(config.x, y, config.z)).build());
|
||||||
}
|
}
|
||||||
finishRunnable.run();
|
TowerRunGame.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskTimer(TowerRun.getInstance(), 0, 10);
|
}.runTaskTimer(TowerRun.getInstance(), 0, 10);
|
||||||
|
@ -26,30 +26,69 @@ 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.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
|
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;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
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.event.player.PlayerRespawnEvent;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.EnumSet;
|
|
||||||
|
|
||||||
public class IngameListener extends GameStateBukkitListener {
|
public class IngameListener extends GameStateBukkitListener {
|
||||||
|
|
||||||
|
private int time = 0;
|
||||||
|
private Map<Integer, List<Block>> blocksToMelt = new HashMap<>();
|
||||||
|
private BukkitRunnable runnable;
|
||||||
|
|
||||||
public IngameListener() {
|
public IngameListener() {
|
||||||
super(EnumSet.of(GameStates.INGAME));
|
super(EnumSet.of(GameStates.INGAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enable() {
|
||||||
|
super.enable();
|
||||||
|
runnable = new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
List<Block> blocks = blocksToMelt.get(time);
|
||||||
|
time++;
|
||||||
|
if (blocks == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
blocks.forEach(block -> {
|
||||||
|
if (!WorldConfig.MELTING_TIMES.containsKey(block.getType())) return;
|
||||||
|
block.setType(Material.AIR);
|
||||||
|
block.getWorld().playSound(block.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 0.1F, 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
runnable.runTaskTimer(TowerRun.getInstance(), 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
super.disable();
|
||||||
|
runnable.cancel();
|
||||||
|
runnable = null;
|
||||||
|
blocksToMelt.clear();
|
||||||
|
time = 0;
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||||
event.setDeathMessage(null);
|
event.setDeathMessage(null);
|
||||||
|
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);
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_WITHER_DEATH, 1, 1);
|
player.playSound(player.getLocation(), Sound.ENTITY_WITHER_DEATH, 1, 1);
|
||||||
@ -113,9 +152,31 @@ public class IngameListener extends GameStateBukkitListener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||||
if (TowerRun.getTowerGenerator() != null) {
|
if (TowerRun.getTowerGenerator() != null) {
|
||||||
event.setRespawnLocation(WorldConfig.SPAWN.clone().add(0, TowerRun.getTowerGenerator().getHeight(), 0));
|
event.setRespawnLocation(TowerRun.getTowerGenerator().getSpawn());
|
||||||
} else {
|
} else {
|
||||||
event.setRespawnLocation(WorldConfig.SPAWN);
|
event.setRespawnLocation(WorldConfig.SPAWN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||||
|
if (event.getSourceBlock().getType() != Material.LAVA) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Block block = event.getSourceBlock();
|
||||||
|
shouldMelt(block.getRelative(0, 1, 0));
|
||||||
|
shouldMelt(block.getRelative(0, -1, 0));
|
||||||
|
shouldMelt(block.getRelative(1, 0, 0));
|
||||||
|
shouldMelt(block.getRelative(-1, 0, 0));
|
||||||
|
shouldMelt(block.getRelative(0, 0, 1));
|
||||||
|
shouldMelt(block.getRelative(0, 0, -1));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void shouldMelt(Block block) {
|
||||||
|
int meltingTime = WorldConfig.MELTING_TIMES.getOrDefault(block.getType(), -1);
|
||||||
|
if (meltingTime == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
blocksToMelt.computeIfAbsent(time + meltingTime * 20, integer -> new ArrayList<>()).add(block);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ import de.steamwar.towerrun.TowerRun;
|
|||||||
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.Bukkit;
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -45,7 +44,7 @@ public class LobbyListener extends GameStateBukkitListener {
|
|||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (TowerRun.getTowerGenerator() != null) {
|
if (TowerRun.getTowerGenerator() != null) {
|
||||||
player.teleport(WorldConfig.SPAWN.clone().add(0, TowerRun.getTowerGenerator().getHeight(), 0));
|
player.teleport(TowerRun.getTowerGenerator().getSpawn());
|
||||||
player.setGameMode(GameMode.SPECTATOR);
|
player.setGameMode(GameMode.SPECTATOR);
|
||||||
} else {
|
} else {
|
||||||
player.teleport(WorldConfig.SPAWN);
|
player.teleport(WorldConfig.SPAWN);
|
||||||
|
@ -38,7 +38,7 @@ public class NotLobbyListener extends GameStateBukkitListener {
|
|||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
event.getPlayer().setGameMode(GameMode.SPECTATOR);
|
event.getPlayer().setGameMode(GameMode.SPECTATOR);
|
||||||
if (TowerRun.getTowerGenerator() != null) {
|
if (TowerRun.getTowerGenerator() != null) {
|
||||||
event.getPlayer().teleport(WorldConfig.SPAWN.clone().add(0, TowerRun.getTowerGenerator().getHeight(), 0));
|
event.getPlayer().teleport(TowerRun.getTowerGenerator().getSpawn());
|
||||||
} else {
|
} else {
|
||||||
event.getPlayer().teleport(WorldConfig.SPAWN);
|
event.getPlayer().teleport(WorldConfig.SPAWN);
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import de.steamwar.towerrun.game.TowerRunGame;
|
|||||||
import de.steamwar.towerrun.game.TowerRunPlayer;
|
import de.steamwar.towerrun.game.TowerRunPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
|
||||||
public class LastOutsideWincondition extends OutsideWincondition{
|
public class LastOutsideWincondition extends OutsideWincondition{
|
||||||
@ -39,7 +40,7 @@ public class LastOutsideWincondition extends OutsideWincondition{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||||
if(TowerRunGame.PLAYERS_ALIVE.isEmpty()) {
|
if(TowerRunGame.PLAYERS_ALIVE.isEmpty()) {
|
||||||
if(TowerRunGame.PLAYERS_ESCAPED.isEmpty()) {
|
if(TowerRunGame.PLAYERS_ESCAPED.isEmpty()) {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren