From 14a349e6a0abccf33531c5324e65bcf77f10e43b Mon Sep 17 00:00:00 2001 From: RangerMauve Date: Sun, 30 Jun 2013 17:25:45 -0400 Subject: [PATCH] Added actual command registering stuff, maybe? --- src/gibstick/bukkit/discosheep/DiscoSheep.java | 16 ++++++++++++---- .../discosheep/DiscoSheepCommandExecutor.java | 9 ++++++++- src/gibstick/bukkit/discosheep/DiscoUpdater.java | 6 ++---- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/gibstick/bukkit/discosheep/DiscoSheep.java b/src/gibstick/bukkit/discosheep/DiscoSheep.java index 295620f..c60f144 100644 --- a/src/gibstick/bukkit/discosheep/DiscoSheep.java +++ b/src/gibstick/bukkit/discosheep/DiscoSheep.java @@ -1,6 +1,7 @@ package gibstick.bukkit.discosheep; import java.util.ArrayList; +import java.util.List; import org.bukkit.DyeColor; import org.bukkit.Location; import org.bukkit.World; @@ -29,7 +30,11 @@ public final class DiscoSheep extends JavaPlugin { }; // array of accetable disco colours (order not important) private DiscoUpdater updater = new DiscoUpdater(this); // radius for random sheep spawns around player - private static int sheepSpawnRadius = 5; + private final int sheepSpawnRadius = 5; + private final int defaultSheepAmount = 10; + private final int defaultDuration = 1000;// ticks + private final int defaultFrequency = 20;// ticks per state change + @Override public void onEnable() { @@ -104,12 +109,15 @@ public final class DiscoSheep extends JavaPlugin { updater.runTaskLater((Plugin) updater, updater.frequency); } - void startDisco(int frequency, int duration) { + void startDisco(int frequency, int duration, List players) { + for(Player player : players){ + this.spawnSheep(player, this.defaultSheepAmount); + } updater.start(frequency, duration); } - void startDisco() { - this.startDisco(); + void startDisco(List players) { + this.startDisco(this.defaultFrequency,this.defaultDuration,players); } void stopDisco() { diff --git a/src/gibstick/bukkit/discosheep/DiscoSheepCommandExecutor.java b/src/gibstick/bukkit/discosheep/DiscoSheepCommandExecutor.java index f81a1b1..f786f36 100644 --- a/src/gibstick/bukkit/discosheep/DiscoSheepCommandExecutor.java +++ b/src/gibstick/bukkit/discosheep/DiscoSheepCommandExecutor.java @@ -1,8 +1,11 @@ package gibstick.bukkit.discosheep; +import java.util.ArrayList; +import java.util.List; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.CommandExecutor; +import org.bukkit.entity.Player; public class DiscoSheepCommandExecutor implements CommandExecutor { @@ -14,7 +17,11 @@ public class DiscoSheepCommandExecutor implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { - + if(sender instanceof Player){ + List players = new ArrayList(); + players.add((Player)sender); + parent.startDisco(players); + } return true; } } diff --git a/src/gibstick/bukkit/discosheep/DiscoUpdater.java b/src/gibstick/bukkit/discosheep/DiscoUpdater.java index d383c84..848f60f 100644 --- a/src/gibstick/bukkit/discosheep/DiscoUpdater.java +++ b/src/gibstick/bukkit/discosheep/DiscoUpdater.java @@ -4,8 +4,6 @@ import org.bukkit.scheduler.BukkitRunnable; public class DiscoUpdater extends BukkitRunnable { - private final int defaultDuration = 1000;// ticks - private final int defaultFrequency = 20;// ticks per state change int frequency = 0, duration = 0; private DiscoSheep parent; @@ -19,8 +17,8 @@ public class DiscoUpdater extends BukkitRunnable { } public void start(int duration, int frequency) { - this.frequency = this.defaultFrequency; - this.duration = this.defaultDuration; + this.frequency = frequency; + this.duration = duration; parent.scheduleUpdate(); }