12
1

rework of countdown sounds

Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Yaruma3341 2019-07-04 22:07:12 +02:00
Ursprung 6aac93dc64
Commit f72c5b224a
8 geänderte Dateien mit 38 neuen und 26 gelöschten Zeilen

Datei anzeigen

@ -97,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(), null);
Countdown countdown = new Countdown(Config.NoPlayerOnlineDuration, new FinishNoPlayersOnline(), null, false);
countdown.startTimer(getPlugin());
TechHider.init();
@ -133,7 +133,7 @@ public class FightSystem extends JavaPlugin {
fightState = FightState.PRE_RUNNING;
Countdown.cancelAllTimers();
Countdown countdown = new Countdown(Config.PreFightDuration, new FinishPreRunning(), Sound.BLOCK_NOTE_PLING);
Countdown countdown = new Countdown(Config.PreFightDuration, new FinishPreRunning(), Sound.BLOCK_NOTE_PLING, true);
countdown.startTimer(this);
for(FightPlayer allFightPlayers : Fight.getBlueTeam().getPlayers()) {
allFightPlayers.getPlayer().getInventory().clear();
@ -210,7 +210,7 @@ public class FightSystem extends JavaPlugin {
}
}
Countdown countdown = new Countdown(Config.SpectatorDuration, new FinishSpectateOver(), Sound.BLOCK_NOTE_PLING);
Countdown countdown = new Countdown(Config.SpectatorDuration, new FinishSpectateOver(), Sound.BLOCK_NOTE_PLING, false);
countdown.startTimer(FightSystem.getPlugin());
}

Datei anzeigen

@ -1,6 +1,8 @@
package me.yaruma.fightsystem.fight;
import me.yaruma.fightsystem.utils.Config;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
public class Fight {
@ -48,4 +50,16 @@ public class Fight {
public static FightTeam getBlueTeam() {
return blueTeam;
}
public static void playSound(Sound sound, float volume, float pitch) {
for(Player player : Bukkit.getServer().getOnlinePlayers()) {
player.playSound(player.getLocation(), sound, volume, pitch); //volume: max. 100, pitch: max. 2
}
}
public static void setLevel(int level) {
for(Player player : Bukkit.getServer().getOnlinePlayers()) {
player.setLevel(level);
}
}
}

Datei anzeigen

@ -323,11 +323,4 @@ 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

@ -5,6 +5,7 @@ import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightTeam;
import me.yaruma.fightsystem.utils.Config;
import org.bukkit.GameMode;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -27,6 +28,8 @@ public class PlayerDeathListener implements Listener {
player.teleport(Config.TeamRedSpawn);
else
player.teleport(Config.TeamBlueSpawn);
Fight.playSound(Sound.ENTITY_WITHER_DEATH, 100.0F, 1.0F);
}

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(), null).startTimer(FightSystem.getPlugin());
new Countdown(Config.SetupDuration, new FinishSetupOver(), null, false).startTimer(FightSystem.getPlugin());
}
FightSystem.getPlugin().getScoreboard().setAutoScoreboard(20*10, player);

Datei anzeigen

@ -16,11 +16,13 @@ public class Countdown {
private final CountdownCallback countdownCallback;
private int taskID;
private Sound sound;
private boolean level;
public Countdown(int time, CountdownCallback countdownCallback, Sound sound) {
public Countdown(int time, CountdownCallback countdownCallback, Sound sound, boolean level) {
this.time = time;
this.countdownCallback = countdownCallback;
this.sound = sound;
this.level = level;
countdowns.add(this);
}
@ -34,28 +36,28 @@ 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);
}
if(this.sound != null)
Fight.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);
}
if(this.sound != null)
Fight.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);
}
if(this.sound != null)
Fight.playSound(this.sound, 100.0F, 2.0F);
cancelTimer();
countdownCallback.countdownFinished();
break;
}
if(this.level)
Fight.setLevel(time);
time--;
if(countdownCallback instanceof FinishTimeOver) FightSystem.setFightTime(time);
}, 0, 20);

Datei anzeigen

@ -13,7 +13,7 @@ public class WinconditionEntern {
public static void entern() {
if(!Config.Entern) return;
Countdown countdownTimeOver = new Countdown(Config.EnterPhaseBegin, new FinishNoneEntern(), Sound.BLOCK_NOTE_PLING);
Countdown countdownTimeOver = new Countdown(Config.EnterPhaseBegin, new FinishNoneEntern(), Sound.BLOCK_NOTE_PLING, false);
countdownTimeOver.startTimer(instance);
}

Datei anzeigen

@ -13,7 +13,7 @@ public class WinconditionTimeout {
public static void timeout() {
if(!Config.Timeout) return;
Countdown countdownTimeOver = new Countdown(Config.TimeoutTime, new FinishTimeOver(), Sound.BLOCK_NOTE_BASS);
Countdown countdownTimeOver = new Countdown(Config.TimeoutTime, new FinishTimeOver(), Sound.BLOCK_NOTE_BASS, false);
countdownTimeOver.startTimer(instance);
}