Permalink
Browse files

Added option to disable playing message in Melody IC.

  • Loading branch information...
me4502 committed Dec 19, 2016
1 parent ffd930f commit 271cfe6247ac5cb1d682aef65c9c893c3092bd57
Showing with 13 additions and 10 deletions.
  1. +13 −10 src/main/java/com/sk89q/craftbook/mechanics/ic/gates/world/miscellaneous/Melody.java
@@ -9,6 +9,8 @@
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MidiUnavailableException;
+import com.sk89q.craftbook.mechanics.ic.*;
+import com.sk89q.util.yaml.YAMLProcessor;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Server;
@@ -17,14 +19,6 @@
import com.sk89q.craftbook.ChangedSign;
import com.sk89q.craftbook.LocalPlayer;
import com.sk89q.craftbook.bukkit.CraftBookPlugin;
-import com.sk89q.craftbook.mechanics.ic.AbstractICFactory;
-import com.sk89q.craftbook.mechanics.ic.AbstractSelfTriggeredIC;
-import com.sk89q.craftbook.mechanics.ic.ChipState;
-import com.sk89q.craftbook.mechanics.ic.IC;
-import com.sk89q.craftbook.mechanics.ic.ICFactory;
-import com.sk89q.craftbook.mechanics.ic.ICManager;
-import com.sk89q.craftbook.mechanics.ic.ICMechanic;
-import com.sk89q.craftbook.mechanics.ic.ICVerificationException;
import com.sk89q.craftbook.util.RegexUtil;
import com.sk89q.craftbook.util.SearchArea;
import com.sk89q.craftbook.util.jinglenote.JingleNoteManager;
@@ -145,7 +139,9 @@ public void trigger(ChipState chip) {
player.stop(pp.getName());
} else if(!player.isPlaying(pp.getName()) && area.isWithinArea(pp.getLocation())) {
player.play(pp.getName());
- pp.sendMessage(ChatColor.YELLOW + "Playing " + midiName + "...");
+ if (((Factory) getFactory()).showPlayingMessage) {
+ pp.sendMessage(ChatColor.YELLOW + "Playing " + midiName + "...");
+ }
if(!hasRun) {
Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), player);
hasRun = true;
@@ -245,7 +241,9 @@ public boolean isValid() {
}
}
- public static class Factory extends AbstractICFactory {
+ public static class Factory extends AbstractICFactory implements ConfigurableIC {
+
+ private boolean showPlayingMessage;
public Factory(Server server) {
@@ -285,6 +283,11 @@ public String getShortDescription() {
};
}
+ @Override
+ public void addConfiguration(YAMLProcessor config, String path) {
+ showPlayingMessage = config.getBoolean(path + "show-playing-message", true);
+ }
+
@Override
public String[] getLineHelp() {

0 comments on commit 271cfe6

Please sign in to comment.