@Override public boolean cast(@Nullable String[] extraParameters, @Nullable Location defaultLocation) { ConfigurationSection parameters = null; if (extraParameters != null && extraParameters.length > 0) { parameters = new MemoryConfiguration(); ConfigurationUtils.addParameters(extraParameters, parameters); } return cast(parameters, defaultLocation); }
@Override public boolean cast(String spellName, String[] parameters, CommandSender sender, Entity entity) { ConfigurationSection config = null; if (parameters != null && parameters.length > 0) { config = new MemoryConfiguration(); ConfigurationUtils.addParameters(parameters, config); } return controller.cast(null, spellName, config, sender, entity); }
@Override public void load(DataKey data) { super.load(data); spellKey = data.getString("spell", null); npcCaster = data.getBoolean("caster", false); targetPlayer = data.getBoolean("target_player", true); messagePlayer = data.getBoolean("message_player", false); String parameterString = data.getString("parameters", null); parameters = new YamlConfiguration(); if (parameterString != null && !parameterString.isEmpty()) { if (!parameterString.contains(":")) { String[] simple = StringUtils.split(parameterString, ' '); if (simple.length > 0) { ConfigurationUtils.addParameters(simple, parameters); } } else { try { parameters.loadFromString(parameterString); } catch (Exception ex) { ex.printStackTrace(); } } } }
describeParameters(sender); } else { ConfigurationUtils.addParameters(params, parameters); sender.sendMessage(ChatColor.DARK_PURPLE + "Set parameters to: "); describeParameters(sender);
private void onAddAutomata(Player player, String[] args) { if (args.length == 0) { player.sendMessage(ChatColor.RED + "Usage: " + ChatColor.WHITE + "/mauto add <template>"); return; } String key = args[0]; if (!magicController.isAutomataTemplate(key)) { player.sendMessage(ChatColor.RED + "Invalid automata template: " + ChatColor.DARK_RED + key); return; } Location location = player.getLocation(); Automaton existing = magicController.getAutomatonAt(location); if (existing != null) { player.sendMessage(ChatColor.RED + "Automata already exists: " + ChatColor.LIGHT_PURPLE + existing.getTemplateKey() + ChatColor.RED + " at " + TextUtils.printLocation(existing.getLocation(), 0)); return; } ConfigurationSection parameters = null; if (args.length > 1) { String[] parameterArgs = Arrays.copyOfRange(args, 1, args.length); parameters = new MemoryConfiguration(); ConfigurationUtils.addParameters(parameterArgs, parameters); } Automaton automaton = new Automaton(magicController, location, key, player.getUniqueId().toString(), player.getName(), parameters); magicController.registerAutomaton(automaton); playEffects(player, automaton, "blockselect"); getSelection(player).selected = automaton; player.sendMessage(ChatColor.AQUA + "Created automaton: " + ChatColor.LIGHT_PURPLE + automaton.getTemplateKey() + ChatColor.AQUA + " at " + TextUtils.printLocation(automaton.getLocation(), 0)); }
if (castParameterString != null && !castParameterString.isEmpty()) { castParameters = new MemoryConfiguration(); ConfigurationUtils.addParameters(StringUtils.split(castParameterString, ' '), castParameters); } else { castParameters = null;