Java Reference
In-Depth Information
PropertiesFile config = getConfig();
numSquids = config.getInt(
"numSquids"
, 6);
squidDropHeight = config.getDouble(
"squidDropHeight"
, 5.0);
setFire = config.getBoolean(
"setFire"
, false);
config.save();
// Create a new one if needed
return
true;
}
@Command(aliases = {
"squidbombc"
},
description =
"Drop a configurable number of squid on your head."
,
permissions = {
""
},
toolTip =
"/squidbombc"
)
public void
squidbombCommand(MessageReceiver caller,
String[]
args) {
if
(caller
instanceof
Player) {
Player me = (Player)caller;
Location loc = me.getLocation();
double
y = loc.getY();
loc.setY(y + squidDropHeight);
me.chat(
"Spawning "
+ numSquids +
" squid."
);
// Spawning some squid. Derp.
for
(
int
i = 0; i < numSquids; i++) {
spawnEntityLiving(loc, EntityType.SQUID);
}
}
}
➤
@Command(aliases = {
"squidpurge"
},
➤
description =
"Get rid of squid."
,
➤
permissions = {
""
},
➤
toolTip =
"/squidpurge"
)
➤
public void
squidpurgeCommand(MessageReceiver caller,
String[]
args) {
➤
if
(caller
instanceof
Player) {
➤
➤
Player me = (Player)caller;
➤
Collection
<EntityLiving> squidlist = me.getWorld().getEntityLivingList();
➤
for
(EntityLiving entity : squidlist) {
➤
if
(entity
instanceof
Squid) {
➤
Squid victim = (Squid)entity;
➤
if
(setFire) {
➤
victim.setFireTicks(600);
➤
}
else
{
➤
victim.setHealth(0.0f);
➤
}
➤
}
➤
}
➤
}
➤
}
}