use of com.elmakers.mine.bukkit.block.MaterialAndData in project MagicPlugin by elBukkit.
the class MagicItemCommandExecutor method onItemType.
public boolean onItemType(Player player, ItemStack item, String[] parameters) {
if (parameters.length < 1) {
return false;
}
String materialKey = parameters[0];
MaterialAndData material = new MaterialAndData(materialKey);
if (!material.isValid() || material.getMaterial() == Material.AIR) {
player.sendMessage(ChatColor.RED + "Invalid material key: " + ChatColor.DARK_RED + materialKey);
return true;
}
material.applyToItem(item);
return true;
}
use of com.elmakers.mine.bukkit.block.MaterialAndData in project MagicPlugin by elBukkit.
the class Wand method loadProperties.
@Override
public void loadProperties() {
super.loadProperties();
locked = getBoolean("locked", locked);
lockedAllowUpgrades = getBoolean("locked_allow_upgrades", false);
consumeReduction = getFloat("consume_reduction");
cooldownReduction = getFloat("cooldown_reduction");
costReduction = getFloat("cost_reduction");
power = getFloat("power");
ConfigurationSection protectionConfig = getConfigurationSection("protection");
if (protectionConfig == null && hasProperty("protection")) {
migrateProtection("protection", "overall");
migrateProtection("protection_physical", "physical");
migrateProtection("protection_projectiles", "projectile");
migrateProtection("protection_falling", "fall");
migrateProtection("protection_fire", "fire");
migrateProtection("protection_explosions", "explosion");
protectionConfig = getConfigurationSection("protection");
}
if (protectionConfig != null) {
protection = new HashMap<>();
for (String protectionKey : protectionConfig.getKeys(false)) {
protection.put(protectionKey, protectionConfig.getDouble(protectionKey));
}
}
hasId = getBoolean("unique", false);
blockChance = getFloat("block_chance");
blockReflectChance = getFloat("block_reflect_chance");
blockFOV = getFloat("block_fov");
blockMageCooldown = getInt("block_mage_cooldown");
blockCooldown = getInt("block_cooldown");
manaPerDamage = getFloat("mana_per_damage");
spMultiplier = getFloat("sp_multiplier", 1);
String singleClass = getString("class");
if (singleClass != null && !singleClass.isEmpty()) {
mageClassKeys = new ArrayList<>();
mageClassKeys.add(singleClass);
} else {
mageClassKeys = getStringList("classes");
}
// Check for single-use wands
uses = getInt("uses");
hasUses = uses > 0;
// Convert some legacy properties to potion effects
float healthRegeneration = getFloat("health_regeneration", 0);
float hungerRegeneration = getFloat("hunger_regeneration", 0);
float speedIncrease = getFloat("haste", 0);
if (speedIncrease > 0) {
potionEffects.put(PotionEffectType.SPEED, 1);
}
if (healthRegeneration > 0) {
potionEffects.put(PotionEffectType.REGENERATION, 1);
}
if (hungerRegeneration > 0) {
potionEffects.put(PotionEffectType.SATURATION, 1);
}
// This overrides the value loaded in CasterProperties
if (!regenWhileInactive) {
setProperty("mana_timestamp", System.currentTimeMillis());
}
if (hasProperty("effect_color")) {
setEffectColor(getString("effect_color"));
}
id = getString("id");
isUpgrade = getBoolean("upgrade");
quietLevel = getInt("quiet");
effectBubbles = getBoolean("effect_bubbles");
keep = getBoolean("keep");
passive = getBoolean("passive");
indestructible = getBoolean("indestructible");
superPowered = getBoolean("powered");
superProtected = getBoolean("protected");
glow = getBoolean("glow");
undroppable = getBoolean("undroppable");
isHeroes = getBoolean("heroes");
bound = getBoolean("bound");
forceUpgrade = getBoolean("force");
autoOrganize = getBoolean("organize");
autoAlphabetize = getBoolean("alphabetize");
autoFill = getBoolean("fill");
rename = getBoolean("rename");
renameDescription = getBoolean("rename_description");
enchantCount = getInt("enchant_count");
maxEnchantCount = getInt("max_enchant_count");
inventoryRows = getInt("inventory_rows", 5);
if (inventoryRows <= 0)
inventoryRows = 1;
if (hasProperty("effect_particle")) {
effectParticle = ConfigurationUtils.toParticleEffect(getString("effect_particle"));
effectParticleData = 0;
} else {
effectParticle = null;
}
if (hasProperty("effect_sound")) {
effectSound = ConfigurationUtils.toSoundEffect(getString("effect_sound"));
} else {
effectSound = null;
}
activeEffectsOnly = getBoolean("active_effects");
effectParticleData = getFloat("effect_particle_data");
effectParticleCount = getInt("effect_particle_count");
effectParticleRadius = getDouble("effect_particle_radius");
effectParticleOffset = getDouble("effect_particle_offset");
effectParticleInterval = getInt("effect_particle_interval");
effectParticleMinVelocity = getDouble("effect_particle_min_velocity");
effectSoundInterval = getInt("effect_sound_interval");
castLocation = getVector("cast_location");
castInterval = getInt("cast_interval");
castMinVelocity = getDouble("cast_min_velocity");
castVelocityDirection = getVector("cast_velocity_direction");
castSpell = getString("cast_spell");
String castParameterString = getString("cast_parameters", null);
if (castParameterString != null && !castParameterString.isEmpty()) {
castParameters = new MemoryConfiguration();
ConfigurationUtils.addParameters(StringUtils.split(castParameterString, ' '), castParameters);
} else {
castParameters = null;
}
WandMode newMode = parseWandMode(getString("mode"), controller.getDefaultWandMode());
if (newMode != mode) {
if (isInventoryOpen()) {
closeInventory();
}
mode = newMode;
}
brushMode = parseWandMode(getString("brush_mode"), controller.getDefaultBrushMode());
// Backwards compatibility
if (getBoolean("mode_drop", false)) {
dropAction = WandAction.TOGGLE;
swapAction = WandAction.CYCLE_HOTBAR;
rightClickAction = WandAction.NONE;
quickCast = true;
// This is to turn the redundant spell lore off
quickCastDisabled = true;
manualQuickCastDisabled = false;
} else if (mode == WandMode.CAST) {
leftClickAction = WandAction.CAST;
rightClickAction = WandAction.CAST;
swapAction = WandAction.NONE;
dropAction = WandAction.NONE;
} else if (mode == WandMode.CYCLE) {
leftClickAction = WandAction.CAST;
rightClickAction = WandAction.NONE;
swapAction = WandAction.NONE;
dropAction = WandAction.CYCLE;
} else {
leftClickAction = WandAction.NONE;
rightClickAction = WandAction.NONE;
dropAction = WandAction.NONE;
swapAction = WandAction.NONE;
quickCast = false;
quickCastDisabled = false;
manualQuickCastDisabled = false;
}
String quickCastType = getString("quick_cast", getString("mode_cast"));
if (quickCastType != null) {
if (quickCastType.equalsIgnoreCase("true")) {
quickCast = true;
// This is to turn the redundant spell lore off
quickCastDisabled = true;
manualQuickCastDisabled = false;
} else if (quickCastType.equalsIgnoreCase("manual")) {
quickCast = false;
quickCastDisabled = true;
manualQuickCastDisabled = false;
} else if (quickCastType.equalsIgnoreCase("disable")) {
quickCast = false;
quickCastDisabled = true;
manualQuickCastDisabled = true;
} else {
quickCast = false;
quickCastDisabled = false;
manualQuickCastDisabled = false;
}
}
leftClickAction = parseWandAction(getString("left_click"), leftClickAction);
rightClickAction = parseWandAction(getString("right_click"), rightClickAction);
dropAction = parseWandAction(getString("drop"), dropAction);
swapAction = parseWandAction(getString("swap"), swapAction);
owner = getString("owner");
ownerId = getString("owner_id");
template = getString("template");
upgradeTemplate = getString("upgrade_template");
path = getString("path");
activeSpell = getString("active_spell");
if (activeSpell != null && activeSpell.contains("|")) {
SpellKey activeKey = new SpellKey(activeSpell);
activeSpell = activeKey.getBaseKey();
setProperty("active_spell", activeSpell);
}
alternateSpell = getString("alternate_spell");
alternateSpell2 = getString("alternate_spell2");
activeBrush = getString("active_brush", getString("active_material"));
if (hasProperty("hotbar")) {
currentHotbar = getInt("hotbar");
}
if (hasProperty("page")) {
int page = getInt("page");
if (page != openInventoryPage) {
openInventoryPage = page;
}
}
// Default to template names, override with localizations and finally with wand data
wandName = controller.getMessages().get("wand.default_name");
description = "";
// Check for migration information in the template config
ConfigurationSection templateConfig = null;
if (template != null && !template.isEmpty()) {
templateConfig = controller.getWandTemplateConfiguration(template);
if (templateConfig != null) {
wandName = templateConfig.getString("name", wandName);
description = templateConfig.getString("description", description);
int templateUses = templateConfig.getInt("uses");
isSingleUse = templateUses == 1;
hasUses = hasUses || templateUses > 0;
}
wandName = controller.getMessages().get("wands." + template + ".name", wandName);
description = controller.getMessages().get("wands." + template + ".description", description);
}
wandName = getString("name", wandName);
description = getString("description", description);
WandTemplate wandTemplate = getTemplate();
// Add vanilla attributes
InventoryUtils.applyAttributes(item, getConfigurationSection("item_attributes"), getString("item_attribute_slot", getString("attribute_slot")));
// Add unstashable and unmoveable tags
if (getBoolean("unstashable") || (undroppable && Unstashable)) {
InventoryUtils.setMetaBoolean(item, "unstashable", true);
} else {
InventoryUtils.removeMeta(item, "unstashable");
}
if (getBoolean("unmoveable")) {
InventoryUtils.setMetaBoolean(item, "unmoveable", true);
} else {
InventoryUtils.removeMeta(item, "unmoveable");
}
if (undroppable) {
InventoryUtils.setMetaBoolean(item, "undroppable", true);
} else {
InventoryUtils.removeMeta(item, "undroppable");
}
if (keep) {
InventoryUtils.setMetaBoolean(item, "keep", true);
} else {
InventoryUtils.removeMeta(item, "keep");
}
// Add vanilla enchantments
ConfigurationSection enchantments = getConfigurationSection("enchantments");
InventoryUtils.applyEnchantments(item, enchantments);
// Add enchantment glow
if (enchantments == null || enchantments.getKeys(false).isEmpty()) {
if (glow) {
CompatibilityUtils.addGlow(item);
} else {
CompatibilityUtils.removeGlow(item);
}
}
if (hasProperty("icon_inactive")) {
String iconKey = getString("icon_inactive");
if (wandTemplate != null) {
iconKey = wandTemplate.migrateIcon(iconKey);
}
if (iconKey != null) {
inactiveIcon = new MaterialAndData(iconKey);
}
} else {
inactiveIcon = null;
}
if (inactiveIcon != null && (inactiveIcon.getMaterial() == null || inactiveIcon.getMaterial() == Material.AIR)) {
inactiveIcon = null;
}
inactiveIconDelay = getInt("icon_inactive_delay");
randomizeOnActivate = randomizeOnActivate && hasProperty("randomize_icon");
if (randomizeOnActivate) {
String randomizeIcon = getString("randomize_icon");
setIcon(new MaterialAndData(randomizeIcon));
if (item == null) {
controller.getLogger().warning("Invalid randomize_icon in wand '" + template + "' config: " + randomizeIcon);
}
} else if (hasProperty("icon")) {
String iconKey = getString("icon");
if (wandTemplate != null) {
iconKey = wandTemplate.migrateIcon(iconKey);
}
if (iconKey.contains(",")) {
Random r = new Random();
String[] keys = StringUtils.split(iconKey, ',');
iconKey = keys[r.nextInt(keys.length)];
}
// Port old custom wand icons
if (templateConfig != null && iconKey.contains("i.imgur.com")) {
iconKey = templateConfig.getString("icon");
}
setIcon(new MaterialAndData(iconKey));
if (item == null) {
controller.getLogger().warning("Invalid icon in wand '" + template + "' config: " + iconKey);
}
updateIcon();
} else if (isUpgrade) {
setIcon(new MaterialAndData(DefaultUpgradeMaterial));
} else {
setIcon(new MaterialAndData(DefaultWandMaterial));
}
if (hasProperty("upgrade_icon")) {
upgradeIcon = new MaterialAndData(getString("upgrade_icon"));
}
// Check for path-based migration, may update icons
com.elmakers.mine.bukkit.api.wand.WandUpgradePath upgradePath = getPath();
if (upgradePath != null) {
hasSpellProgression = upgradePath.getSpells().size() > 0 || upgradePath.getExtraSpells().size() > 0 || upgradePath.getRequiredSpells().size() > 0;
upgradePath.checkMigration(this);
} else {
hasSpellProgression = false;
}
if (isHeroes) {
hasSpellProgression = true;
}
brushInventory.clear();
spellInventory.clear();
limitSpellsToPath = getBoolean("limit_spells_to_path");
limitBrushesToPath = getBoolean("limit_brushes_to_path");
loadSpells();
// Load spell levels
Object spellLevelsRaw = getObject("spell_levels");
if (spellLevelsRaw != null) {
// Not sure this will ever appear as a Map, but just in case
if (spellLevelsRaw instanceof Map) {
@SuppressWarnings("unchecked") Map<String, Integer> spellLevels = (Map<String, Integer>) spellLevelsRaw;
loadSpellLevels(spellLevels);
} else if (spellLevelsRaw instanceof ConfigurationSection) {
loadSpellLevels(NMSUtils.getMap((ConfigurationSection) spellLevelsRaw));
}
}
checkActiveSpell();
loadBrushes();
Object brushInventoryRaw = getObject("brush_inventory");
if (brushInventoryRaw != null) {
// Not sure this will ever appear as a Map, but just in case
if (brushInventoryRaw instanceof Map) {
@SuppressWarnings("unchecked") Map<String, Integer> brushInventory = (Map<String, Integer>) brushInventoryRaw;
loadBrushInventory(brushInventory);
} else if (brushInventoryRaw instanceof ConfigurationSection) {
loadBrushInventory(NMSUtils.getMap((ConfigurationSection) brushInventoryRaw));
}
}
Object spellInventoryRaw = getObject("spell_inventory");
if (spellInventoryRaw != null) {
// Not sure this will ever appear as a Map, but just in case
if (spellInventoryRaw instanceof Map) {
@SuppressWarnings("unchecked") Map<String, Integer> spellInventory = (Map<String, Integer>) spellInventoryRaw;
loadSpellInventory(spellInventory);
} else if (spellInventoryRaw instanceof ConfigurationSection) {
loadSpellInventory(NMSUtils.getMap((ConfigurationSection) spellInventoryRaw));
}
} else {
// Spells may have contained an inventory from migration or templates with a spell@slot format.
updateSpellInventory();
}
castOverrides = null;
if (hasProperty("overrides")) {
castOverrides = null;
Object overridesGeneric = getObject("overrides");
if (overridesGeneric != null) {
castOverrides = new HashMap<>();
if (overridesGeneric instanceof String) {
String overrides = (String) overridesGeneric;
if (!overrides.isEmpty()) {
// Support YML-List-As-String format
// May not really need this anymore.
overrides = overrides.replaceAll("[\\]\\[]", "");
String[] pairs = StringUtils.split(overrides, ',');
for (String override : pairs) {
parseOverride(override);
}
}
} else if (overridesGeneric instanceof List) {
@SuppressWarnings("unchecked") List<String> overrideList = (List<String>) overridesGeneric;
for (String override : overrideList) {
parseOverride(override);
}
} else if (overridesGeneric instanceof ConfigurationSection) {
ConfigurationSection overridesSection = (ConfigurationSection) overridesGeneric;
Set<String> keys = overridesSection.getKeys(true);
for (String key : keys) {
Object leaf = overridesSection.get(key);
if (!(leaf instanceof ConfigurationSection) && !(leaf instanceof Map)) {
castOverrides.put(key, leaf.toString());
}
}
}
}
}
potionEffects.clear();
if (hasProperty("potion_effects")) {
addPotionEffects(potionEffects, getString("potion_effects", null));
}
// so try to keep defaults as 0/0.0/false.
if (effectSound == null) {
effectSoundInterval = 0;
} else {
effectSoundInterval = (effectSoundInterval == 0) ? 5 : effectSoundInterval;
}
if (effectParticle == null) {
effectParticleInterval = 0;
}
checkActiveMaterial();
}
use of com.elmakers.mine.bukkit.block.MaterialAndData in project MagicPlugin by elBukkit.
the class RecurseSpell method onCast.
@Override
public SpellResult onCast(ConfigurationSection parameters) {
Block targetBlock = getTargetBlock();
if (targetBlock == null) {
return SpellResult.NO_TARGET;
}
if (!hasBuildPermission(targetBlock)) {
return SpellResult.INSUFFICIENT_PERMISSION;
}
if (!isDestructible(targetBlock)) {
return SpellResult.NO_TARGET;
}
BlockRecurse blockRecurse = new BlockRecurse();
int size = parameters.getInt("size", 8);
size = (int) (mage.getRadiusMultiplier() * size);
blockRecurse.setMaxRecursion(size);
ModifyBlockAction action = new ModifyBlockAction();
action.initialize(this, parameters);
blockRecurse.addReplaceable(new MaterialAndData(targetBlock));
Material targetMaterial = targetBlock.getType();
// A bit hacky, but is very handy!
if (targetMaterial == Material.STATIONARY_WATER || targetMaterial == Material.WATER) {
for (byte i = 0; i < 9; i++) {
blockRecurse.addReplaceable(Material.STATIONARY_WATER, i);
blockRecurse.addReplaceable(Material.WATER, i);
}
} else if (targetMaterial == Material.STATIONARY_LAVA || targetMaterial == Material.LAVA) {
for (byte i = 0; i < 9; i++) {
blockRecurse.addReplaceable(Material.STATIONARY_LAVA, i);
blockRecurse.addReplaceable(Material.LAVA, i);
}
} else if (targetMaterial == Material.SNOW) {
for (byte i = 0; i < 8; i++) {
blockRecurse.addReplaceable(Material.SNOW, i);
}
}
CastContext context = getCurrentCast();
context.setTargetLocation(targetBlock.getLocation());
blockRecurse.recurse(new ActionContext(action, parameters), context);
registerForUndo();
controller.updateBlock(targetBlock);
return SpellResult.CAST;
}
use of com.elmakers.mine.bukkit.block.MaterialAndData in project MagicPlugin by elBukkit.
the class SimulateSpell method onCast.
@Override
public SpellResult onCast(ConfigurationSection parameters) {
Target t = getTarget();
if (t == null) {
return SpellResult.NO_TARGET;
}
Block target = t.getBlock();
if (target == null) {
return SpellResult.NO_TARGET;
}
if (!hasBuildPermission(target)) {
return SpellResult.INSUFFICIENT_PERMISSION;
}
int radius = parameters.getInt("radius", DEFAULT_RADIUS);
radius = parameters.getInt("r", radius);
int yRadius = parameters.getInt("yradius", 0);
MaterialAndData birthMaterial = new MaterialAndData(target);
birthMaterial = ConfigurationUtils.getMaterialAndData(parameters, "material", birthMaterial);
birthMaterial = ConfigurationUtils.getMaterialAndData(parameters, "m", birthMaterial);
Double dmxValue = ConfigurationUtils.getDouble(parameters, "obx", null);
Double dmyValue = ConfigurationUtils.getDouble(parameters, "oby", null);
Double dmzValue = ConfigurationUtils.getDouble(parameters, "obz", null);
if (dmxValue != null || dmyValue != null || dmzValue != null) {
Vector offset = new Vector(dmxValue == null ? 0 : dmxValue, dmyValue == null ? 0 : dmyValue, dmzValue == null ? 0 : dmzValue);
Location targetLocation = target.getLocation().add(offset);
if (!targetLocation.getBlock().getChunk().isLoaded())
return SpellResult.FAIL;
birthMaterial = new MaterialAndData(targetLocation.getBlock());
}
Material deathMaterial = ConfigurationUtils.getMaterial(parameters, "death_material", Material.AIR);
// use the target location with the player's facing
Location location = getLocation();
Location targetLocation = target.getLocation();
targetLocation.setPitch(location.getPitch());
targetLocation.setYaw(location.getYaw());
// Look for relative-positioned chests that define the rulesets.
Set<Integer> birthCounts = new HashSet<>();
Set<Integer> liveCounts = new HashSet<>();
Double dlcxValue = ConfigurationUtils.getDouble(parameters, "olcx", null);
Double dlcyValue = ConfigurationUtils.getDouble(parameters, "olcy", null);
Double dlczValue = ConfigurationUtils.getDouble(parameters, "olcz", null);
if (dlcxValue != null || dlcyValue != null || dlczValue != null) {
Location liveChestLocation = targetLocation.clone().add(new Vector(dlcxValue == null ? 0 : dlcxValue, dlcyValue == null ? 0 : dlcyValue, dlczValue == null ? 0 : dlczValue));
Block chestBlock = liveChestLocation.getBlock();
BlockState chestState = chestBlock.getState();
if (chestState instanceof InventoryHolder) {
ItemStack[] items = ((InventoryHolder) chestState).getInventory().getContents();
for (int index = 0; index < items.length; index++) {
if (items[index] != null && items[index].getType() != Material.AIR) {
liveCounts.add(index + 1);
// controller.getLogger().info("SimulateSpell: Added live rules for index " + (index + 1) + " from chest at " + liveChestLocation.toVector());
}
}
} else {
controller.getLogger().warning("SimulateSpell: Chest for live rules not found at " + liveChestLocation.toVector());
}
} else if (parameters.contains("live_rules")) {
liveCounts.addAll(ConfigurationUtils.getIntegerList(parameters, "live_rules"));
} else {
liveCounts.add(2);
liveCounts.add(3);
}
Double dbcxValue = ConfigurationUtils.getDouble(parameters, "obcx", null);
Double dbcyValue = ConfigurationUtils.getDouble(parameters, "obcy", null);
Double dbczValue = ConfigurationUtils.getDouble(parameters, "obcz", null);
if (dbcxValue != null || dbcyValue != null || dbczValue != null) {
Location birthChestLocation = targetLocation.clone().add(new Vector(dbcxValue == null ? 0 : dbcxValue, dbcyValue == null ? 0 : dbcyValue, dbczValue == null ? 0 : dbczValue));
Block chestBlock = birthChestLocation.getBlock();
BlockState chestState = chestBlock.getState();
if (chestState instanceof InventoryHolder) {
ItemStack[] items = ((InventoryHolder) chestState).getInventory().getContents();
for (int index = 0; index < items.length; index++) {
if (items[index] != null && items[index].getType() != Material.AIR) {
birthCounts.add(index + 1);
// controller.getLogger().info("SimulateSpell: Added birth rules for index " + (index + 1) + " from chest at " + birthChestLocation.toVector());
}
}
} else {
controller.getLogger().warning("SimulateSpell: Chest for birth rules not found at " + birthChestLocation.toVector());
}
} else if (parameters.contains("birth_rules")) {
birthCounts.addAll(ConfigurationUtils.getIntegerList(parameters, "birth_rules"));
} else {
birthCounts.add(3);
}
if (liveCounts.size() == 0 || birthCounts.size() == 0) {
return SpellResult.FAIL;
}
String automataName = parameters.getString("animate", null);
boolean isAutomata = automataName != null;
final SimulateBatch batch = new SimulateBatch(this, targetLocation, radius, yRadius, birthMaterial, deathMaterial, liveCounts, birthCounts, automataName);
if (parameters.contains("diagonal_live_rules")) {
batch.setDiagonalLiveRules(ConfigurationUtils.getIntegerList(parameters, "diagonal_live_rules"));
}
if (parameters.contains("diagonal_birth_rules")) {
batch.setDiagonalBirthRules(ConfigurationUtils.getIntegerList(parameters, "diagonal_birth_rules"));
}
batch.setReflectChange(parameters.getDouble("reflect_chance", 0));
batch.setBirthRange(parameters.getInt("birth_range", 0));
batch.setLiveRange(parameters.getInt("live_range", 0));
batch.setConcurrent(parameters.getBoolean("concurrent", false));
batch.setCastRange(parameters.getInt("cast_range", 16));
int delay = parameters.getInt("delay", 0);
if (isAutomata) {
SimulateBatch.TargetMode targetMode = null;
String targetModeString = parameters.getString("target_mode", "");
if (targetModeString.length() > 0) {
try {
targetMode = SimulateBatch.TargetMode.valueOf(targetModeString.toUpperCase());
} catch (Exception ex) {
controller.getLogger().warning(ex.getMessage());
}
}
SimulateBatch.TargetMode backupTargetMode = null;
String backupTargetModeString = parameters.getString("backup_target_mode", "");
if (backupTargetModeString.length() > 0) {
try {
backupTargetMode = SimulateBatch.TargetMode.valueOf(backupTargetModeString.toUpperCase());
} catch (Exception ex) {
controller.getLogger().warning(ex.getMessage());
}
}
batch.setMoveRange(parameters.getInt("move", 3));
SimulateBatch.TargetType targetType = null;
String targetTypeString = parameters.getString("targets", "");
if (targetTypeString.length() > 0) {
try {
targetType = SimulateBatch.TargetType.valueOf(targetTypeString.toUpperCase());
} catch (Exception ex) {
controller.getLogger().warning(ex.getMessage());
}
}
batch.setTargetType(targetType);
batch.setMinHuntRange(parameters.getInt("target_min_range", 4));
batch.setMaxHuntRange(parameters.getInt("target_max_range", 128));
batch.setDrop(parameters.getString("drop"), parameters.getInt("drop_xp", 0), ConfigurationUtils.getStringList(parameters, "drops"));
int maxBlocks = parameters.getInt("max_blocks");
batch.setMaxBlocks(maxBlocks);
batch.setMinBlocks(parameters.getInt("min_blocks", maxBlocks));
int level = parameters.getInt("level", 1);
if (level < 1)
level = 1;
if (levelMap != null) {
AutomatonLevel automatonLevel = levelMap.get(level);
batch.setLevel(automatonLevel);
delay = automatonLevel.getDelay(delay);
}
batch.setDelay(delay);
if (targetMode != null) {
batch.setTargetMode(targetMode);
}
if (backupTargetMode != null) {
batch.setBackupTargetMode(backupTargetMode);
}
}
boolean success = mage.addBatch(batch);
return success ? SpellResult.CAST : SpellResult.FAIL;
}
use of com.elmakers.mine.bukkit.block.MaterialAndData 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));
}
Aggregations