SteamWar/FightSystem
Archiviert
13
1

added countdown sounds

Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Yaruma3341 2019-07-02 22:56:58 +02:00
Ursprung 470a86be80
Commit 6aac93dc64
6 geänderte Dateien mit 34 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -16,6 +16,7 @@ import me.yaruma.fightsystem.utils.scoreboard.Scoreboard;
import me.yaruma.fightsystem.winconditions.*;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Sound;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
@ -96,7 +97,7 @@ public class FightSystem extends JavaPlugin {
getCommand("ready").setExecutor(new ReadyCommand());
getCommand("kit").setExecutor(new KitCommand());
Countdown countdown = new Countdown(Config.NoPlayerOnlineDuration, new FinishNoPlayersOnline());
Countdown countdown = new Countdown(Config.NoPlayerOnlineDuration, new FinishNoPlayersOnline(), null);
countdown.startTimer(getPlugin());
TechHider.init();
@ -132,7 +133,7 @@ public class FightSystem extends JavaPlugin {
fightState = FightState.PRE_RUNNING;
Countdown.cancelAllTimers();
Countdown countdown = new Countdown(Config.PreFightDuration, new FinishPreRunning());
Countdown countdown = new Countdown(Config.PreFightDuration, new FinishPreRunning(), Sound.BLOCK_NOTE_PLING);
countdown.startTimer(this);
for(FightPlayer allFightPlayers : Fight.getBlueTeam().getPlayers()) {
allFightPlayers.getPlayer().getInventory().clear();
@ -209,7 +210,7 @@ public class FightSystem extends JavaPlugin {
}
}
Countdown countdown = new Countdown(Config.SpectatorDuration, new FinishSpectateOver());
Countdown countdown = new Countdown(Config.SpectatorDuration, new FinishSpectateOver(), Sound.BLOCK_NOTE_PLING);
countdown.startTimer(FightSystem.getPlugin());
}

Datei anzeigen

@ -20,10 +20,7 @@ import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.*;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
@ -326,4 +323,11 @@ public class FightTeam {
player.spigot().sendMessage(beforePage);
}
}
public void playSound(Sound sound, float volume, float pitch) {
for(FightPlayer fightPlayer : players) {
Player player = fightPlayer.getPlayer();
player.playSound(player.getLocation(), sound, volume, pitch); //volume: max. 100, pitch: max. 2
}
}
}

Datei anzeigen

@ -44,7 +44,7 @@ public class PlayerJoinListener implements Listener {
if(Fight.getRedTeam().hasTeamLeader() && Fight.getBlueTeam().hasTeamLeader() && FightSystem.getFightState() == FightState.SETUP
&& (Fight.getRedTeam().getLeader().getPlayer() == player || Fight.getBlueTeam().getLeader().getPlayer() == player)) {
Countdown.cancelTimerType(CountdownType.NO_PLAYERS_ONLINE);
new Countdown(Config.SetupDuration, new FinishSetupOver()).startTimer(FightSystem.getPlugin());
new Countdown(Config.SetupDuration, new FinishSetupOver(), null).startTimer(FightSystem.getPlugin());
}
FightSystem.getPlugin().getScoreboard().setAutoScoreboard(20*10, player);

Datei anzeigen

@ -1,7 +1,9 @@
package me.yaruma.fightsystem.utils.countdown;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.scheduler.BukkitScheduler;
import java.util.ArrayList;
@ -13,10 +15,12 @@ public class Countdown {
private int time;
private final CountdownCallback countdownCallback;
private int taskID;
private Sound sound;
public Countdown(int time, CountdownCallback countdownCallback) {
public Countdown(int time, CountdownCallback countdownCallback, Sound sound) {
this.time = time;
this.countdownCallback = countdownCallback;
this.sound = sound;
countdowns.add(this);
}
@ -30,12 +34,24 @@ public class Countdown {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§7Noch §a" + time / 60 + " §7Minuten " + countdownCallback.countdownCounting());
break;
case 60: case 30: case 20: case 15: case 10: case 5: case 4: case 3: case 2:
if(this.sound != null) {
Fight.getBlueTeam().playSound(this.sound, 100.0F, 1.0F);
Fight.getRedTeam().playSound(this.sound, 100.0F, 1.0F);
}
Bukkit.broadcastMessage(FightSystem.PREFIX + "§7Noch §a" + time + " §7Sekunden " + countdownCallback.countdownCounting());
break;
case 1:
if(this.sound != null) {
Fight.getBlueTeam().playSound(this.sound, 100.0F, 1.0F);
Fight.getRedTeam().playSound(this.sound, 100.0F, 1.0F);
}
Bukkit.broadcastMessage(FightSystem.PREFIX + "§7Noch §aeine §7Sekunde " + countdownCallback.countdownCounting());
break;
case 0:
if(this.sound != null) {
Fight.getBlueTeam().playSound(this.sound, 100.0F, 2.0F);
Fight.getRedTeam().playSound(this.sound, 100.0F, 2.0F);
}
cancelTimer();
countdownCallback.countdownFinished();
break;

Datei anzeigen

@ -4,6 +4,7 @@ import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.utils.Config;
import me.yaruma.fightsystem.utils.countdown.Countdown;
import me.yaruma.fightsystem.utils.countdown.FinishNoneEntern;
import org.bukkit.Sound;
public class WinconditionEntern {
@ -12,7 +13,7 @@ public class WinconditionEntern {
public static void entern() {
if(!Config.Entern) return;
Countdown countdownTimeOver = new Countdown(Config.EnterPhaseBegin, new FinishNoneEntern());
Countdown countdownTimeOver = new Countdown(Config.EnterPhaseBegin, new FinishNoneEntern(), Sound.BLOCK_NOTE_PLING);
countdownTimeOver.startTimer(instance);
}

Datei anzeigen

@ -4,6 +4,7 @@ import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.utils.Config;
import me.yaruma.fightsystem.utils.countdown.Countdown;
import me.yaruma.fightsystem.utils.countdown.FinishTimeOver;
import org.bukkit.Sound;
public class WinconditionTimeout {
@ -12,7 +13,7 @@ public class WinconditionTimeout {
public static void timeout() {
if(!Config.Timeout) return;
Countdown countdownTimeOver = new Countdown(Config.TimeoutTime, new FinishTimeOver());
Countdown countdownTimeOver = new Countdown(Config.TimeoutTime, new FinishTimeOver(), Sound.BLOCK_NOTE_BASS);
countdownTimeOver.startTimer(instance);
}