Java Reference
In-Depth Information
@Command(aliases = {
"testexplode"
},
description =
"Test cow explode"
,
permissions = {
""
},
min = 1,
// Number of arguments
toolTip =
"/testexplode"
)
public void
testExplodeCommand(MessageReceiver caller,
String[]
args) {
if
(caller
instanceof
Player) {
Player me = (Player)caller;
List
<CreeperCowTimer> list =
new ArrayList
<CreeperCowTimer>();
for
(Cow c : allCows.keySet()) {
CreeperCowTimer superCow = allCows.get(c);
list.add(superCow);
}
for
(CreeperCowTimer superCow : list) {
superCow.explode();
}
}
}
@HookHandler
public void
onChunkLoad(ChunkLoadedHook event) {
if
(enabled) {
World world = event.getWorld();
Chunk chunk = event.getChunk();
if
(
Math
.random() > 0.10) {
// Only make a cow 1 in 10
return
;
}
logger.info(
"[CreeperCow] Spawning"
);
// The X and Z from the chunk are indexes;
// we have to multiply by 16 to get an actual
// block location.
Location start =
new
Location(
chunk.getX() * CHUNK_SIZE,
0,
chunk.getZ() * CHUNK_SIZE);
spawnCows(start, 16, 1);
}
}
@HookHandler
public void
onChunkUnload(ChunkUnloadHook event) {
Chunk chunk = event.getChunk();
List
<
Entity
>
[]
all = chunk.getEntityLists();
for
(
int
i = 0; i < all.length; i++) {
for
(
Entity
ent : all[i]) {
// List of 16 block subchunks
if
(ent
instanceof
Cow) {
Cow cow = (Cow) ent;
if
(allCows.containsKey(cow)) {