t
This commit is contained in:
parent
8cb6f1d901
commit
980743ef62
@ -18,6 +18,7 @@ import rip.tilly.bedwars.game.arena.CopiedArena;
|
|||||||
import rip.tilly.bedwars.generators.Generator;
|
import rip.tilly.bedwars.generators.Generator;
|
||||||
import rip.tilly.bedwars.generators.GeneratorTier;
|
import rip.tilly.bedwars.generators.GeneratorTier;
|
||||||
import rip.tilly.bedwars.generators.GeneratorType;
|
import rip.tilly.bedwars.generators.GeneratorType;
|
||||||
|
import rip.tilly.bedwars.playerdata.PlayerData;
|
||||||
import rip.tilly.bedwars.utils.CC;
|
import rip.tilly.bedwars.utils.CC;
|
||||||
import rip.tilly.bedwars.utils.CustomLocation;
|
import rip.tilly.bedwars.utils.CustomLocation;
|
||||||
import rip.tilly.bedwars.utils.TimeUtils;
|
import rip.tilly.bedwars.utils.TimeUtils;
|
||||||
@ -85,6 +86,12 @@ public class Game {
|
|||||||
this.teams.forEach(team -> team.playingPlayers().forEach(player -> player.sendTitle(title)));
|
this.teams.forEach(team -> team.playingPlayers().forEach(player -> player.sendTitle(title)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void broadcastTitleToOneTeam(String message, String subMessage, GameTeam gameTeam) {
|
||||||
|
Title title = new Title(CC.translate(message), CC.translate(subMessage), 5, 20, 5);
|
||||||
|
|
||||||
|
this.teams.stream().filter(team -> team == gameTeam).forEach(team -> team.playingPlayers().forEach(player -> player.sendTitle(title)));
|
||||||
|
}
|
||||||
|
|
||||||
public void broadcast(String message) {
|
public void broadcast(String message) {
|
||||||
this.teams.forEach(team -> team.playingPlayers().forEach(player -> player.sendMessage(CC.translate(message))));
|
this.teams.forEach(team -> team.playingPlayers().forEach(player -> player.sendMessage(CC.translate(message))));
|
||||||
}
|
}
|
||||||
@ -306,4 +313,16 @@ public class Game {
|
|||||||
this.addEntityToRemove(teamAUpgradesVillager);
|
this.addEntityToRemove(teamAUpgradesVillager);
|
||||||
this.addEntityToRemove(teamBUpgradesVillager);
|
this.addEntityToRemove(teamBUpgradesVillager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean checkTrapStatus(Player player) {
|
||||||
|
PlayerData playerData = this.plugin.getPlayerDataManager().getPlayerData(player.getUniqueId());
|
||||||
|
|
||||||
|
GameTeam gameTeam = this.getTeams().get(playerData.getTeamId());
|
||||||
|
|
||||||
|
if (player.getLocation().distance((gameTeam.getId() == 0 ? this.copiedArena.getA().toBukkitLocation() : this.copiedArena.getB().toBukkitLocation())) < 15) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,9 @@ import rip.tilly.bedwars.game.GameState;
|
|||||||
import rip.tilly.bedwars.events.PlayerKillEvent;
|
import rip.tilly.bedwars.events.PlayerKillEvent;
|
||||||
import rip.tilly.bedwars.playerdata.PlayerData;
|
import rip.tilly.bedwars.playerdata.PlayerData;
|
||||||
import rip.tilly.bedwars.playerdata.PlayerState;
|
import rip.tilly.bedwars.playerdata.PlayerState;
|
||||||
|
import rip.tilly.bedwars.playerdata.currentgame.PlayerCurrentGameData;
|
||||||
|
import rip.tilly.bedwars.upgrades.Upgrade;
|
||||||
|
import rip.tilly.bedwars.utils.CC;
|
||||||
|
|
||||||
public class MovementListener implements Listener {
|
public class MovementListener implements Listener {
|
||||||
|
|
||||||
@ -24,11 +27,13 @@ public class MovementListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (player.getGameMode() == GameMode.CREATIVE && player.isOp()) {
|
if (player.getGameMode() == GameMode.CREATIVE && player.isOp()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerData playerData = this.plugin.getPlayerDataManager().getPlayerData(player.getUniqueId());
|
PlayerData playerData = this.plugin.getPlayerDataManager().getPlayerData(player.getUniqueId());
|
||||||
|
|
||||||
if (playerData == null) {
|
if (playerData == null) {
|
||||||
this.plugin.getLogger().warning(player.getName() + "'s player data is null");
|
this.plugin.getLogger().warning(player.getName() + "'s player data is null");
|
||||||
return;
|
return;
|
||||||
@ -56,6 +61,26 @@ public class MovementListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (game.getGameState() == GameState.FIGHTING) {
|
||||||
|
game.getTeams().forEach(gameTeam -> {
|
||||||
|
gameTeam.playingPlayers().forEach(teamPlayer -> {
|
||||||
|
PlayerData teamPlayerData = this.plugin.getPlayerDataManager().getPlayerData(teamPlayer.getUniqueId());
|
||||||
|
|
||||||
|
PlayerCurrentGameData teamPlayerCurrentGameData = teamPlayerData.getCurrentGameData();
|
||||||
|
|
||||||
|
if (teamPlayerCurrentGameData.getLevelForUpgrade(Upgrade.TRAP) != 0) {
|
||||||
|
if (game.checkTrapStatus(player)) {
|
||||||
|
teamPlayerCurrentGameData.getUpgrades().remove(Upgrade.TRAP);
|
||||||
|
|
||||||
|
teamPlayer.sendMessage(CC.translate("&cYour trap has been activated"));
|
||||||
|
|
||||||
|
game.broadcastTitleToOneTeam("&cTRAP ACTIVATED", "&eYour trap has been activated", gameTeam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (game.getGameState() != GameState.ENDING) {
|
if (game.getGameState() != GameState.ENDING) {
|
||||||
if (player.getLocation().getY() <= game.getArena().getDeadZone()) {
|
if (player.getLocation().getY() <= game.getArena().getDeadZone()) {
|
||||||
Player killer = playerData.getLastDamager();
|
Player killer = playerData.getLastDamager();
|
||||||
|
@ -13,8 +13,6 @@ public class GameRunnable extends BukkitRunnable {
|
|||||||
|
|
||||||
private Game game;
|
private Game game;
|
||||||
|
|
||||||
private int amount;
|
|
||||||
|
|
||||||
public GameRunnable(Game game) {
|
public GameRunnable(Game game) {
|
||||||
this.game = game;
|
this.game = game;
|
||||||
}
|
}
|
||||||
@ -33,9 +31,8 @@ public class GameRunnable extends BukkitRunnable {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case FIGHTING:
|
case FIGHTING:
|
||||||
this.amount++;
|
|
||||||
this.game.incrementDuration();
|
this.game.incrementDuration();
|
||||||
this.game.tick(this.amount, this.game);
|
this.game.tick(this.game.getDurationTimer(), this.game);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ENDING:
|
case ENDING:
|
||||||
|
34
src/main/java/rip/tilly/bedwars/utils/LocationUtils.java
Normal file
34
src/main/java/rip/tilly/bedwars/utils/LocationUtils.java
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package rip.tilly.bedwars.utils;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class LocationUtils {
|
||||||
|
|
||||||
|
public static List<Block> getBlocks(Location center, int radius) {
|
||||||
|
return getBlocks(center, radius, radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Block> getBlocks(Location center, int radius, int yRadius) {
|
||||||
|
if (radius < 0) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
int iterations = radius * 2 + 1;
|
||||||
|
|
||||||
|
List<Block> blocks = new ArrayList<>(iterations * iterations * iterations);
|
||||||
|
|
||||||
|
for (int x = -radius; x <= radius; x++) {
|
||||||
|
for (int y = -yRadius; y <= yRadius; y++) {
|
||||||
|
for (int z = -radius; z <= radius; z++) {
|
||||||
|
blocks.add(center.getBlock().getRelative(x, y, z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return blocks;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user