Skip to content

Commit eb4a6c0

Browse files
committed
Separate common compound action parameters from base action parameters
1 parent e7c1edb commit eb4a6c0

3 files changed

Lines changed: 40 additions & 10 deletions

File tree

src/main/java/com/elmakers/mine/bukkit/meta/MagicMeta.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@
1212

1313
import org.bukkit.entity.Player;
1414
import org.reflections.Reflections;
15+
16+
import com.elmakers.mine.bukkit.action.BaseSpellAction;
1517
import com.elmakers.mine.bukkit.action.CastContext;
1618
import com.elmakers.mine.bukkit.action.CompoundAction;
1719
import com.elmakers.mine.bukkit.api.action.SpellAction;
20+
import com.elmakers.mine.bukkit.api.spell.SpellResult;
1821
import com.elmakers.mine.bukkit.effect.EffectPlayer;
1922
import com.elmakers.mine.bukkit.effect.builtin.EffectSingle;
2023
import com.elmakers.mine.bukkit.entity.EntityData;
@@ -147,13 +150,26 @@ private void generateActionMeta() {
147150
CastContext context = new CastContext(spell);
148151

149152
// First get base action parameters
150-
SpellAction baseAction = new CompoundAction() {};
153+
154+
BaseSpellAction baseAction = new BaseSpellAction() {
155+
@Override
156+
public SpellResult perform(com.elmakers.mine.bukkit.api.action.CastContext context) {
157+
return SpellResult.NO_ACTION;
158+
}
159+
};
151160
InterrogatingConfiguration baseConfiguration = new InterrogatingConfiguration(data.getParameterStore());
152161
baseAction.initialize(spell, baseConfiguration);
153162
baseAction.prepare(context, baseConfiguration);
154163
ParameterList baseParameters = baseConfiguration.getParameters();
155164
data.addActionParameters(baseParameters);
156165

166+
SpellAction compoundAction = new CompoundAction() {};
167+
InterrogatingConfiguration compoundConfiguration = new InterrogatingConfiguration(data.getParameterStore());
168+
compoundAction.initialize(spell, compoundConfiguration);
169+
compoundAction.prepare(context, compoundConfiguration);
170+
ParameterList compoundParameters = compoundConfiguration.getParameters();
171+
data.addCompoundActionParameters(compoundParameters);
172+
157173
for (Class<? extends SpellAction> actionClass : allClasses) {
158174
if (!actionClass.getPackage().getName().equals(BUILTIN_SPELL_PACKAGE)
159175
|| actionClass.getAnnotation(Deprecated.class) != null
@@ -170,6 +186,7 @@ private void generateActionMeta() {
170186

171187
ParameterList spellParameters = actionConfiguration.getParameters();
172188
spellParameters.removeDefaults(baseParameters);
189+
spellParameters.removeDefaults(compoundParameters);
173190
SpellActionDescription spellAction = new SpellActionDescription(actionClass, spellParameters);
174191
if (CompoundAction.class.isAssignableFrom(actionClass)) {
175192
spellAction.setCategory(getCategory("compound").getKey());

src/main/java/com/elmakers/mine/bukkit/meta/MetaData.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
package com.elmakers.mine.bukkit.meta;
22

3-
import java.util.ArrayList;
4-
import java.util.Collection;
5-
import java.util.Collections;
63
import java.util.HashMap;
7-
import java.util.List;
84
import java.util.Map;
9-
import java.util.Set;
105

116
import com.fasterxml.jackson.annotation.JsonIgnore;
127
import com.fasterxml.jackson.annotation.JsonProperty;
138

149
public class MetaData {
1510
private ParameterList mobParameters = new ParameterList();
11+
private ParameterList compoundActionParameters = new ParameterList();
1612
private ParameterList actionParameters = new ParameterList();
1713
private ParameterList spellParameters = new ParameterList();
1814
private ParameterList spellProperties = new ParameterList();
@@ -51,6 +47,15 @@ public void setActionParameters(ParameterList actionParameters) {
5147
this.actionParameters = actionParameters;
5248
}
5349

50+
@JsonProperty("compound_action_parameters")
51+
public ParameterList getCompoundActionParameters() {
52+
return compoundActionParameters;
53+
}
54+
55+
public void setCompoundActionParameters(ParameterList compoundActionParameters) {
56+
this.compoundActionParameters = compoundActionParameters;
57+
}
58+
5459
@JsonProperty("spell_properties")
5560
public ParameterList getSpellProperties() {
5661
return spellProperties;
@@ -166,6 +171,10 @@ public void addActionParameters(ParameterList parameters) {
166171
actionParameters.merge(parameters, parameterStore);
167172
}
168173

174+
public void addCompoundActionParameters(ParameterList parameters) {
175+
compoundActionParameters.merge(parameters, parameterStore);
176+
}
177+
169178
public void addSpellParameters(ParameterList parameters) {
170179
spellParameters.merge(parameters, parameterStore);
171180
}

src/web/common/meta.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
{
22
"action_parameters" : {
3-
"action_class" : null,
4-
"actions_map" : null,
53
"ignore_result" : "false",
64
"requires_entity_target" : "false",
7-
"requires_target" : "false",
8-
"stop_on_success" : "false"
5+
"requires_target" : "false"
96
},
107
"actions" : {
118
"absorb" : {
@@ -3259,6 +3256,13 @@
32593256
"name" : "Wand"
32603257
}
32613258
},
3259+
"compound_action_parameters" : {
3260+
"actions" : null,
3261+
"ignore_result" : "false",
3262+
"requires_entity_target" : "false",
3263+
"requires_target" : "false",
3264+
"stop_on_success" : "false"
3265+
},
32623266
"effect_parameters" : {
32633267
"color" : null,
32643268
"color2" : null,

0 commit comments

Comments
 (0)