Commits vergleichen
Keine gemeinsamen Commits. "24a5c3e99596fbd17e054b6d6ee569e732da2abd" und "0e9ba50cde8ccae55d0682243b625bee51248430" haben vollständig unterschiedliche Historien.
24a5c3e995
...
0e9ba50cde
@ -16,49 +16,6 @@ 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
|
||||||
@ -88,10 +45,10 @@ towerGenerator:
|
|||||||
percentage: 1.0
|
percentage: 1.0
|
||||||
material: MANGROVE_ROOTS
|
material: MANGROVE_ROOTS
|
||||||
|
|
||||||
minX: -28
|
minX: -40
|
||||||
maxX: 98
|
maxX: 109
|
||||||
minZ: -27
|
minZ: -40
|
||||||
maxZ: 107
|
maxZ: 119
|
||||||
|
|
||||||
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("SpigotCore")
|
@Dependency(value = "SpigotCore")
|
||||||
@Author("YoyoNow")
|
@Author(value = "YoyoNow")
|
||||||
@Author("Chaoscaot")
|
@Author(value = "Chaoscaot")
|
||||||
@Description("SteamWar TowerRun Plugin")
|
@Description(value = "SteamWar TowerRun Plugin")
|
||||||
@ApiVersion(ApiVersion.Target.v1_19)
|
|
||||||
public class TowerRun extends JavaPlugin {
|
public class TowerRun extends JavaPlugin {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@ -35,7 +35,8 @@ 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.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class WorldConfig {
|
public class WorldConfig {
|
||||||
@ -54,7 +55,6 @@ 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,17 +160,6 @@ 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));
|
||||||
|
|
||||||
@ -214,7 +203,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[] fillRegions;
|
public final TowerGeneratorFillRegion[] FILL_REGIONS;
|
||||||
|
|
||||||
public TowerGeneratorConfig(ConfigurationSection section) {
|
public TowerGeneratorConfig(ConfigurationSection section) {
|
||||||
x = section.getInt("x");
|
x = section.getInt("x");
|
||||||
@ -228,12 +217,12 @@ public class WorldConfig {
|
|||||||
.map(fillRegionsSection::getConfigurationSection)
|
.map(fillRegionsSection::getConfigurationSection)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
this.fillRegions = new TowerGeneratorFillRegion[fillRegions.size()];
|
FILL_REGIONS = new TowerGeneratorFillRegion[fillRegions.size()];
|
||||||
for (int i = 0; i < fillRegions.size(); i++) {
|
for (int i = 0; i < fillRegions.size(); i++) {
|
||||||
this.fillRegions[i] = new TowerGeneratorFillRegion(fillRegions.get(i));
|
FILL_REGIONS[i] = new TowerGeneratorFillRegion(fillRegions.get(i));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fillRegions = new TowerGeneratorFillRegion[0];
|
FILL_REGIONS = new TowerGeneratorFillRegion[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class LobbyCountdown extends Countdown {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
void timerEnd() {
|
void timerEnd() {
|
||||||
TowerRunGame.prepareTowerOrStart();
|
TowerRunGame.prepareTower();
|
||||||
override = false;
|
override = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ public class TowerRunGame {
|
|||||||
return PLAYERS_ALIVE.contains(player);
|
return PLAYERS_ALIVE.contains(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void prepareTowerOrStart() {
|
public static void prepareTower() {
|
||||||
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();
|
TowerRun.getTowerGenerator().generate(TowerRunGame::start);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("Game is already running!");
|
throw new IllegalStateException("Game is already running!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void start() {
|
private 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(TowerRun.getTowerGenerator().getSpawn());
|
player.teleport(WorldConfig.SPAWN.clone().add(0, TowerRun.getTowerGenerator().getHeight(), 0));
|
||||||
} else {
|
} else {
|
||||||
player.teleport(WorldConfig.SPAWN);
|
player.teleport(WorldConfig.SPAWN);
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,11 @@ 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;
|
||||||
|
|
||||||
@ -29,27 +28,24 @@ import java.util.Random;
|
|||||||
|
|
||||||
public class TowerGenerator {
|
public class TowerGenerator {
|
||||||
|
|
||||||
private static final Random random = new Random();
|
private Random random = new Random();
|
||||||
private final WorldConfig.TowerGeneratorConfig config;
|
private WorldConfig.TowerGeneratorConfig config;
|
||||||
private List<SchematicNode> allSchematics;
|
private List<SchematicNode> ALL_SCHEMATICS;
|
||||||
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();
|
||||||
throw new SecurityException("TowerRun schematic not found");
|
return;
|
||||||
}
|
}
|
||||||
roof = loadSchematic(file);
|
roof = loadSchematic(file);
|
||||||
|
|
||||||
this.config = config;
|
this.config = config;
|
||||||
allSchematics = SchematicNode.getAllSchematicsOfType(config.schematicType);
|
ALL_SCHEMATICS = SchematicNode.getAllSchematicsOfType(config.schematicType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Clipboard loadSchematic(File file) {
|
private Clipboard loadSchematic(File file) {
|
||||||
@ -63,7 +59,7 @@ public class TowerGenerator {
|
|||||||
return clipboard;
|
return clipboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generate() {
|
public void generate(Runnable finishRunnable) {
|
||||||
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;
|
||||||
@ -75,7 +71,7 @@ public class TowerGenerator {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (height > 0) {
|
if (height > 0) {
|
||||||
SchematicNode schematicNode = allSchematics.get(random.nextInt(allSchematics.size()));
|
SchematicNode schematicNode = ALL_SCHEMATICS.get(random.nextInt(ALL_SCHEMATICS.size()));
|
||||||
SchematicData schematicData = new SchematicData(schematicNode);
|
SchematicData schematicData = new SchematicData(schematicNode);
|
||||||
int currentY;
|
int currentY;
|
||||||
try {
|
try {
|
||||||
@ -88,12 +84,11 @@ 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) {
|
||||||
allSchematics.remove(schematicNode);
|
ALL_SCHEMATICS.remove(schematicNode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
spawn = WorldConfig.SPAWN.clone().add(0, y, 0);
|
|
||||||
|
|
||||||
for (WorldConfig.TowerGeneratorFillRegion fillRegion : config.fillRegions) {
|
for (WorldConfig.TowerGeneratorFillRegion fillRegion : config.FILL_REGIONS) {
|
||||||
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++) {
|
||||||
@ -114,7 +109,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());
|
||||||
}
|
}
|
||||||
TowerRunGame.start();
|
finishRunnable.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskTimer(TowerRun.getInstance(), 0, 10);
|
}.runTaskTimer(TowerRun.getInstance(), 0, 10);
|
||||||
|
@ -26,69 +26,30 @@ 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.*;
|
import java.util.Arrays;
|
||||||
|
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);
|
||||||
@ -152,31 +113,9 @@ 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(TowerRun.getTowerGenerator().getSpawn());
|
event.setRespawnLocation(WorldConfig.SPAWN.clone().add(0, TowerRun.getTowerGenerator().getHeight(), 0));
|
||||||
} 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,6 +23,7 @@ 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;
|
||||||
@ -44,7 +45,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(TowerRun.getTowerGenerator().getSpawn());
|
player.teleport(WorldConfig.SPAWN.clone().add(0, TowerRun.getTowerGenerator().getHeight(), 0));
|
||||||
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(TowerRun.getTowerGenerator().getSpawn());
|
event.getPlayer().teleport(WorldConfig.SPAWN.clone().add(0, TowerRun.getTowerGenerator().getHeight(), 0));
|
||||||
} else {
|
} else {
|
||||||
event.getPlayer().teleport(WorldConfig.SPAWN);
|
event.getPlayer().teleport(WorldConfig.SPAWN);
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ 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{
|
||||||
@ -40,7 +39,7 @@ public class LastOutsideWincondition extends OutsideWincondition{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler
|
||||||
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