Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Midi Fixes

  • Loading branch information...
commit 4965ee254aa328cb3b78bd307ce07c2815559d2f 1 parent 9fca67b
@me4502 me4502 authored
View
6 circuits/src/main/java/com/sk89q/craftbook/bukkit/CircuitsPlugin.java
@@ -18,6 +18,8 @@
package com.sk89q.craftbook.bukkit;
+import java.io.File;
+
import org.bukkit.Chunk;
import org.bukkit.Server;
import org.bukkit.World;
@@ -71,6 +73,10 @@ public void onEnable() {
MechanicListenerAdapter adapter = new MechanicListenerAdapter(this);
adapter.register(manager);
+ File midi = new File(getDataFolder(),"midi/");
+ if(!midi.exists())
+ midi.mkdir();
+
registerICs();
// Let's register mechanics!
View
29 circuits/src/main/java/com/sk89q/craftbook/gates/world/Melody.java
@@ -16,6 +16,7 @@
import com.sk89q.craftbook.ic.SelfTriggeredIC;
import com.sk89q.jinglenote.JingleNoteComponent;
import com.sk89q.jinglenote.MidiJingleSequencer;
+import com.sk89q.minecraft.util.commands.CommandException;
public class Melody extends AbstractIC{
@@ -40,7 +41,30 @@ public void trigger(ChipState chip) {
{
String midiName = getSign().getLine(2);
- MidiJingleSequencer sequencer = new MidiJingleSequencer(new File(CircuitsPlugin.getInst().getDataFolder(), midiName));
+ File[] trialPaths = {
+ new File(CircuitsPlugin.getInst().getDataFolder(), "midi/" + midiName),
+ new File(CircuitsPlugin.getInst().getDataFolder(), "midi/" + midiName + ".mid"),
+ new File(CircuitsPlugin.getInst().getDataFolder(), "midi/" + midiName + ".midi"),
+ new File("midi", midiName),
+ new File("midi", midiName + ".mid"),
+ new File("midi", midiName + ".midi"),
+ };
+
+ File file = null;
+
+ for (File f : trialPaths) {
+ if (f.exists()) {
+ file = f;
+ break;
+ }
+ }
+
+ if (file == null) {
+ getServer().getLogger().log(Level.SEVERE, "Midi file not found!");
+ return;
+ }
+
+ MidiJingleSequencer sequencer = new MidiJingleSequencer(file);
for (Player player : getServer().getOnlinePlayers()) {
JingleNoteComponent.getJingleNoteManager().play(player, sequencer, 0);
player.sendMessage(ChatColor.YELLOW + "Playing " + midiName + "...");
@@ -48,7 +72,8 @@ public void trigger(ChipState chip) {
}
}
catch(Exception e){
- getServer().getLogger().log(Level.SEVERE, "Midi Failed To Play!");
+ getServer().getLogger().log(Level.SEVERE, "[CraftBookCircuits]: Midi Failed To Play!");
+ getServer().getLogger().log(Level.SEVERE, "[CraftBookCircuits]: " + e.getMessage());
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.