SteamWar/FightSystem
Archiviert
13
1

Adding SWSound for better Sound handling

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2019-12-27 10:09:03 +01:00
Ursprung 9901c4edb8
Commit 6582b9a5c4
12 geänderte Dateien mit 40 neuen und 21 gelöschten Zeilen

Datei anzeigen

@ -5,7 +5,16 @@ import org.bukkit.Sound;
class Countdown_12 { class Countdown_12 {
private Countdown_12(){} private Countdown_12(){}
static Sound getSound(String sound){ static Sound getSound(SWSound sound){
return Sound.valueOf(sound); switch(sound){
case ENTITY_WITHER_DEATH:
return Sound.ENTITY_WITHER_DEATH;
case BLOCK_NOTE_BASS:
return Sound.BLOCK_NOTE_BASS;
case BLOCK_NOTE_PLING:
return Sound.BLOCK_NOTE_PLING;
default:
return null;
}
} }
} }

Datei anzeigen

@ -5,14 +5,16 @@ import org.bukkit.Sound;
class Countdown_14 { class Countdown_14 {
private Countdown_14(){} private Countdown_14(){}
static Sound getSound(String sound){ static Sound getSound(SWSound sound){
switch(sound){ switch(sound){
case "BLOCK_NOTE_BASS": case ENTITY_WITHER_DEATH:
return Sound.BLOCK_NOTE_BLOCK_PLING; return Sound.ENTITY_WITHER_DEATH;
case "BLOCK_NOTE_PLING": case BLOCK_NOTE_BASS:
return Sound.BLOCK_NOTE_BLOCK_BASS;
case BLOCK_NOTE_PLING:
return Sound.BLOCK_NOTE_BLOCK_PLING; return Sound.BLOCK_NOTE_BLOCK_PLING;
default: default:
return Sound.valueOf(sound); return null;
} }
} }
} }

Datei anzeigen

@ -5,16 +5,16 @@ import org.bukkit.Sound;
class Countdown_8 { class Countdown_8 {
private Countdown_8(){} private Countdown_8(){}
static Sound getSound(String sound){ static Sound getSound(SWSound sound){
switch(sound){ switch(sound){
case "ENTITY_WITHER_DEATH": case ENTITY_WITHER_DEATH:
return Sound.WITHER_DEATH; return Sound.WITHER_DEATH;
case "BLOCK_NOTE_BASS": case BLOCK_NOTE_BASS:
return Sound.NOTE_BASS; return Sound.NOTE_BASS;
case "BLOCK_NOTE_PLING": case BLOCK_NOTE_PLING:
return Sound.NOTE_PLING; return Sound.NOTE_PLING;
default: default:
return Sound.valueOf(sound); return null;
} }
} }
} }

Datei anzeigen

@ -0,0 +1,7 @@
package de.steamwar.fightsystem.countdown;
public enum SWSound {
ENTITY_WITHER_DEATH,
BLOCK_NOTE_PLING,
BLOCK_NOTE_BASS
}

Datei anzeigen

@ -26,7 +26,7 @@ public abstract class Countdown {
abstract String countdownCounting(); abstract String countdownCounting();
abstract void countdownFinished(); abstract void countdownFinished();
Countdown(int time, String sound, boolean level) { Countdown(int time, SWSound sound, boolean level) {
this.time = time; this.time = time;
this.sound = getSound(sound); this.sound = getSound(sound);
this.level = level; this.level = level;
@ -36,7 +36,7 @@ public abstract class Countdown {
this.taskID = bukkitScheduler.scheduleSyncRepeatingTask(FightSystem.getPlugin(), this::count, 0, 20); this.taskID = bukkitScheduler.scheduleSyncRepeatingTask(FightSystem.getPlugin(), this::count, 0, 20);
} }
public static Sound getSound(String sound){ public static Sound getSound(SWSound sound){
if(sound == null) if(sound == null)
return null; return null;

Datei anzeigen

@ -7,7 +7,7 @@ import org.bukkit.Bukkit;
public class EnternCountdown extends Countdown { public class EnternCountdown extends Countdown {
public EnternCountdown() { public EnternCountdown() {
super(Config.EnterPhaseBegin, "BLOCK_NOTE_PLING", false); super(Config.EnterPhaseBegin, SWSound.BLOCK_NOTE_PLING, false);
} }
@Override @Override

Datei anzeigen

@ -6,7 +6,7 @@ import de.steamwar.fightsystem.Config;
public class EventStartCountdown extends Countdown { public class EventStartCountdown extends Countdown {
public EventStartCountdown() { public EventStartCountdown() {
super(Config.SetupDuration, "BLOCK_NOTE_PLING", false); super(Config.SetupDuration, SWSound.BLOCK_NOTE_PLING, false);
} }
@Override @Override

Datei anzeigen

@ -6,7 +6,7 @@ import de.steamwar.fightsystem.Config;
public class PreRunningCountdown extends Countdown { public class PreRunningCountdown extends Countdown {
public PreRunningCountdown() { public PreRunningCountdown() {
super(Config.PreFightDuration, "BLOCK_NOTE_PLING", true); super(Config.PreFightDuration, SWSound.BLOCK_NOTE_PLING, true);
} }
@Override @Override

Datei anzeigen

@ -6,7 +6,7 @@ import de.steamwar.fightsystem.Config;
public class SpectateOverCountdown extends Countdown { public class SpectateOverCountdown extends Countdown {
public SpectateOverCountdown() { public SpectateOverCountdown() {
super(Config.SpectatorDuration, "BLOCK_NOTE_PLING", false); super(Config.SpectatorDuration, SWSound.BLOCK_NOTE_PLING, false);
} }
@Override @Override

Datei anzeigen

@ -11,7 +11,7 @@ public class TechKOCountdown extends Countdown {
private final FightTeam team; private final FightTeam team;
public TechKOCountdown(FightTeam team) { public TechKOCountdown(FightTeam team) {
super(WinconditionTechKO.TECH_KO_COUNTDOWN_TIME, "BLOCK_NOTE_PLING", false); super(WinconditionTechKO.TECH_KO_COUNTDOWN_TIME, SWSound.BLOCK_NOTE_PLING, false);
this.team = team; this.team = team;
} }

Datei anzeigen

@ -9,7 +9,7 @@ public class TimeOverCountdown extends Countdown {
private final Runnable timeOver; private final Runnable timeOver;
public TimeOverCountdown(Runnable timeOver) { public TimeOverCountdown(Runnable timeOver) {
super(Config.TimeoutTime, "BLOCK_NOTE_BASS", false); super(Config.TimeoutTime, SWSound.BLOCK_NOTE_BASS, false);
this.timeOver = timeOver; this.timeOver = timeOver;
} }

Datei anzeigen

@ -2,6 +2,7 @@ package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.Countdown; import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.countdown.SWSound;
import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightTeam;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -26,6 +27,6 @@ public class PlayerDeathListener extends BasicListener {
fightTeam.getFightPlayer(player).setOut(); fightTeam.getFightPlayer(player).setOut();
player.setGameMode(GameMode.SPECTATOR); player.setGameMode(GameMode.SPECTATOR);
player.teleport(fightTeam.getSpawn()); player.teleport(fightTeam.getSpawn());
Fight.playSound(Countdown.getSound("ENTITY_WITHER_DEATH"), 100.0F, 1.0F); Fight.playSound(Countdown.getSound(SWSound.ENTITY_WITHER_DEATH), 100.0F, 1.0F);
} }
} }