summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-06-23 19:34:51 +0200
committersnowleo <schneeleo@gmail.com>2011-06-23 19:34:51 +0200
commit6b360da8d8ea57af2e2fae11caa4d3de454a7f80 (patch)
tree7f3c3f8d6cc5d63f99512ed2719c1417f948ecc0
parent198b205d83cc492bd2a0e0e656ae8a1d19814340 (diff)
downloadEssentials-6b360da8d8ea57af2e2fae11caa4d3de454a7f80.tar
Essentials-6b360da8d8ea57af2e2fae11caa4d3de454a7f80.tar.gz
Essentials-6b360da8d8ea57af2e2fae11caa4d3de454a7f80.tar.lz
Essentials-6b360da8d8ea57af2e2fae11caa4d3de454a7f80.tar.xz
Essentials-6b360da8d8ea57af2e2fae11caa4d3de454a7f80.zip
Cleanup
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandessentials.java98
1 files changed, 97 insertions, 1 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java
index 84daceba0..bf0226138 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java
@@ -1,8 +1,14 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Util;
+import java.util.HashMap;
+import java.util.Map;
+import org.bukkit.Location;
+import org.bukkit.Material;
import org.bukkit.Server;
+import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
public class Commandessentials extends EssentialsCommand
@@ -11,12 +17,102 @@ public class Commandessentials extends EssentialsCommand
{
super("essentials");
}
+ private transient int taskid;
+ private final transient Map<Player, Block> noteBlocks = new HashMap<Player, Block>();
@Override
- public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
+ public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
+ final Map<String, Byte> noteMap = new HashMap<String, Byte>();
+ noteMap.put("1F#", (byte)0x0);
+ noteMap.put("1G", (byte)0x1);
+ noteMap.put("1G#", (byte)0x2);
+ noteMap.put("1A", (byte)0x3);
+ noteMap.put("1A#", (byte)0x4);
+ noteMap.put("1B", (byte)0x5);
+ noteMap.put("1C", (byte)0x6);
+ noteMap.put("1C#", (byte)0x7);
+ noteMap.put("1D", (byte)0x8);
+ noteMap.put("1D#", (byte)0x9);
+ noteMap.put("1E", (byte)0xA);
+ noteMap.put("1F", (byte)0xB);
+ noteMap.put("2F#", (byte)(0x0 + 0xC));
+ noteMap.put("2G", (byte)(0x1 + 0xC));
+ noteMap.put("2G#", (byte)(0x2 + 0xC));
+ noteMap.put("2A", (byte)(0x3 + 0xC));
+ noteMap.put("2A#", (byte)(0x4 + 0xC));
+ noteMap.put("2B", (byte)(0x5 + 0xC));
+ noteMap.put("2C", (byte)(0x6 + 0xC));
+ noteMap.put("2C#", (byte)(0x7 + 0xC));
+ noteMap.put("2D", (byte)(0x8 + 0xC));
+ noteMap.put("2D#", (byte)(0x9 + 0xC));
+ noteMap.put("2E", (byte)(0xA + 0xC));
+ noteMap.put("2F", (byte)(0xB + 0xC));
+ if (args.length > 0 && args[0].equalsIgnoreCase("nya"))
+ {
+ if (!noteBlocks.isEmpty())
+ {
+ return;
+ }
+ final String tuneStr = "1D#,1E,2F#,,2A#,1E,1D#,1E,2F#,2B,2D#,2E,2D#,2A#,2B,,2F#,,1D#,1E,2F#,2B,2C#,2A#,2B,2C#,2E,2D#,2E,2C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G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1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1B,,";
+ final String[] tune = tuneStr.split(",");
+
+ for (Player player : server.getOnlinePlayers())
+ {
+ final Location loc = player.getLocation();
+ loc.add(0, 3, 0);
+ while (loc.getBlockY() < player.getLocation().getBlockY() + 10 && loc.getBlock().getTypeId() != 0)
+ {
+ loc.add(0, 1, 0);
+ }
+ if (loc.getBlock().getTypeId() == 0)
+ {
+ noteBlocks.put(player, loc.getBlock());
+ loc.getBlock().setType(Material.NOTE_BLOCK);
+ }
+ }
+ taskid = ess.scheduleSyncRepeatingTask(new Runnable()
+ {
+ int i = 0;
+
+ public void run()
+ {
+ final String note = tune[i];
+ i++;
+ if (i >= tune.length)
+ {
+ Commandessentials.this.stopTune();
+ }
+ if (note.isEmpty())
+ {
+ return;
+ }
+ Map<Player, Block> noteBlocks = Commandessentials.this.noteBlocks;
+ for (Player player : server.getOnlinePlayers())
+ {
+ Block block = noteBlocks.get(player);
+ if (block == null)
+ {
+ continue;
+ }
+ player.playNote(block.getLocation(), (byte)0, noteMap.get(note));
+ }
+ }
+ }, 20, 2);
+ return;
+ }
ess.reload();
charge(sender);
sender.sendMessage(Util.format("essentialsReload", ess.getDescription().getVersion()));
}
+
+ private void stopTune()
+ {
+ ess.getScheduler().cancelTask(taskid);
+ for (Block block : noteBlocks.values())
+ {
+ block.setType(Material.AIR);
+ }
+ noteBlocks.clear();
+ }
}