BEDFIGHTTTTTTTT

This commit is contained in:
nearfe 2024-06-17 21:13:22 -03:00
parent 820d418eac
commit a8fdd72217
8 changed files with 89 additions and 2 deletions

View File

@ -29,7 +29,7 @@ public class Arena {
private AsyncLocation min;
private AsyncLocation max;
private int deadZone;
private boolean enabled = false;
private Flag flag = Flag.DEFAULT;

View File

@ -31,6 +31,8 @@ public class Kit {
private Flag flag = Flag.DEFAULT;
public void applyToPlayer(Player player) {
player.getInventory().setContents(this.contents);
player.getInventory().setArmorContents(this.armor);

View File

@ -151,6 +151,13 @@ public class MatchListener implements Listener {
@EventHandler
public void onEntityDamage(EntityDamageByEntityEvent event) {
Player killer = (Player) event.getDamager();
Match match = this.plugin.getMatchManager().getMatch(killer.getUniqueId());
if (match.getKit().getFlag().equals(Flag.BEDWARS)) {
if (killer == null) {
return;
}
if (event.getEntity() instanceof Player && event.getDamager() instanceof Player) {
Player defender = (Player) event.getEntity();
@ -174,7 +181,7 @@ public class MatchListener implements Listener {
}
}
}
}
@EventHandler
public void onMatchStart(MatchStartEvent event) {

View File

@ -1,20 +1,26 @@
package land.battle.practice.listeners;
import land.battle.practice.Practice;
import land.battle.practice.event.match.MatchEndEvent;
import land.battle.practice.flags.Flag;
import land.battle.practice.match.Match;
import land.battle.practice.match.MatchState;
import land.battle.practice.match.custom.CustomMatchRespawnRunnable;
import land.battle.practice.match.team.impl.MatchTeam;
import land.battle.practice.player.PlayerData;
import land.battle.practice.player.PlayerState;
import land.battle.practice.util.BlockUtil;
import io.papermc.lib.PaperLib;
import land.battle.practice.util.cuboid.Cuboid;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.potion.PotionEffectType;
/**
* @author BattleLand Team
@ -55,6 +61,38 @@ public class MovementListener implements Listener {
this.plugin.getMatchManager().removeFighter(startingOpponent, playerData, false);
}
}
if (match.getKit().getFlag().equals(Flag.BEDWARS)) {
MatchTeam playerTeam = match.getTeams().get(playerData.getTeamID());
if (player.getLocation().getY() <= 50
&& !player.hasPotionEffect(PotionEffectType.WEAKNESS)
&& match.getMatchState() != MatchState.ENDING) {
if (playerTeam.isHasBed()) {
match.broadcast(
(playerTeam.getTeamID() == 1 ? "&9" : "&c") + player.getName() + " &7has died.", Sound.ORB_PICKUP);
new CustomMatchRespawnRunnable(player, playerData, match, playerTeam, 4,
4).runTaskTimer(plugin, 0L, 20L);
} else if (match.isPartyMatch()) {
if (!playerTeam.isHasBed()) {
this.plugin.getMatchManager().removeFighter(player, playerData, false);
}
} else if (match.getMatchState() == MatchState.ENDING) {
this.plugin.getPlayerManager().sendToSpawnAndReset(player);
} else {
match.setCanContinue(false);
if (!match.isCanContinue() && !match.getMatchState().equals(MatchState.ENDING)) {
MatchTeam opposingTeam = match.isFFA() ? match.getTeams().get(0)
: ((playerData.getTeamID() == 0) ? match.getTeams().get(1)
: match.getTeams().get(0));
Bukkit.getPluginManager()
.callEvent(new MatchEndEvent(match, opposingTeam, playerTeam));
player.teleport(playerTeam.getTeamID() == 1 ? match.getStandaloneArena().getPositionOne()
.toBukkitLocation() : match.getStandaloneArena().getPositionTwo().toBukkitLocation());
match.broadcast("", Sound.FIREWORK_LAUNCH);
match.broadcast("", Sound.FIREWORK_TWINKLE2);
}
}
}
}
if (match.getKit().getFlag().equals(Flag.SPLEEF) || match.getKit().getFlag().equals(Flag.SUMO)) {
final Location location = player.getLocation();

View File

@ -5,11 +5,13 @@ import land.battle.practice.arena.type.StandaloneArena;
import land.battle.practice.flags.Flag;
import land.battle.practice.match.Match;
import land.battle.practice.match.MatchState;
import land.battle.practice.match.team.impl.MatchTeam;
import land.battle.practice.player.PlayerData;
import land.battle.practice.player.PlayerState;
import land.battle.practice.runnable.BlockRemoveRunnable;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
@ -40,6 +42,32 @@ public class WorldListener implements Listener {
return;
}
if (event.getBlock().getType() == Material.BED_BLOCK) {
Match match = this.plugin.getMatchManager().getMatch(player.getUniqueId());
MatchTeam playerTeam = match.getTeams().get(playerData.getTeamID());
MatchTeam opposingTeam = match.isFFA() ? match.getTeams().get(0)
: ((playerData.getTeamID() == 0) ? match.getTeams().get(1)
: match.getTeams().get(0));
if ((playerTeam.getTeamID() == 1 ? match.getStandaloneArena().getPositionOne().toBukkitLocation()
: match.getStandaloneArena().getPositionTwo().toBukkitLocation()).distance(
event.getBlock().getLocation()) > 20.0) {
if (match.getKit().getFlag().equals(Flag.BEDWARS)) {
if (playerTeam.getPlayers().contains(player.getUniqueId()) && (!match.getMatchState().equals(MatchState.ENDING))
&& opposingTeam.isHasBed()) {
opposingTeam.destroyBed();
match.broadcast(playerTeam.getTeamID() == 1 ? "&9"
: "&c" + player.getName() + " &7destroyed the bed of " + (
playerTeam.getTeamID() == 1 ? "&cRed" : "&9Blue") + "&7!");
match.broadcast(
playerTeam.getTeamID() == 1 ? "&cRed's" : "&9Blue's" + " destroyed",
"&7By " + (playerTeam.getTeamID() == 1 ? "&9" : "&c") + player.getName());
match.broadcast("", Sound.ENDERDRAGON_GROWL);
return;
}
}
}
}
if (playerData.getPlayerState() == PlayerState.FIGHTING) {
Match match = this.plugin.getMatchManager().getMatch(player.getUniqueId());

View File

@ -40,6 +40,7 @@ public class Match {
private final UUID matchId = UUID.randomUUID();
private final String shortMatchId = SaltUtil.getRandomSaltedString(7);
private boolean canContinue = true;
private final Set<Entity> entitiesToRemove = new HashSet<>();

View File

@ -2,6 +2,8 @@ package land.battle.practice.match.team.impl;
import land.battle.practice.match.team.KillableTeam;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.Bukkit;
import java.util.List;
import java.util.UUID;
@ -10,6 +12,14 @@ import java.util.UUID;
public class MatchTeam extends KillableTeam {
private final int teamID;
private boolean hasBed = true;
@Setter
private int lives;
public void destroyBed() {
this.hasBed = false;
}
public MatchTeam(UUID leader, List<UUID> players, int teamID) {
super(leader, players);

View File

@ -37,6 +37,7 @@ public class PlayerData {
private final Map<String, Integer> highestKillStreaks = new HashMap<>();
private final Map<String, Integer> kitKillStreaks = new HashMap<>();
private final Map<String, Boolean> rankedDivisionBooleanMap = new HashMap<>();
private final List<String> matchIds = new ArrayList<>();