implemented spawnSheep(Player, int)
This commit is contained in:
parent
76c7cb706c
commit
edef18aa4c
@ -1,6 +1,7 @@
|
|||||||
package gibstick.bukkit.DiscoSheep;
|
package gibstick.bukkit.DiscoSheep;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.lang.Math;
|
||||||
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;
|
||||||
@ -19,7 +20,7 @@ public final class DiscoSheep extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
// Watashi Wa Kawaii, Ne?
|
// Watashi Wa Kawaii, Ne?
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnSheep(World world, Location loc) {
|
public void spawnSheep(World world, Location loc) {
|
||||||
@ -28,20 +29,26 @@ public final class DiscoSheep extends JavaPlugin {
|
|||||||
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
|
||||||
public void spawnSheep(Player player, int num) {
|
public void spawnSheep(Player player, int num) {
|
||||||
Location loc;
|
Location loc;
|
||||||
|
World world = player.getWorld();
|
||||||
|
|
||||||
for (int i = 0; i < num; i++) {
|
for (int i = 0; i < num; i++) {
|
||||||
loc = null;
|
double x, y, z;
|
||||||
|
|
||||||
|
// random x and z coordinates within a 5 block radius
|
||||||
|
// safe y-coordinate
|
||||||
|
x = -5 + (Math.random() * ((5 - (-5)) + 1)) + player.getLocation().getX();
|
||||||
|
z = -5 + (Math.random() * ((5 - (-5)) + 1)) + player.getLocation().getZ();
|
||||||
|
y = world.getHighestBlockYAt((int) x, (int) z);
|
||||||
|
loc = new Location(world, x, y, z);
|
||||||
|
|
||||||
|
spawnSheep(world, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// change
|
|
||||||
/// change
|
|
||||||
/// change
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark all sheep in the sheep array for removal
|
// Mark all sheep in the sheep array for removal
|
||||||
public void removeAllSheep() {
|
public void removeAllSheep() {
|
||||||
for (int i = 0; i < sheepArray.size(); i++) {
|
for (int i = 0; i < sheepArray.size(); i++) {
|
||||||
@ -49,13 +56,11 @@ public final class DiscoSheep extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
sheepArray.clear();
|
sheepArray.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cycle colours of all sheep in the array
|
// Cycle colours of all sheep in the array
|
||||||
public void cycleSheepColours() {
|
public 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user