Added actual command registering stuff, maybe?
This commit is contained in:
parent
803470a76b
commit
14a349e6a0
@ -1,6 +1,7 @@
|
|||||||
package gibstick.bukkit.discosheep;
|
package gibstick.bukkit.discosheep;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -29,7 +30,11 @@ public final class DiscoSheep extends JavaPlugin {
|
|||||||
}; // array of accetable disco colours (order not important)
|
}; // array of accetable disco colours (order not important)
|
||||||
private DiscoUpdater updater = new DiscoUpdater(this);
|
private DiscoUpdater updater = new DiscoUpdater(this);
|
||||||
// radius for random sheep spawns around player
|
// 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
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
@ -104,12 +109,15 @@ public final class DiscoSheep extends JavaPlugin {
|
|||||||
updater.runTaskLater((Plugin) updater, updater.frequency);
|
updater.runTaskLater((Plugin) updater, updater.frequency);
|
||||||
}
|
}
|
||||||
|
|
||||||
void startDisco(int frequency, int duration) {
|
void startDisco(int frequency, int duration, List<Player> players) {
|
||||||
|
for(Player player : players){
|
||||||
|
this.spawnSheep(player, this.defaultSheepAmount);
|
||||||
|
}
|
||||||
updater.start(frequency, duration);
|
updater.start(frequency, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
void startDisco() {
|
void startDisco(List<Player> players) {
|
||||||
this.startDisco();
|
this.startDisco(this.defaultFrequency,this.defaultDuration,players);
|
||||||
}
|
}
|
||||||
|
|
||||||
void stopDisco() {
|
void stopDisco() {
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
package gibstick.bukkit.discosheep;
|
package gibstick.bukkit.discosheep;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class DiscoSheepCommandExecutor implements CommandExecutor {
|
public class DiscoSheepCommandExecutor implements CommandExecutor {
|
||||||
|
|
||||||
@ -14,7 +17,11 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
|
if(sender instanceof Player){
|
||||||
|
List<Player> players = new ArrayList<Player>();
|
||||||
|
players.add((Player)sender);
|
||||||
|
parent.startDisco(players);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,6 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
|
|
||||||
public class DiscoUpdater extends 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;
|
int frequency = 0, duration = 0;
|
||||||
private DiscoSheep parent;
|
private DiscoSheep parent;
|
||||||
|
|
||||||
@ -19,8 +17,8 @@ public class DiscoUpdater extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void start(int duration, int frequency) {
|
public void start(int duration, int frequency) {
|
||||||
this.frequency = this.defaultFrequency;
|
this.frequency = frequency;
|
||||||
this.duration = this.defaultDuration;
|
this.duration = duration;
|
||||||
parent.scheduleUpdate();
|
parent.scheduleUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user