use of com.elmakers.mine.bukkit.api.magic.MaterialSet in project MagicPlugin by elBukkit.
the class SimpleMaterialSetManager method createMaterialSetFromString.
private MaterialSet createMaterialSetFromString(String materialSet) {
if (materialSet.equals("*")) {
return MaterialSets.wildcard();
}
boolean negate;
String materialString;
if (materialSet.startsWith("!")) {
materialString = materialSet.substring(1);
negate = true;
} else {
materialString = materialSet;
negate = false;
}
String[] names = StringUtils.split(materialString, ',');
MaterialSet created = createMaterialSetFromStringList(Arrays.asList(names), true);
return negate ? created.not() : created;
}
use of com.elmakers.mine.bukkit.api.magic.MaterialSet in project MagicPlugin by elBukkit.
the class AbsorbAction method perform.
@SuppressWarnings("deprecation")
@Override
public SpellResult perform(CastContext context) {
Block target = context.getTargetBlock();
Mage mage = context.getMage();
Wand wand = context.getWand();
if (wand == null) {
return SpellResult.FAIL;
}
MageController controller = context.getController();
Material material = target.getType();
byte data = target.getData();
MaterialSet buildingMaterials = controller.getBuildingMaterialSet();
MaterialSet restrictedMaterials = mage.getRestrictedMaterialSet();
if (material == null || material == Material.AIR) {
return SpellResult.NO_TARGET;
}
if (!mage.getCommandSender().hasPermission("Magic.bypass_restricted") && (!buildingMaterials.testBlock(target) || restrictedMaterials.testBlock(target))) {
return SpellResult.NO_TARGET;
}
// Add to the wand
MaterialAndData mat = new MaterialAndData(material, data);
if (!wand.addBrush(mat.getKey())) {
// Still try and activate it
wand.setActiveBrush(mat.getKey());
return SpellResult.NO_TARGET;
}
// And activate it
wand.setActiveBrush(mat.getKey());
return SpellResult.CAST;
}
use of com.elmakers.mine.bukkit.api.magic.MaterialSet in project MagicPlugin by elBukkit.
the class Wand method makeEnchantable.
public void makeEnchantable(boolean enchantable) {
if (EnchantableWandMaterial == null)
return;
if (!enchantable) {
item.setType(icon.getMaterial());
item.setDurability(icon.getData());
} else {
MaterialSet enchantableMaterials = controller.getMaterialSetManager().getMaterialSetEmpty("enchantable");
if (!enchantableMaterials.testItem(item)) {
item.setType(EnchantableWandMaterial);
item.setDurability((short) 0);
}
}
updateName();
}
use of com.elmakers.mine.bukkit.api.magic.MaterialSet in project MagicPlugin by elBukkit.
the class MaterialSetsTest method testFromConfig.
@SuppressWarnings("deprecation")
@Test
public void testFromConfig() {
MaterialAndData value = ConfigurationUtils.toMaterialAndData("stone|2");
MaterialSet set = MaterialSets.unionBuilder().add(value).build();
assertFalse(set.testBlock(stone()));
assertFalse(set.testBlock(dirt()));
Block correct = stone();
Mockito.when(correct.getData()).thenReturn((byte) 2);
assertTrue(set.testBlock(correct));
}
use of com.elmakers.mine.bukkit.api.magic.MaterialSet in project MagicPlugin by elBukkit.
the class MaterialSetsTest method testTestBlock.
@Test
public void testTestBlock() {
MaterialSet set = MaterialSets.unionBuilder().add(Material.STONE).build();
assertTrue(set.testBlock(stone()));
assertFalse(set.testBlock(dirt()));
}
Aggregations