I cannot into git

This commit is contained in:
Charlie Wang 2013-06-30 14:48:36 -04:00
parent bf15d90dcd
commit eda4007b1e
4 changed files with 120 additions and 121 deletions

View File

@ -1,97 +1,97 @@
package gibstick.bukkit.discosheep; package gibstick.bukkit.discosheep;
import java.util.ArrayList; import java.util.ArrayList;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.entity.Sheep; import org.bukkit.entity.Sheep;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
public final class DiscoSheep extends JavaPlugin { public final class DiscoSheep extends JavaPlugin {
private ArrayList<Sheep> sheepArray = new ArrayList<>(); private ArrayList<Sheep> sheepArray = new ArrayList<>();
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 static int sheepSpawnRadius = 5;
@Override @Override
public void onEnable() { public void onEnable() {
getCommand("ds").setExecutor(new DiscoSheepCommandExecutor(this)); getCommand("ds").setExecutor(new DiscoSheepCommandExecutor(this));
} }
@Override @Override
public void onDisable() { public void onDisable() {
// Watashi Wa Kawaii, Ne? // Watashi Wa Kawaii, Ne?
} }
void spawnSheep(World world, Location loc) { void spawnSheep(World world, Location loc) {
Sheep newSheep = (Sheep) world.spawnEntity(loc, EntityType.SHEEP); Sheep newSheep = (Sheep) world.spawnEntity(loc, EntityType.SHEEP);
newSheep.setMaxHealth(10000); newSheep.setMaxHealth(10000);
newSheep.setHealth(10000); newSheep.setHealth(10000);
sheepArray.add(newSheep); sheepArray.add(newSheep);
} }
// Spawn some number of sheep next to given player // Spawn some number of sheep next to given player
void spawnSheep(Player player, int num) { void spawnSheep(Player player, int num) {
Location loc; Location loc;
World world = player.getWorld(); World world = player.getWorld();
for (int i = 0; i < num; i++) { for (int i = 0; i < num; i++) {
double x, y, z; double x, y, z;
// random x and z coordinates within a 5 block radius // random x and z coordinates within a 5 block radius
// safe y-coordinate // safe y-coordinate
x = -sheepSpawnRadius + (Math.random() * ((sheepSpawnRadius * 2) + 1)) + player.getLocation().getX(); x = -sheepSpawnRadius + (Math.random() * ((sheepSpawnRadius * 2) + 1)) + player.getLocation().getX();
z = -sheepSpawnRadius + (Math.random() * ((sheepSpawnRadius * 2) + 1)) + player.getLocation().getZ(); z = -sheepSpawnRadius + (Math.random() * ((sheepSpawnRadius * 2) + 1)) + player.getLocation().getZ();
y = world.getHighestBlockYAt((int) x, (int) z); y = world.getHighestBlockYAt((int) x, (int) z);
loc = new Location(world, x, y, z); loc = new Location(world, x, y, z);
spawnSheep(world, loc); spawnSheep(world, loc);
} }
} }
// Mark all sheep in the sheep array for removal // Mark all sheep in the sheep array for removal
void removeAllSheep() { void removeAllSheep() {
for (int i = 0; i < sheepArray.size(); i++) { for (int i = 0; i < sheepArray.size(); i++) {
sheepArray.get(i).remove(); sheepArray.get(i).remove();
} }
sheepArray.clear(); sheepArray.clear();
} }
// Cycle colours of all sheep in the array // Cycle colours of all sheep in the array
void cycleSheepColours() { void cycleSheepColours() {
for (int i = 0; i < sheepArray.size(); i++) { for (int i = 0; i < sheepArray.size(); i++) {
//sheepArray.get(i) something something //sheepArray.get(i) something something
} }
} }
void playSounds() { void playSounds() {
// TODO: generate list of players to send sounds to // TODO: generate list of players to send sounds to
} }
void playSounds(Player player) { void playSounds(Player player) {
//TODO: Add sound playing here //TODO: Add sound playing here
} }
// Called after discosheep is stopped // Called after discosheep is stopped
void cleanUp() { void cleanUp() {
removeAllSheep(); removeAllSheep();
} }
void scheduleUpdate() { void scheduleUpdate() {
updater.runTaskLater((Plugin) updater, updater.frequency); updater.runTaskLater((Plugin) updater, updater.frequency);
} }
void startDisco(int frequency, int duration) { void startDisco(int frequency, int duration) {
updater.start(frequency, duration); updater.start(frequency, duration);
} }
void startDisco() { void startDisco() {
this.startDisco(); this.startDisco();
} }
void stopDisco() { void stopDisco() {
updater.stop(); updater.stop();
} }
} }

View File

@ -1,22 +1,22 @@
package gibstick.bukkit.DiscoSheep; package gibstick.bukkit.discosheep;
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;
public class DiscoSheepCommandExecutor implements CommandExecutor { public class DiscoSheepCommandExecutor implements CommandExecutor {
private DiscoSheep plugin; private DiscoSheep parent;
public DiscoSheepCommandExecutor(DiscoSheep plugin) { public DiscoSheepCommandExecutor(DiscoSheep parent) {
this.plugin = plugin; this.parent = parent;
} }
@Override @Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
return true; return true;
} }
} }

View File

@ -1,6 +1,5 @@
package gibstick.bukkit.discosheep; package gibstick.bukkit.discosheep;
import gibstick.bukkit.DiscoSheep.DiscoSheep;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
public class DiscoUpdater extends BukkitRunnable { public class DiscoUpdater extends BukkitRunnable {

View File

@ -1,3 +1,3 @@
name: DiscoSheep name: DiscoSheep
main: gibstick.bukkit.DiscoSheep.DiscoSheep main: gibstick.bukkit.DiscoSheep.DiscoSheep
version: 0.5 version: 0.6