Skip to content

Commit

Permalink
Added bed broken title
Browse files Browse the repository at this point in the history
  • Loading branch information
Devlrxxh committed Apr 5, 2024
1 parent f1c7c47 commit 5d17fe7
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 13 deletions.
19 changes: 16 additions & 3 deletions src/main/java/me/lrxh/practice/match/Match.java
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ public void onDeath(Player dead) {
PlayerUtil.animateDeath(dead);

if (killer != null) {
PlayerUtil.sendTitle(dead, CC.translate("&cLOST!"), "&c" + killer.getName() + " &fwon the match!", 60);
PlayerUtil.sendTitle(dead, CC.translate("&cLOST!"), "&c" + killer.getName() + " &fwon the match!", 70);
}

// Don't continue if the player is already dead
Expand All @@ -515,8 +515,7 @@ public void onDeath(Player dead) {
if (killer != null) {
Profile killerProfile = Profile.getByUuid(killer.getUniqueId());
killerProfile.getOptions().killEffect().execute(killer, dead.getLocation());
PlayerUtil.setLastAttacker(killer, null);
PlayerUtil.sendTitle(killer, CC.translate("&aVICTORY!"), "&a" + killer.getName() + " &fwon the match!", 60);
PlayerUtil.sendTitle(killer, CC.translate("&aVICTORY!"), "&a" + killer.getName() + " &fwon the match!", 70);
killer.playSound(killer.getLocation(), Sound.EXPLODE, 1.0f, 1.0f);
}

Expand Down Expand Up @@ -591,6 +590,12 @@ public GameParticipant<MatchGamePlayer> getParticipantA() {
return getParticipants().get(0);
}

public void sendTeamAMessage(String message){
for (GameParticipant<MatchGamePlayer> gameParticipant : getParticipants()) {
gameParticipant.sendMessage(message);
}
}

public GameParticipant<MatchGamePlayer> getParticipantB() {
return getParticipants().get(1);
}
Expand Down Expand Up @@ -705,6 +710,14 @@ public void sendTitle(String header, String footer, int duration) {
}
}

public void sendTitleA(String header, String footer, int duration) {
getParticipantA().sendTitle(header, footer, duration);
}

public void sendTitleB(String header, String footer, int duration) {
getParticipantB().sendTitle(header, footer, duration);
}

public void sendSound(Sound sound, float volume, float pitch) {
for (GameParticipant gameParticipant : getParticipants()) {
gameParticipant.sendSound(sound, volume, pitch);
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/me/lrxh/practice/match/MatchListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ public void onBlockBreakEvent(BlockBreakEvent event) {
return;
}

if(!aTeam){
match.sendTitleA("&cBED DESTROYED!", "&fYou will no longer respawn!", 40);
}else{
match.sendTitleB("&cBED DESTROYED!", "&fYou will no longer respawn!", 40);
}

match.sendSound(Sound.ORB_PICKUP, 1.0F, 1.0F);
match.sendSound(Sound.WITHER_DEATH, 1.0F, 1.0F);
match.broadcast(" ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,10 @@ public class MatchLogicTask extends BukkitRunnable {

private final Match match;
@Setter
private int nextAction;
private int nextAction = 6;

public MatchLogicTask(Match match) {
this.match = match;

if (match.getKit().getGameRules().isSumo()) {
nextAction = 4;
} else {
nextAction = 6;
}
}


Expand Down
11 changes: 9 additions & 2 deletions src/main/java/me/lrxh/practice/participant/GameParticipant.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.Getter;
import lombok.Setter;
import me.lrxh.practice.util.PlayerUtil;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
Expand Down Expand Up @@ -75,6 +76,14 @@ public void sendMessage(List<String> messages) {
}
}

public void sendTitle(String header, String footer, int duration) {
for (GamePlayer gamePlayer : getPlayers()) {
if (!gamePlayer.isDisconnected()) {
PlayerUtil.sendTitle(gamePlayer.getPlayer(), header, footer, duration);
}
}
}

public void sendSound(Sound sound, float volume, float pitch) {
for (GamePlayer gamePlayer : getPlayers()) {
if (!gamePlayer.isDisconnected()) {
Expand All @@ -99,6 +108,4 @@ public void addSpeed() {
}
}
}


}
2 changes: 1 addition & 1 deletion src/main/java/me/lrxh/practice/util/PlayerUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public Player getLastAttacker(Player victim) {
}

public static void sendTitle(Player player, String header, String footer, int duration) {
player.sendTitle(new Title(CC.translate(header), CC.translate(footer), 1, duration, 0));
player.sendTitle(new Title(CC.translate(header), CC.translate(footer), 1, duration, 10));
}

public ItemStack getPlayerHead(UUID playerUUID) {
Expand Down

0 comments on commit 5d17fe7

Please sign in to comment.