Java Reference
In-Depth Information
allCows.get(cow).removeMe();
allCows.remove(cow);
}
}
}
}
}
@HookHandler
public void
onEntityDamage(DamageHook event) {
Entity
ent = event.getDefender();
if
(ent
instanceof
Cow) {
Cow cow = (Cow) ent;
if
(event.getDamageSource().getDamagetype() == DamageType.FALL) {
if
(allCows.containsKey(cow)) {
event.setCanceled();
}
}
}
}
}
package
creepercow;
import
java.util.List;
import
java.util.ArrayList;
import
net.canarymod.Canary;
import
net.canarymod.api.entity.EntityType;
import
net.canarymod.api.world.position.Location;
import
net.canarymod.api.entity.living.humanoid.Player;
import
net.canarymod.api.entity.living.animal.Cow;
import
net.canarymod.api.world.position.Vector3D;
import
net.canarymod.api.world.blocks.Block;
import
net.canarymod.api.world.blocks.BlockType;
import
net.canarymod.tasks.ServerTask;
import
com.pragprog.ahmine.ez.EZPlugin;
public class
CreeperCowTimer
extends
ServerTask {
private
Cow cow;
private
CreeperCow plugin;
CreeperCowTimer(CreeperCow parentPlugin, Cow aCow) {
super(Canary.getServer(), 0, true);
// delay, isContinuous
cow = aCow;
plugin = parentPlugin;
}
public
Player getClosestPlayer(Location loc) {
//return -1 on failure