added sound effects
This commit is contained in:
parent
9dc6b54a3e
commit
3c7fdfab1c
@ -4,6 +4,7 @@ import eu.mhsl.craftattack.teamLobby.data.Team;
|
|||||||
import eu.mhsl.craftattack.teamLobby.util.CommonHandler;
|
import eu.mhsl.craftattack.teamLobby.util.CommonHandler;
|
||||||
import eu.mhsl.craftattack.teamLobby.util.PluginMessageUtil;
|
import eu.mhsl.craftattack.teamLobby.util.PluginMessageUtil;
|
||||||
import eu.mhsl.craftattack.teamLobby.util.PosSerializer;
|
import eu.mhsl.craftattack.teamLobby.util.PosSerializer;
|
||||||
|
import net.kyori.adventure.sound.Sound;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.util.Ticks;
|
import net.kyori.adventure.util.Ticks;
|
||||||
@ -23,6 +24,7 @@ import net.minestom.server.particle.Particle;
|
|||||||
import net.minestom.server.potion.Potion;
|
import net.minestom.server.potion.Potion;
|
||||||
import net.minestom.server.potion.PotionEffect;
|
import net.minestom.server.potion.PotionEffect;
|
||||||
import net.minestom.server.registry.DynamicRegistry;
|
import net.minestom.server.registry.DynamicRegistry;
|
||||||
|
import net.minestom.server.sound.SoundEvent;
|
||||||
import net.minestom.server.timer.TaskSchedule;
|
import net.minestom.server.timer.TaskSchedule;
|
||||||
import net.minestom.server.utils.NamespaceID;
|
import net.minestom.server.utils.NamespaceID;
|
||||||
import net.minestom.server.world.DimensionType;
|
import net.minestom.server.world.DimensionType;
|
||||||
@ -92,11 +94,26 @@ public class Lobby extends InstanceContainer {
|
|||||||
private <TEvent> void onPlayerChange(TEvent event) {
|
private <TEvent> void onPlayerChange(TEvent event) {
|
||||||
MinecraftServer.getSchedulerManager().scheduleNextTick(() -> {
|
MinecraftServer.getSchedulerManager().scheduleNextTick(() -> {
|
||||||
this.isJoining = false;
|
this.isJoining = false;
|
||||||
|
boolean wasComplete = this.isComplete;
|
||||||
this.isComplete = this.getPlayers().stream()
|
this.isComplete = this.getPlayers().stream()
|
||||||
.map(Entity::getUuid)
|
.map(Entity::getUuid)
|
||||||
.collect(Collectors.toSet())
|
.collect(Collectors.toSet())
|
||||||
.containsAll(this.team.players());
|
.containsAll(this.team.players());
|
||||||
|
|
||||||
|
if(this.isComplete) {
|
||||||
|
this.playSound(Sound.sound(SoundEvent.ENTITY_EXPERIENCE_ORB_PICKUP, Sound.Source.PLAYER, 1f, 1f));
|
||||||
|
this.everyMember(p -> p.sendMessage(Component.text(
|
||||||
|
"Das Team ist vollständig. Der Server kann jederzeit über den Knopf betreten werden!",
|
||||||
|
NamedTextColor.GREEN
|
||||||
|
)));
|
||||||
|
} else if(wasComplete) {
|
||||||
|
this.playSound(Sound.sound(SoundEvent.ENTITY_EXPERIENCE_ORB_PICKUP, Sound.Source.PLAYER, 1f, 0.1f));
|
||||||
|
this.everyMember(p -> p.sendMessage(Component.text(
|
||||||
|
"Das Team ist nicht mehr vollständig.",
|
||||||
|
NamedTextColor.RED
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
this.update();
|
this.update();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -105,6 +122,7 @@ public class Lobby extends InstanceContainer {
|
|||||||
if(!event.getBlockPosition().sameBlock(this.buttonLocation)) return;
|
if(!event.getBlockPosition().sameBlock(this.buttonLocation)) return;
|
||||||
if(this.isJoining) return;
|
if(this.isJoining) return;
|
||||||
if(!this.isComplete) {
|
if(!this.isComplete) {
|
||||||
|
event.getPlayer().playSound(Sound.sound(SoundEvent.UI_BUTTON_CLICK, Sound.Source.PLAYER, 1f, 1f));
|
||||||
this.everyMember(p -> p.sendActionBar(Component.text("Dein Team ist nicht vollständig!", NamedTextColor.RED)));
|
this.everyMember(p -> p.sendActionBar(Component.text("Dein Team ist nicht vollständig!", NamedTextColor.RED)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -123,6 +141,7 @@ public class Lobby extends InstanceContainer {
|
|||||||
|
|
||||||
private void connect() {
|
private void connect() {
|
||||||
if(!this.isJoining) return;
|
if(!this.isJoining) return;
|
||||||
|
this.playSound(Sound.sound(SoundEvent.ENTITY_PLAYER_LEVELUP, Sound.Source.PLAYER, 1f, 1f));
|
||||||
this.everyMember(p -> {
|
this.everyMember(p -> {
|
||||||
p.addEffect(new Potion(PotionEffect.DARKNESS, 0, 5 * Ticks.TICKS_PER_SECOND));
|
p.addEffect(new Potion(PotionEffect.DARKNESS, 0, 5 * Ticks.TICKS_PER_SECOND));
|
||||||
p.sendActionBar(Component.text("Verbinde...", NamedTextColor.GREEN));
|
p.sendActionBar(Component.text("Verbinde...", NamedTextColor.GREEN));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user