Change our Noteblock API to better support features required for Nano Games
This commit is contained in:
parent
3245a798ba
commit
2e0d457a78
@ -36,8 +36,8 @@ import mineplex.core.gadget.gadgets.outfit.windup.OutfitWindupLeggings;
|
|||||||
import mineplex.core.gadget.types.GadgetSet;
|
import mineplex.core.gadget.types.GadgetSet;
|
||||||
import mineplex.core.itemstack.ItemBuilder;
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
import mineplex.core.noteblock.NBSReader;
|
import mineplex.core.noteblock.NBSReader;
|
||||||
import mineplex.core.noteblock.NotePlayer;
|
|
||||||
import mineplex.core.noteblock.NoteSong;
|
import mineplex.core.noteblock.NoteSong;
|
||||||
|
import mineplex.core.noteblock.SingleRunNotePlayer;
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
@ -105,7 +105,7 @@ public class SetWindup extends GadgetSet
|
|||||||
{
|
{
|
||||||
if (data.NotePlayer != null)
|
if (data.NotePlayer != null)
|
||||||
{
|
{
|
||||||
data.NotePlayer.cancel();
|
data.NotePlayer.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
player.removePotionEffect(PotionEffectType.SPEED);
|
player.removePotionEffect(PotionEffectType.SPEED);
|
||||||
@ -183,7 +183,7 @@ public class SetWindup extends GadgetSet
|
|||||||
|
|
||||||
if (_song != null)
|
if (_song != null)
|
||||||
{
|
{
|
||||||
data.NotePlayer = new NotePlayer(Manager.getPlugin(), _song, other -> true, 1, false, player);
|
data.NotePlayer = new SingleRunNotePlayer(_song, player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Effect is charging
|
// Effect is charging
|
||||||
@ -278,7 +278,7 @@ public class SetWindup extends GadgetSet
|
|||||||
float Charge;
|
float Charge;
|
||||||
long EffectStart;
|
long EffectStart;
|
||||||
Color Current;
|
Color Current;
|
||||||
NotePlayer NotePlayer;
|
SingleRunNotePlayer NotePlayer;
|
||||||
|
|
||||||
WindupData()
|
WindupData()
|
||||||
{
|
{
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
package mineplex.core.noteblock;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public interface INoteVerifier
|
|
||||||
{
|
|
||||||
|
|
||||||
public boolean shouldPlay(Player player);
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,176 @@
|
|||||||
|
package mineplex.core.noteblock;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.concurrent.ThreadFactory;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
import mineplex.core.lifetimes.Component;
|
||||||
|
import mineplex.core.lifetimes.Lifetime;
|
||||||
|
import mineplex.core.lifetimes.Lifetimed;
|
||||||
|
|
||||||
|
public class LoopedNotePlayer implements Runnable, Component, Lifetimed
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final ThreadFactory THREAD_FACTORY = new ThreadFactoryBuilder()
|
||||||
|
.setNameFormat("NoteBlockPlayer %1$d")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
private final Lifetime _lifetime;
|
||||||
|
|
||||||
|
protected final NoteSong _song;
|
||||||
|
protected final long _sleepMillis;
|
||||||
|
|
||||||
|
private final Collection<Player> _listeners;
|
||||||
|
private final Predicate<Player> _shouldPlay;
|
||||||
|
|
||||||
|
private volatile boolean _playing;
|
||||||
|
protected volatile int _tick;
|
||||||
|
|
||||||
|
public LoopedNotePlayer(Lifetime lifetime, NoteSong song)
|
||||||
|
{
|
||||||
|
this(lifetime, song, (Predicate<Player>) null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoopedNotePlayer(Lifetime lifetime, NoteSong song, Predicate<Player> shouldPlay)
|
||||||
|
{
|
||||||
|
this(lifetime, song, (Collection<Player>) UtilServer.getPlayersCollection(), shouldPlay);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoopedNotePlayer(Lifetime lifetime, NoteSong song, Collection<Player> listeners)
|
||||||
|
{
|
||||||
|
this(lifetime, song, listeners, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoopedNotePlayer(Lifetime lifetime, NoteSong song, Player listener, int sleepMillis)
|
||||||
|
{
|
||||||
|
this(lifetime, song, sleepMillis, Collections.singleton(listener), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoopedNotePlayer(Lifetime lifetime, NoteSong song, Collection<Player> listeners, Predicate<Player> shouldPlay)
|
||||||
|
{
|
||||||
|
this(lifetime, song, (long) (1000 / (song.getTempo() / 100D)), listeners, shouldPlay);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoopedNotePlayer(Lifetime lifetime, NoteSong song, long sleepMillis, Collection<Player> listeners, Predicate<Player> shouldPlay)
|
||||||
|
{
|
||||||
|
_lifetime = lifetime;
|
||||||
|
|
||||||
|
_song = song;
|
||||||
|
_sleepMillis = sleepMillis;
|
||||||
|
|
||||||
|
_listeners = listeners;
|
||||||
|
_shouldPlay = shouldPlay;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void activate()
|
||||||
|
{
|
||||||
|
THREAD_FACTORY.newThread(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deactivate()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
while (getLifetime().isActive())
|
||||||
|
{
|
||||||
|
if (!_playing)
|
||||||
|
{
|
||||||
|
sleep();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setTick(_tick + 1);
|
||||||
|
|
||||||
|
if (_tick > _song.getLength())
|
||||||
|
{
|
||||||
|
onSongEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
playTick(_tick);
|
||||||
|
sleep();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onSongEnd()
|
||||||
|
{
|
||||||
|
_tick = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void playTick(int tick)
|
||||||
|
{
|
||||||
|
Collection<Player> listeners = _listeners;
|
||||||
|
|
||||||
|
if (_shouldPlay != null)
|
||||||
|
{
|
||||||
|
listeners = _listeners.stream()
|
||||||
|
.filter(_shouldPlay)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (NoteLayer layer : _song.getLayerMap().values())
|
||||||
|
{
|
||||||
|
Note note = layer.getNote(tick);
|
||||||
|
|
||||||
|
if (note != null)
|
||||||
|
{
|
||||||
|
Sound sound = UtilNote.getInstrumentSound(note.getInstrument());
|
||||||
|
float volume = layer.getVolume() / 100F;
|
||||||
|
float pitch = (float) UtilNote.getPitch(note.getNote() - 33);
|
||||||
|
|
||||||
|
for (Player player : listeners)
|
||||||
|
{
|
||||||
|
player.playSound(player.getEyeLocation(), sound, volume, pitch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sleep()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Thread.sleep(_sleepMillis);
|
||||||
|
}
|
||||||
|
catch (InterruptedException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setTick(int tick)
|
||||||
|
{
|
||||||
|
_tick = tick;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlaying(boolean playing)
|
||||||
|
{
|
||||||
|
_playing = playing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoopedNotePlayer cloneForPlayer(Player player, float tempoFactor)
|
||||||
|
{
|
||||||
|
LoopedNotePlayer notePlayer = new LoopedNotePlayer(getLifetime(), _song, player, (int) (_sleepMillis * tempoFactor));
|
||||||
|
notePlayer.setTick(_tick);
|
||||||
|
return notePlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Lifetime getLifetime()
|
||||||
|
{
|
||||||
|
return _lifetime;
|
||||||
|
}
|
||||||
|
}
|
@ -1,106 +0,0 @@
|
|||||||
package mineplex.core.noteblock;
|
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.common.util.UtilServer;
|
|
||||||
import mineplex.core.common.util.UtilTextBottom;
|
|
||||||
import mineplex.core.noteblock.event.SongFinishEvent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Very basic Manager to play music across the entire server. Specifically used for Lobby Music
|
|
||||||
*
|
|
||||||
* Created by shaun on 2016-10-05.
|
|
||||||
*/
|
|
||||||
public class MusicManager extends MiniPlugin
|
|
||||||
{
|
|
||||||
private Random _random = new Random();
|
|
||||||
private final ArrayList<NoteSong> _songs = new ArrayList<>();
|
|
||||||
private int _lastSong = 0;
|
|
||||||
|
|
||||||
private final Predicate<Player> _shouldPlay;
|
|
||||||
|
|
||||||
public MusicManager(Predicate<Player> shouldPlay, String folderName)
|
|
||||||
{
|
|
||||||
super("Music Manager");
|
|
||||||
|
|
||||||
_shouldPlay = shouldPlay;
|
|
||||||
|
|
||||||
addSongs(folderName);
|
|
||||||
playNextSong();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void playNextSong()
|
|
||||||
{
|
|
||||||
if (_songs.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
int index = (_lastSong + _random.nextInt(_songs.size() - 1) + 1) % _songs.size();
|
|
||||||
NoteSong song = _songs.get(index);
|
|
||||||
if (song != null)
|
|
||||||
{
|
|
||||||
UtilServer.getPlayersCollection().stream()
|
|
||||||
.filter(_shouldPlay)
|
|
||||||
.forEach(player -> displaySongInfo(song, player));
|
|
||||||
|
|
||||||
new NotePlayer(_plugin, song, _shouldPlay, 0.5F, false);
|
|
||||||
|
|
||||||
_lastSong = index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addSongs(String folderName)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
File songsFolder = new File(folderName);
|
|
||||||
if (songsFolder.exists())
|
|
||||||
{
|
|
||||||
File[] files = songsFolder.listFiles();
|
|
||||||
if (files == null) return;
|
|
||||||
|
|
||||||
for (File file : files)
|
|
||||||
{
|
|
||||||
if (file.getName().endsWith(".nbs"))
|
|
||||||
{
|
|
||||||
System.out.println("Loading Song " + file.getPath());
|
|
||||||
NoteSong song = NBSReader.loadSong(new DataInputStream(new FileInputStream(file)), file.getName().replace("_", " ").replace(".nbs", ""));
|
|
||||||
if (song != null)
|
|
||||||
{
|
|
||||||
_songs.add(song);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (FileNotFoundException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
System.out.println("FAILED TO LOAD SONG!!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void displaySongInfo(NoteSong song, Player player)
|
|
||||||
{
|
|
||||||
UtilTextBottom.display(C.cWhite + "Now Playing " + C.cYellow + song.getName(), player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onSongFinish(SongFinishEvent event)
|
|
||||||
{
|
|
||||||
if (_lastSong < _songs.size() && event.getSong().equals(_songs.get(_lastSong)))
|
|
||||||
{
|
|
||||||
playNextSong();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,6 +7,7 @@ import java.io.FileInputStream;
|
|||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information about the NBS Format was taken from
|
* Information about the NBS Format was taken from
|
||||||
@ -14,6 +15,7 @@ import java.util.HashMap;
|
|||||||
*/
|
*/
|
||||||
public class NBSReader
|
public class NBSReader
|
||||||
{
|
{
|
||||||
|
|
||||||
public static NoteSong loadSong(String fileName) throws FileNotFoundException
|
public static NoteSong loadSong(String fileName) throws FileNotFoundException
|
||||||
{
|
{
|
||||||
return loadSong(new DataInputStream(new FileInputStream(new File(fileName))), fileName);
|
return loadSong(new DataInputStream(new FileInputStream(new File(fileName))), fileName);
|
||||||
@ -41,37 +43,51 @@ public class NBSReader
|
|||||||
int blocksRemoved = readInt(stream);
|
int blocksRemoved = readInt(stream);
|
||||||
String midiFileName = readString(stream);
|
String midiFileName = readString(stream);
|
||||||
|
|
||||||
if ((name == null || name.length() == 0) && defaultName != null)
|
if (name.length() == 0 && defaultName != null)
|
||||||
|
{
|
||||||
name = defaultName;
|
name = defaultName;
|
||||||
|
}
|
||||||
|
|
||||||
HashMap<Integer, NoteLayer> layerMap = new HashMap<Integer, NoteLayer>();
|
Map<Integer, NoteLayer> layerMap = new HashMap<>();
|
||||||
|
|
||||||
// Note Block Information
|
// Note Block Information
|
||||||
int tick = -1;
|
int tick = -1;
|
||||||
int jumps = 0;
|
int jumps;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
jumps = readShort(stream);
|
jumps = readShort(stream);
|
||||||
|
|
||||||
if (jumps == 0)
|
if (jumps == 0)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
tick += jumps;
|
tick += jumps;
|
||||||
int layer = -1;
|
int layer = -1;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
jumps = readShort(stream);
|
jumps = readShort(stream);
|
||||||
|
|
||||||
if (jumps == 0)
|
if (jumps == 0)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
layer += jumps;
|
layer += jumps;
|
||||||
byte instrument = stream.readByte();
|
byte instrument = stream.readByte();
|
||||||
byte key = stream.readByte();
|
byte key = stream.readByte();
|
||||||
|
|
||||||
Note note = new Note(instrument, key);
|
Note note = new Note(instrument, key);
|
||||||
NoteLayer noteLayer = layerMap.get(layer);
|
NoteLayer noteLayer = layerMap.get(layer);
|
||||||
|
|
||||||
if (noteLayer == null)
|
if (noteLayer == null)
|
||||||
{
|
{
|
||||||
noteLayer = new NoteLayer();
|
noteLayer = new NoteLayer();
|
||||||
layerMap.put(layer, noteLayer);
|
layerMap.put(layer, noteLayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
noteLayer.setNote(tick, note);
|
noteLayer.setNote(tick, note);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,8 +103,7 @@ public class NBSReader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("[NBSReader] Successfully loaded song " + name + "");
|
System.out.println("[NBSReader] Successfully loaded song " + name + " with tempo " + tempo);
|
||||||
System.out.println("Tempo: " + tempo);
|
|
||||||
return new NoteSong(length, height, name, tempo, timeSignature, layerMap);
|
return new NoteSong(length, height, name, tempo, timeSignature, layerMap);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
|
@ -5,8 +5,8 @@ package mineplex.core.noteblock;
|
|||||||
*/
|
*/
|
||||||
public class Note
|
public class Note
|
||||||
{
|
{
|
||||||
private byte _instrument;
|
|
||||||
private byte _note;
|
private final byte _instrument, _note;
|
||||||
|
|
||||||
public Note(byte instrument, byte note)
|
public Note(byte instrument, byte note)
|
||||||
{
|
{
|
||||||
|
@ -1,19 +1,21 @@
|
|||||||
package mineplex.core.noteblock;
|
package mineplex.core.noteblock;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a layer of notes in Note Block Studio
|
* Represents a layer of notes in Note Block Studio
|
||||||
*/
|
*/
|
||||||
public class NoteLayer
|
public class NoteLayer
|
||||||
{
|
{
|
||||||
private HashMap<Integer, Note> _noteMap; // Notes indexed by ticks
|
|
||||||
|
private final Map<Integer, Note> _noteMap; // Notes indexed by ticks
|
||||||
private int _volume; // Volume as a percentage 1-100
|
private int _volume; // Volume as a percentage 1-100
|
||||||
private String _name;
|
private String _name;
|
||||||
|
|
||||||
public NoteLayer()
|
NoteLayer()
|
||||||
{
|
{
|
||||||
_noteMap = new HashMap<Integer, Note>();
|
_noteMap = new HashMap<>();
|
||||||
_volume = 100;
|
_volume = 100;
|
||||||
_name = "";
|
_name = "";
|
||||||
}
|
}
|
||||||
@ -47,4 +49,5 @@ public class NoteLayer
|
|||||||
{
|
{
|
||||||
return _noteMap.get(ticks);
|
return _noteMap.get(ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,145 +0,0 @@
|
|||||||
package mineplex.core.noteblock;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.UtilServer;
|
|
||||||
import mineplex.core.noteblock.event.SongFinishEvent;
|
|
||||||
import mineplex.core.noteblock.event.SongStartEvent;
|
|
||||||
|
|
||||||
public class NotePlayer
|
|
||||||
{
|
|
||||||
private final JavaPlugin _plugin;
|
|
||||||
private final NoteSong _song;
|
|
||||||
private final Predicate<Player> _shouldPlay;
|
|
||||||
private final long _sleepMs;
|
|
||||||
private volatile float _volumeMult;
|
|
||||||
private volatile boolean _loop;
|
|
||||||
private volatile int _tick;
|
|
||||||
private volatile boolean _finished, _paused;
|
|
||||||
private volatile Player[] _players = null;
|
|
||||||
|
|
||||||
public NotePlayer(JavaPlugin plugin, NoteSong song, Predicate<Player> shouldPlay, float volumeMult, boolean loop, Player... players)
|
|
||||||
{
|
|
||||||
this(plugin, song, shouldPlay, volumeMult, loop);
|
|
||||||
_players = players;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NotePlayer(JavaPlugin plugin, NoteSong song, Predicate<Player> shouldPlay, float volumeMult, boolean loop)
|
|
||||||
{
|
|
||||||
_plugin = plugin;
|
|
||||||
_song = song;
|
|
||||||
_shouldPlay = shouldPlay;
|
|
||||||
_sleepMs = (long) (1000 / (song.getTempo() / 100D));
|
|
||||||
_loop = loop;
|
|
||||||
_tick = 0;
|
|
||||||
_volumeMult = volumeMult;
|
|
||||||
_finished = false;
|
|
||||||
|
|
||||||
startThread();
|
|
||||||
|
|
||||||
SongStartEvent event = new SongStartEvent(_song);
|
|
||||||
_plugin.getServer().getPluginManager().callEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startThread()
|
|
||||||
{
|
|
||||||
Thread thread = new Thread(() ->
|
|
||||||
{
|
|
||||||
while (!_finished)
|
|
||||||
{
|
|
||||||
if (_paused)
|
|
||||||
{
|
|
||||||
sleep();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
_tick++;
|
|
||||||
if (_tick > _song.getLength())
|
|
||||||
{
|
|
||||||
if (_loop)
|
|
||||||
{
|
|
||||||
_tick = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_finished = true;
|
|
||||||
|
|
||||||
_plugin.getServer().getScheduler().runTask(_plugin, () ->
|
|
||||||
{
|
|
||||||
SongFinishEvent event = new SongFinishEvent(_song);
|
|
||||||
_plugin.getServer().getPluginManager().callEvent(event);
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
playTick(_tick);
|
|
||||||
sleep();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
thread.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void playTick(int tick)
|
|
||||||
{
|
|
||||||
Player[] playerArray = (_players != null) ? _players : UtilServer.getPlayers();
|
|
||||||
List<Player> players = new ArrayList<>(playerArray.length);
|
|
||||||
|
|
||||||
for (Player player : playerArray)
|
|
||||||
{
|
|
||||||
if (_shouldPlay == null || _shouldPlay.test(player))
|
|
||||||
{
|
|
||||||
players.add(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (NoteLayer layer : _song.getLayers())
|
|
||||||
{
|
|
||||||
Note note = layer.getNote(tick);
|
|
||||||
if (note != null)
|
|
||||||
{
|
|
||||||
Sound sound = UtilNote.getInstrumentSound(note.getInstrument());
|
|
||||||
float volume = _volumeMult * (layer.getVolume() / 100F);
|
|
||||||
float pitch = (float) UtilNote.getPitch(note.getNote() - 33);
|
|
||||||
|
|
||||||
for (Player player : players)
|
|
||||||
{
|
|
||||||
if (!_finished)
|
|
||||||
{
|
|
||||||
player.playSound(player.getEyeLocation(), sound, volume, pitch);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sleep()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Thread.sleep(_sleepMs);
|
|
||||||
}
|
|
||||||
catch (InterruptedException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void cancel()
|
|
||||||
{
|
|
||||||
_finished = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPaused(boolean paused)
|
|
||||||
{
|
|
||||||
_paused = paused;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +1,20 @@
|
|||||||
package mineplex.core.noteblock;
|
package mineplex.core.noteblock;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class NoteSong
|
public class NoteSong
|
||||||
{
|
{
|
||||||
|
|
||||||
// Song Data
|
// Song Data
|
||||||
private short _length;
|
private final short _length, _height;
|
||||||
private short _height;
|
private final String _name;
|
||||||
private String _name;
|
private final short _tempo;
|
||||||
private short _tempo;
|
private final byte _timeSignature;
|
||||||
private byte _timeSignature;
|
|
||||||
|
|
||||||
// Layer Data
|
// Layer Data
|
||||||
private HashMap<Integer, NoteLayer> _layerMap;
|
private final Map<Integer, NoteLayer> _layerMap;
|
||||||
|
|
||||||
public NoteSong(short length, short height, String name, short tempo, byte timeSignature, HashMap<Integer, NoteLayer> layerMap)
|
public NoteSong(short length, short height, String name, short tempo, byte timeSignature, Map<Integer, NoteLayer> layerMap)
|
||||||
{
|
{
|
||||||
_length = length;
|
_length = length;
|
||||||
_height = height;
|
_height = height;
|
||||||
@ -50,8 +49,8 @@ public class NoteSong
|
|||||||
return _timeSignature;
|
return _timeSignature;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<NoteLayer> getLayers()
|
public Map<Integer, NoteLayer> getLayerMap()
|
||||||
{
|
{
|
||||||
return _layerMap.values();
|
return _layerMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,74 @@
|
|||||||
|
package mineplex.core.noteblock;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
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
|
||||||
|
{
|
||||||
|
|
||||||
|
private final SimpleLifetime _lifetime;
|
||||||
|
|
||||||
|
public SingleRunNotePlayer(NoteSong song, Player player)
|
||||||
|
{
|
||||||
|
this(song, Collections.singleton(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
public SingleRunNotePlayer(NoteSong song, Predicate<Player> shouldPlay)
|
||||||
|
{
|
||||||
|
this(new SimpleLifetime(), song, (Collection<Player>) UtilServer.getPlayersCollection(), shouldPlay);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SingleRunNotePlayer(NoteSong song, Collection<Player> listeners)
|
||||||
|
{
|
||||||
|
this(new SimpleLifetime(), song, listeners, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SingleRunNotePlayer(NoteSong song, Collection<Player> listeners, Predicate<Player> shouldPlay)
|
||||||
|
{
|
||||||
|
this(new SimpleLifetime(), song, listeners, shouldPlay);
|
||||||
|
}
|
||||||
|
|
||||||
|
private SingleRunNotePlayer(SimpleLifetime lifetime, NoteSong song, Collection<Player> listeners, Predicate<Player> shouldPlay)
|
||||||
|
{
|
||||||
|
super(lifetime, song, listeners, shouldPlay);
|
||||||
|
|
||||||
|
_lifetime = lifetime;
|
||||||
|
lifetime.register(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start()
|
||||||
|
{
|
||||||
|
if (!_lifetime.isActive())
|
||||||
|
{
|
||||||
|
_lifetime.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void end()
|
||||||
|
{
|
||||||
|
if (_lifetime.isActive())
|
||||||
|
{
|
||||||
|
_lifetime.end();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSongEnd()
|
||||||
|
{
|
||||||
|
super.onSongEnd();
|
||||||
|
|
||||||
|
_lifetime.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SimpleLifetime getLifetime()
|
||||||
|
{
|
||||||
|
return _lifetime;
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,7 @@ import org.bukkit.Sound;
|
|||||||
*/
|
*/
|
||||||
public class UtilNote
|
public class UtilNote
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final double[] PITCH = { 0.5, 0.53, 0.56, 0.6, 0.63, 0.67, 0.7, 0.76, 0.8, 0.84, 0.9, 0.94, 1.0,
|
private static final double[] PITCH = { 0.5, 0.53, 0.56, 0.6, 0.63, 0.67, 0.7, 0.76, 0.8, 0.84, 0.9, 0.94, 1.0,
|
||||||
1.06, 1.12, 1.18, 1.26, 1.34, 1.42, 1.5, 1.6, 1.68, 1.78, 1.88, 2.0 };
|
1.06, 1.12, 1.18, 1.26, 1.34, 1.42, 1.5, 1.6, 1.68, 1.78, 1.88, 2.0 };
|
||||||
|
|
||||||
@ -31,12 +32,7 @@ public class UtilNote
|
|||||||
|
|
||||||
public static double getPitch(int note)
|
public static double getPitch(int note)
|
||||||
{
|
{
|
||||||
if (note >= 0 && note < PITCH.length)
|
return note >= 0 && note < PITCH.length ? PITCH[note] : 0;
|
||||||
{
|
|
||||||
return PITCH[note];
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
package mineplex.core.noteblock.event;
|
|
||||||
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
import mineplex.core.noteblock.NoteSong;
|
|
||||||
|
|
||||||
public class SongFinishEvent extends Event
|
|
||||||
{
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
public static HandlerList getHandlerList() { return handlers; }
|
|
||||||
public HandlerList getHandlers() { return handlers; }
|
|
||||||
|
|
||||||
private NoteSong _song;
|
|
||||||
|
|
||||||
public SongFinishEvent(NoteSong song)
|
|
||||||
{
|
|
||||||
_song = song;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NoteSong getSong()
|
|
||||||
{
|
|
||||||
return _song;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
package mineplex.core.noteblock.event;
|
|
||||||
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
import mineplex.core.noteblock.NoteSong;
|
|
||||||
|
|
||||||
public class SongStartEvent extends Event
|
|
||||||
{
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
public static HandlerList getHandlerList() { return handlers; }
|
|
||||||
public HandlerList getHandlers() { return handlers; }
|
|
||||||
|
|
||||||
private NoteSong _song;
|
|
||||||
|
|
||||||
public SongStartEvent(NoteSong song)
|
|
||||||
{
|
|
||||||
_song = song;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NoteSong getSong()
|
|
||||||
{
|
|
||||||
return _song;
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,6 +2,7 @@ package mineplex.game.nano.game.games.musicminecart;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -31,8 +32,8 @@ import mineplex.core.common.util.UtilAlg;
|
|||||||
import mineplex.core.common.util.UtilFirework;
|
import mineplex.core.common.util.UtilFirework;
|
||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilTextMiddle;
|
import mineplex.core.common.util.UtilTextMiddle;
|
||||||
|
import mineplex.core.noteblock.LoopedNotePlayer;
|
||||||
import mineplex.core.noteblock.NBSReader;
|
import mineplex.core.noteblock.NBSReader;
|
||||||
import mineplex.core.noteblock.NotePlayer;
|
|
||||||
import mineplex.core.noteblock.NoteSong;
|
import mineplex.core.noteblock.NoteSong;
|
||||||
import mineplex.game.nano.NanoManager;
|
import mineplex.game.nano.NanoManager;
|
||||||
import mineplex.game.nano.game.GameType;
|
import mineplex.game.nano.game.GameType;
|
||||||
@ -44,7 +45,7 @@ public class MusicMinecarts extends SoloGame
|
|||||||
{
|
{
|
||||||
|
|
||||||
private final Set<Minecart> _minecarts;
|
private final Set<Minecart> _minecarts;
|
||||||
private final NotePlayer _notePlayer;
|
private final LoopedNotePlayer _notePlayer;
|
||||||
|
|
||||||
private Location _center;
|
private Location _center;
|
||||||
private List<Location> _floor;
|
private List<Location> _floor;
|
||||||
@ -82,8 +83,8 @@ public class MusicMinecarts extends SoloGame
|
|||||||
|
|
||||||
if (song != null)
|
if (song != null)
|
||||||
{
|
{
|
||||||
_notePlayer = new NotePlayer(manager.getPlugin(), song, null, 0.5F, true);
|
_notePlayer = new LoopedNotePlayer(getLifetime(), song);
|
||||||
_notePlayer.setPaused(true);
|
getLifetime().register(_notePlayer, Collections.singleton(GameState.Live));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -142,7 +143,7 @@ public class MusicMinecarts extends SoloGame
|
|||||||
|
|
||||||
if (_notePlayer != null)
|
if (_notePlayer != null)
|
||||||
{
|
{
|
||||||
_notePlayer.setPaused(false);
|
_notePlayer.setPlaying(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
getManager().runSyncTimer(new BukkitRunnable()
|
getManager().runSyncTimer(new BukkitRunnable()
|
||||||
@ -158,7 +159,7 @@ public class MusicMinecarts extends SoloGame
|
|||||||
|
|
||||||
if (_notePlayer != null)
|
if (_notePlayer != null)
|
||||||
{
|
{
|
||||||
_notePlayer.setPaused(true);
|
_notePlayer.setPlaying(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
UtilTextMiddle.display(null, "Get in a " + C.cRed + "Minecart", 0, 20, 10, getAlivePlayers().toArray(new Player[0]));
|
UtilTextMiddle.display(null, "Get in a " + C.cRed + "Minecart", 0, 20, 10, getAlivePlayers().toArray(new Player[0]));
|
||||||
|
@ -68,7 +68,6 @@ import mineplex.core.menu.MenuManager;
|
|||||||
import mineplex.core.message.PrivateMessageEvent;
|
import mineplex.core.message.PrivateMessageEvent;
|
||||||
import mineplex.core.mission.MissionManager;
|
import mineplex.core.mission.MissionManager;
|
||||||
import mineplex.core.mission.MissionTrackerType;
|
import mineplex.core.mission.MissionTrackerType;
|
||||||
import mineplex.core.noteblock.MusicManager;
|
|
||||||
import mineplex.core.notifier.NotificationManager;
|
import mineplex.core.notifier.NotificationManager;
|
||||||
import mineplex.core.npc.NpcManager;
|
import mineplex.core.npc.NpcManager;
|
||||||
import mineplex.core.party.PartyManager;
|
import mineplex.core.party.PartyManager;
|
||||||
@ -223,8 +222,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
|||||||
new NotificationManager(getPlugin(), clientManager);
|
new NotificationManager(getPlugin(), clientManager);
|
||||||
new BotSpamManager(_plugin, clientManager, punish);
|
new BotSpamManager(_plugin, clientManager, punish);
|
||||||
|
|
||||||
new MusicManager((player) -> _preferences.get(player).isActive(Preference.HUB_MUSIC), "../../update/songs/lobbyMusic");
|
|
||||||
|
|
||||||
require(PlayerDisguiseManager.class);
|
require(PlayerDisguiseManager.class);
|
||||||
|
|
||||||
new SalesAnnouncementManager(_plugin);
|
new SalesAnnouncementManager(_plugin);
|
||||||
|
@ -29,8 +29,8 @@ import mineplex.core.common.util.UtilParticle.ViewDist;
|
|||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.noteblock.NBSReader;
|
import mineplex.core.noteblock.NBSReader;
|
||||||
import mineplex.core.noteblock.NotePlayer;
|
|
||||||
import mineplex.core.noteblock.NoteSong;
|
import mineplex.core.noteblock.NoteSong;
|
||||||
|
import mineplex.core.noteblock.SingleRunNotePlayer;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.core.world.MineplexWorld;
|
import mineplex.core.world.MineplexWorld;
|
||||||
@ -163,7 +163,7 @@ public class SecretAreas extends MiniPlugin
|
|||||||
Location location = clicked.getLocation();
|
Location location = clicked.getLocation();
|
||||||
|
|
||||||
UtilParticle.PlayParticleToAll(ParticleType.NOTE, location, 1, 1, 1, 0, 10, ViewDist.NORMAL);
|
UtilParticle.PlayParticleToAll(ParticleType.NOTE, location, 1, 1, 1, 0, 10, ViewDist.NORMAL);
|
||||||
new NotePlayer(_plugin, _tankSong, other -> UtilMath.offsetSquared(other.getLocation(), location) < 120, 1, false);
|
new SingleRunNotePlayer(_tankSong, other -> UtilMath.offsetSquared(other.getLocation(), location) < 120).start();
|
||||||
_lastTank = System.currentTimeMillis();
|
_lastTank = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,38 +1,11 @@
|
|||||||
package nautilus.game.arcade.game.games.valentines;
|
package nautilus.game.arcade.game.games.valentines;
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
import java.util.ArrayList;
|
||||||
import mineplex.core.common.util.Callback;
|
import java.util.HashMap;
|
||||||
import mineplex.core.common.util.F;
|
import java.util.HashSet;
|
||||||
import mineplex.core.common.util.MapUtil;
|
import java.util.Iterator;
|
||||||
import mineplex.core.common.util.UtilAction;
|
import java.util.List;
|
||||||
import mineplex.core.common.util.UtilAlg;
|
|
||||||
import mineplex.core.common.util.UtilBlock;
|
|
||||||
import mineplex.core.common.util.UtilEnt;
|
|
||||||
import mineplex.core.common.util.UtilMath;
|
|
||||||
import mineplex.core.common.util.UtilParticle;
|
|
||||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
|
||||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
|
||||||
import mineplex.core.common.util.UtilServer;
|
|
||||||
import mineplex.core.common.util.UtilTextBottom;
|
|
||||||
import mineplex.core.common.util.UtilTextMiddle;
|
|
||||||
import mineplex.core.common.util.UtilTime;
|
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
|
||||||
import mineplex.core.noteblock.NBSReader;
|
|
||||||
import mineplex.core.noteblock.NotePlayer;
|
|
||||||
import mineplex.core.noteblock.NoteSong;
|
|
||||||
import mineplex.core.preferences.Preference;
|
|
||||||
import mineplex.core.updater.UpdateType;
|
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
|
||||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
|
||||||
import nautilus.game.arcade.ArcadeManager;
|
|
||||||
import nautilus.game.arcade.GameType;
|
|
||||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
|
||||||
import nautilus.game.arcade.game.SoloGame;
|
|
||||||
import nautilus.game.arcade.game.games.valentines.kit.KitMasterOfLove;
|
|
||||||
import nautilus.game.arcade.game.games.valentines.tutorial.TutorialValentines;
|
|
||||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
|
||||||
import nautilus.game.arcade.kit.Kit;
|
|
||||||
import org.bukkit.EntityEffect;
|
import org.bukkit.EntityEffect;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -52,12 +25,36 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
|||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import mineplex.core.common.util.C;
|
||||||
import java.util.ArrayList;
|
import mineplex.core.common.util.Callback;
|
||||||
import java.util.HashMap;
|
import mineplex.core.common.util.F;
|
||||||
import java.util.HashSet;
|
import mineplex.core.common.util.MapUtil;
|
||||||
import java.util.Iterator;
|
import mineplex.core.common.util.UtilAction;
|
||||||
import java.util.List;
|
import mineplex.core.common.util.UtilAlg;
|
||||||
|
import mineplex.core.common.util.UtilBlock;
|
||||||
|
import mineplex.core.common.util.UtilEnt;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
import mineplex.core.common.util.UtilParticle;
|
||||||
|
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||||
|
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
import mineplex.core.common.util.UtilTextBottom;
|
||||||
|
import mineplex.core.common.util.UtilTextMiddle;
|
||||||
|
import mineplex.core.common.util.UtilTime;
|
||||||
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
|
import nautilus.game.arcade.GameType;
|
||||||
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
|
import nautilus.game.arcade.game.SoloGame;
|
||||||
|
import nautilus.game.arcade.game.games.valentines.kit.KitMasterOfLove;
|
||||||
|
import nautilus.game.arcade.game.games.valentines.tutorial.TutorialValentines;
|
||||||
|
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||||
|
import nautilus.game.arcade.kit.Kit;
|
||||||
|
|
||||||
public class Valentines extends SoloGame
|
public class Valentines extends SoloGame
|
||||||
{
|
{
|
||||||
@ -65,14 +62,8 @@ public class Valentines extends SoloGame
|
|||||||
|
|
||||||
private Cow _cow;
|
private Cow _cow;
|
||||||
|
|
||||||
private NotePlayer _music;
|
|
||||||
private NoteSong[] _songs;
|
|
||||||
private NoteSong _finalSong;
|
|
||||||
|
|
||||||
private int _playersOutPerRound = 1;
|
private int _playersOutPerRound = 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private HashSet<Block> _blocks = new HashSet<Block>();
|
private HashSet<Block> _blocks = new HashSet<Block>();
|
||||||
private int _blockMapHeight = 0;
|
private int _blockMapHeight = 0;
|
||||||
|
|
||||||
@ -121,19 +112,6 @@ public class Valentines extends SoloGame
|
|||||||
|
|
||||||
EnableTutorials = true;
|
EnableTutorials = true;
|
||||||
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_songs = new NoteSong[2];
|
|
||||||
_songs[0] = NBSReader.loadSong("../../update/songs/tetris.nbs");
|
|
||||||
_songs[1] = NBSReader.loadSong("../../update/songs/gangnam.nbs");
|
|
||||||
_finalSong = NBSReader.loadSong("../../update/songs/popcorn.nbs");
|
|
||||||
}
|
|
||||||
catch (FileNotFoundException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
new CompassModule()
|
new CompassModule()
|
||||||
.setGiveCompass(true)
|
.setGiveCompass(true)
|
||||||
.setGiveCompassToSpecs(true)
|
.setGiveCompassToSpecs(true)
|
||||||
@ -178,8 +156,6 @@ public class Valentines extends SoloGame
|
|||||||
UtilEnt.ghost(_cow, true, false);
|
UtilEnt.ghost(_cow, true, false);
|
||||||
CreatureAllowOverride = false;
|
CreatureAllowOverride = false;
|
||||||
}
|
}
|
||||||
if (event.GetState() == GameState.End || event.GetState() == GameState.Dead)
|
|
||||||
_music.cancel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -637,10 +613,7 @@ public class Valentines extends SoloGame
|
|||||||
|
|
||||||
_pigsDead.add(pig);
|
_pigsDead.add(pig);
|
||||||
pigIter.remove();
|
pigIter.remove();
|
||||||
}
|
};
|
||||||
|
|
||||||
//Stop Music
|
|
||||||
_music.cancel();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -687,13 +660,10 @@ public class Valentines extends SoloGame
|
|||||||
//Restock Pigs
|
//Restock Pigs
|
||||||
pigSpawn();
|
pigSpawn();
|
||||||
|
|
||||||
|
|
||||||
NoteSong noteSong;
|
|
||||||
//Announce
|
//Announce
|
||||||
if (_pigs.size() > 1)
|
if (_pigs.size() > 1)
|
||||||
{
|
{
|
||||||
UtilTextMiddle.display(C.cYellow + "Round " + _round, _item.getTitle(), 0, 80, 20);
|
UtilTextMiddle.display(C.cYellow + "Round " + _round, _item.getTitle(), 0, 80, 20);
|
||||||
noteSong = _songs[_round % _songs.length];
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -701,11 +671,7 @@ public class Valentines extends SoloGame
|
|||||||
|
|
||||||
for (Player player : GetPlayers(true))
|
for (Player player : GetPlayers(true))
|
||||||
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SADDLE, (byte)0, 1, "Pig Saddle"));
|
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SADDLE, (byte)0, 1, "Pig Saddle"));
|
||||||
noteSong = _finalSong;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Music!
|
|
||||||
_music = new NotePlayer(Manager.getPlugin(), noteSong, p -> Manager.getPreferences().get(p).isActive(Preference.HUB_MUSIC), 0.7F, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user