use of ch.njol.util.Checker in project MagicPlugin by elBukkit.
the class CondHasPath method check.
@Override
public boolean check(final Event e) {
return entities.check(e, new Checker<Entity>() {
@Override
public boolean check(final Entity entity) {
final Mage mage = MagicPlugin.getAPI().getController().getRegisteredMage(entity);
if (mage == null) {
return false;
}
return paths.check(e, new Checker<String>() {
@Override
public boolean check(final String pathKey) {
Wand wand = mage.getActiveWand();
if (checkPath(wand, pathKey)) {
return true;
}
MageClass activeClass = mage.getActiveClass();
if (checkPath(activeClass, pathKey)) {
return true;
}
return false;
}
}, isNegated());
}
});
}
use of ch.njol.util.Checker in project MagicPlugin by elBukkit.
the class CondHasItem method check.
@Override
public boolean check(final Event e) {
return entities.check(e, new Checker<Entity>() {
@Override
public boolean check(final Entity entity) {
final MageController controller = MagicPlugin.getAPI().getController();
final Mage mage = controller.getRegisteredMage(entity);
if (mage == null) {
return false;
}
final Wand wand = offhand ? mage.getOffhandWand() : mage.getActiveWand();
if (itemKeys == null) {
return (wand != null) != isNegated();
}
final LivingEntity living = mage.getLivingEntity();
final ItemStack item = wand == null && living != null ? (offhand ? living.getEquipment().getItemInOffHand() : living.getEquipment().getItemInMainHand()) : null;
return itemKeys.check(e, new Checker<String>() {
@Override
public boolean check(final String targetKey) {
if (armor) {
if (living == null)
return false;
for (ItemStack armorItem : living.getEquipment().getArmorContents()) {
if (armorItem == null)
continue;
String key = controller.getWandKey(armorItem);
if (key != null && key.equalsIgnoreCase(targetKey))
return true;
key = controller.getItemKey(armorItem);
if (key != null && key.equalsIgnoreCase(targetKey))
return true;
}
return false;
}
if (wand != null && wand.getTemplateKey().equalsIgnoreCase(targetKey)) {
return true;
}
if (item != null) {
String itemKey = controller.getItemKey(item);
if (itemKey != null && itemKey.equalsIgnoreCase(targetKey)) {
return true;
}
}
return false;
}
}, isNegated());
}
});
}
use of ch.njol.util.Checker in project MagicPlugin by elBukkit.
the class CondHasSpell method check.
@Override
public boolean check(final Event e) {
return entities.check(e, new Checker<Entity>() {
@Override
public boolean check(final Entity entity) {
final Mage mage = MagicPlugin.getAPI().getController().getRegisteredMage(entity);
if (mage == null) {
return false;
}
return spells.check(e, new Checker<String>() {
@Override
public boolean check(final String spellKey) {
Wand wand = mage.getActiveWand();
if (wand != null && wand.hasSpell(spellKey)) {
return true;
}
MageClass activeClass = mage.getActiveClass();
if (activeClass != null && activeClass.hasSpell(spellKey)) {
return true;
}
return false;
}
}, isNegated());
}
});
}
Aggregations