Fix some bugs which appeared when testing

This commit is contained in:
Sam 2018-09-13 14:16:41 +01:00 committed by Alexander Meech
parent 2e0d457a78
commit fd22ff1975
2 changed files with 7 additions and 7 deletions

View File

@ -41,7 +41,7 @@ public class LoopedNotePlayer implements Runnable, Component, Lifetimed
public LoopedNotePlayer(Lifetime lifetime, NoteSong song, Predicate<Player> shouldPlay)
{
this(lifetime, song, (Collection<Player>) UtilServer.getPlayersCollection(), shouldPlay);
this(lifetime, song, null, shouldPlay);
}
public LoopedNotePlayer(Lifetime lifetime, NoteSong song, Collection<Player> listeners)
@ -68,18 +68,19 @@ public class LoopedNotePlayer implements Runnable, Component, Lifetimed
_listeners = listeners;
_shouldPlay = shouldPlay;
setPlaying(true);
}
@Override
public void activate()
{
THREAD_FACTORY.newThread(this);
THREAD_FACTORY.newThread(this).start();
}
@Override
public void deactivate()
{
}
@Override
@ -112,11 +113,11 @@ public class LoopedNotePlayer implements Runnable, Component, Lifetimed
private void playTick(int tick)
{
Collection<Player> listeners = _listeners;
Collection<Player> listeners = _listeners == null ? (Collection<Player>) UtilServer.getPlayersCollection() : _listeners;
if (_shouldPlay != null)
{
listeners = _listeners.stream()
listeners = listeners.stream()
.filter(_shouldPlay)
.collect(Collectors.toSet());
}

View File

@ -6,7 +6,6 @@ import java.util.function.Predicate;
import org.bukkit.entity.Player;
import mineplex.core.common.util.UtilServer;
import mineplex.core.lifetimes.SimpleLifetime;
public class SingleRunNotePlayer extends LoopedNotePlayer
@ -21,7 +20,7 @@ public class SingleRunNotePlayer extends LoopedNotePlayer
public SingleRunNotePlayer(NoteSong song, Predicate<Player> shouldPlay)
{
this(new SimpleLifetime(), song, (Collection<Player>) UtilServer.getPlayersCollection(), shouldPlay);
this(new SimpleLifetime(), song, null, shouldPlay);
}
public SingleRunNotePlayer(NoteSong song, Collection<Player> listeners)