Skip to content

Commit 4f9014f

Browse files
committed
Merge branch 'master' into genericsTake2
2 parents 662d792 + 760d39c commit 4f9014f

19 files changed

Lines changed: 114 additions & 467 deletions

pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,8 @@
496496
<arg>-XDignore.symbol.file</arg>
497497
<arg>-parameters</arg>
498498
<arg>-proc:none</arg>
499+
<arg>-Xmaxwarns</arg>
500+
<arg>9999</arg>
499501
</compilerArgs>
500502
</configuration>
501503
</plugin>

src/main/java/com/laytonsmith/core/ArgumentValidation.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,13 @@ public static CByteArray getByteArray(Mixed c, Target t, Environment env) {
552552
}
553553
}
554554

555+
/** @deprecated Use {@link #getClassType(Mixed, Target, Environment)} instead. */
556+
@Deprecated
557+
@AggressiveDeprecation(deprecationDate = "2022-04-06", removalVersion = "3.3.7", deprecationVersion = "3.3.6")
558+
public static LeftHandSideType getClassType(Mixed c, Target t) {
559+
return getClassType(c, t, null);
560+
}
561+
555562
/**
556563
* Returns the LeftHandSideType from the given Construct. This accepts either a LeftHandSideType directly, or a
557564
* CClassType, which is converted to a LeftHandSideType.

src/main/java/com/laytonsmith/core/ObjectGenerator.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ public CArray location(MCLocation l, boolean includeYawAndPitch, Environment env
199199
}
200200

201201
@AggressiveDeprecation(deprecationDate = "2022-04-06", removalVersion = "3.3.7", deprecationVersion = "3.3.6")
202+
/** @deprecated Use {@link #location(Mixed, MCWorld, Target, Environment)} instead. */
202203
@Deprecated
203204
public MCLocation location(Mixed c, MCWorld w, Target t) {
204205
return location(c, w, t, null);
@@ -2150,6 +2151,7 @@ public Vector3D vector(Mixed c, Target t, Environment env) {
21502151
return vector(Vector3D.ZERO, c, t, env);
21512152
}
21522153

2154+
/** @deprecated Use {@link #vector(Vector3D, Mixed, Target, Environment)} instead. */
21532155
@AggressiveDeprecation(deprecationDate = "2022-04-06", removalVersion = "3.3.7", deprecationVersion = "3.3.6")
21542156
@Deprecated
21552157
public Vector3D vector(Vector3D v, Mixed c, Target t) {
@@ -2614,6 +2616,7 @@ public CArray fireworkEffect(MCFireworkEffect mcfe, Target t, Environment env) {
26142616
}
26152617

26162618
@AggressiveDeprecation(deprecationDate = "2022-04-06", removalVersion = "3.3.7", deprecationVersion = "3.3.6")
2619+
/** @deprecated Use {@link #fireworkEffect(CArray, Target, Environment)} instead. */
26172620
@Deprecated
26182621
public MCFireworkEffect fireworkEffect(CArray fe, Target t) {
26192622
return fireworkEffect(fe, t, null);
@@ -2777,6 +2780,7 @@ public Construct recipe(MCRecipe r, Target t, Environment env) {
27772780
return ret;
27782781
}
27792782

2783+
/** @deprecated Use {@link #recipe(Mixed, Target, Environment)} instead. */
27802784
@AggressiveDeprecation(deprecationDate = "2022-04-06", removalVersion = "3.3.7", deprecationVersion = "3.3.6")
27812785
@Deprecated
27822786
public MCRecipe recipe(Mixed c, Target t) {

src/main/java/com/laytonsmith/core/Static.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1565,6 +1565,12 @@ public static boolean InCmdLine(Environment environment, boolean defaultValue) {
15651565
return environment.getEnv(GlobalEnv.class).inCmdlineMode();
15661566
}
15671567

1568+
/** @deprecated Use {@link #AssertType(Class, Mixed[], int, Function, Target, Environment)} instead. */
1569+
@Deprecated
1570+
public static <T extends Mixed> T AssertType(Class<T> type, Mixed[] args, int argNumber, Function func, Target t) {
1571+
return AssertType(type, args, argNumber, func, t, null);
1572+
}
1573+
15681574
/**
15691575
* This verifies that the type required is actually present, and returns the value, cast to the appropriate type,
15701576
* or, if not the correct type, a CRE.
@@ -1577,7 +1583,8 @@ public static boolean InCmdLine(Environment environment, boolean defaultValue) {
15771583
* @param args The array of arguments.
15781584
* @param argNumber The argument number, used both for grabbing the correct argument from args, and building the
15791585
* error message if the cast cannot occur.
1580-
* @param func The function, in case this errors out, to build the error message.
1586+
* @param func The function, in case this errors out,
1587+
* @param envto build the error message.
15811588
* @param t The code target
15821589
* @param env The environment.
15831590
* @return The value, cast to the desired type.

src/main/java/com/laytonsmith/core/constructs/InstanceofUtil.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ public static boolean isInstanceof(Mixed value, CClassType instanceofThis, Envir
124124
// "None" type, which is not instanceof anything, nor is anything instanceof it
125125
return false;
126126
}
127+
if(value instanceof CFunction) {
128+
// TODO: Need to put the return type here, so we can work with this, but for now, just always return false
129+
return false;
130+
}
127131
return isInstanceof(value, instanceofThis.asLeftHandSideType(), env);
128132
}
129133

src/main/java/com/laytonsmith/core/events/AbstractGenericEvent.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.laytonsmith.core.events.prefilters.Prefilter;
2424
import com.laytonsmith.core.events.prefilters.PrefilterBuilder;
2525
import com.laytonsmith.core.exceptions.CRE.CREFormatException;
26+
import com.laytonsmith.core.exceptions.CRE.CREUnsupportedOperationException;
2627
import com.laytonsmith.core.exceptions.CancelCommandException;
2728
import com.laytonsmith.core.exceptions.ConfigCompileException;
2829
import com.laytonsmith.core.exceptions.ConfigCompileGroupException;
@@ -59,8 +60,8 @@ public final void setAbstractEventMixin(EventMixinInterface mixin) {
5960
}
6061

6162
/**
62-
* This function should return true if the event code should be run, based on implementation specific conditions
63-
* for the BindableEvent.
63+
* This function should return true if the event code should be run, based on implementation specific conditions for
64+
* the BindableEvent.
6465
*
6566
* @param e The bindable event itself
6667
* @return {@code true} if the event code should be run
@@ -152,13 +153,13 @@ public final void execute(ParseTree tree, BoundEvent b, Environment env, BoundEv
152153
try {
153154
try {
154155
MethodScriptCompiler.execute(tree, env, null, null);
155-
} catch (CancelCommandException ex) {
156+
} catch(CancelCommandException ex) {
156157
if(ex.getMessage() != null && !ex.getMessage().isEmpty()) {
157158
StreamUtils.GetSystemOut().println(ex.getMessage());
158159
}
159-
} catch (FunctionReturnException ex) {
160+
} catch(FunctionReturnException ex) {
160161
//We simply allow this to end the event execution
161-
} catch (ProgramFlowManipulationException ex) {
162+
} catch(ProgramFlowManipulationException ex) {
162163
ConfigRuntimeException.HandleUncaughtException(new CREFormatException("Unexpected control flow operation used.", ex.getTarget()), env);
163164
}
164165
} finally {
@@ -325,9 +326,10 @@ public final Map<String, Prefilter<? extends TBindableEvent>> getPrefilters() {
325326
}
326327

327328
/**
328-
* Returns the prefilter builder for this subclass. This is built by AbstractEvent and cached, so that calls
329-
* to getPrefilters will be faster for future calls. Subclasses should implement this in order to provide
330-
* declarative prefilter support, which is more efficient and provides more features to end users.
329+
* Returns the prefilter builder for this subclass. This is built by AbstractEvent and cached, so that calls to
330+
* getPrefilters will be faster for future calls. Subclasses should implement this in order to provide declarative
331+
* prefilter support, which is more efficient and provides more features to end users.
332+
*
331333
* @return
332334
*/
333335
// TODO: Once everything has this, this should be re-added, since everything should have its own version.
@@ -338,15 +340,19 @@ protected PrefilterBuilder getPrefilterBuilder() {
338340

339341
/**
340342
* By default, we do nothing.
343+
*
341344
* @param prefilters
342345
* @param env
343346
*/
344347
@Override
345348
public void validatePrefilters(Map<Prefilter<TBindableEvent>, ParseTree> prefilters, Environment env)
346-
throws ConfigCompileException, ConfigCompileGroupException {
349+
throws ConfigCompileException, ConfigCompileGroupException {
347350
//
348351
}
349352

350-
351-
353+
@Override
354+
public TBindableEvent convert(CArray manualObject, Target t, Environment env) {
355+
throw new CREUnsupportedOperationException("Manual triggering of the "
356+
+ getName() + " event is not supported.", t);
357+
}
352358
}

src/main/java/com/laytonsmith/core/events/EventUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public static void ManualTrigger(String eventName, CArray object, Target t, bool
154154
if(b.getEventName().equalsIgnoreCase(eventName)) {
155155
BindableEvent convertedEvent = null;
156156
try {
157-
convertedEvent = driver.convert(object, t, b.getEnvironment());
157+
convertedEvent = driver.convert(object, t, env);
158158
} catch (UnsupportedOperationException ex) {
159159
// The event will stay null, and be caught below
160160
}

src/main/java/com/laytonsmith/core/events/drivers/BlockEvents.java

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ public boolean matches(Map<String, Mixed> prefilter, BindableEvent e, Environmen
6969
return true;
7070
}
7171

72-
@Override
73-
public BindableEvent convert(CArray manualObject, Target t, Environment env) {
74-
return null;
75-
}
76-
7772
@Override
7873
public boolean modifyEvent(String key, Mixed value, BindableEvent e, Environment env) {
7974
return false;
@@ -253,11 +248,6 @@ public boolean matches(Map<String, Mixed> prefilter, BindableEvent e, Environmen
253248
return true;
254249
}
255250

256-
@Override
257-
public BindableEvent convert(CArray manualObject, Target t, Environment env) {
258-
return null;
259-
}
260-
261251
@Override
262252
public Map<String, Mixed> evaluate(BindableEvent e, Environment env) throws EventException {
263253
MCBlockBreakEvent event = (MCBlockBreakEvent) e;
@@ -271,7 +261,7 @@ public Map<String, Mixed> evaluate(BindableEvent e, Environment env) throws Even
271261

272262
CArray drops = new CArray(t, null, env);
273263
for(MCItemStack stack : event.getDrops()) {
274-
drops.push(ObjectGenerator.GetGenerator().item(stack, t), t);
264+
drops.push(ObjectGenerator.GetGenerator().item(stack, t, env), t);
275265
}
276266
map.put("drops", drops);
277267

@@ -398,11 +388,6 @@ public boolean matches(Map<String, Mixed> prefilter, BindableEvent e, Environmen
398388
return true;
399389
}
400390

401-
@Override
402-
public BindableEvent convert(CArray manualObject, Target t, Environment env) {
403-
return null;
404-
}
405-
406391
@Override
407392
public Map<String, Mixed> evaluate(BindableEvent e, Environment env) throws EventException {
408393
MCBlockPlaceEvent event = (MCBlockPlaceEvent) e;
@@ -548,11 +533,6 @@ public boolean matches(Map<String, Mixed> prefilter, BindableEvent e, Environmen
548533
return true;
549534
}
550535

551-
@Override
552-
public BindableEvent convert(CArray manualObject, Target t, Environment env) {
553-
return null;
554-
}
555-
556536
@Override
557537
public Map<String, Mixed> evaluate(BindableEvent e, Environment env) throws EventException {
558538
MCBlockBurnEvent event = (MCBlockBurnEvent) e;
@@ -627,10 +607,6 @@ public boolean matches(Map<String, Mixed> prefilter, BindableEvent e, Environmen
627607
return true;
628608
}
629609

630-
@Override
631-
public BindableEvent convert(CArray manualObject, Target t, Environment env) {
632-
return null;
633-
}
634610

635611
@Override
636612
public Map<String, Mixed> evaluate(BindableEvent e, Environment env) throws EventException {
@@ -772,11 +748,6 @@ public boolean matches(Map<String, Mixed> prefilter, BindableEvent e, Environmen
772748
return true;
773749
}
774750

775-
@Override
776-
public BindableEvent convert(CArray manualObject, Target t, Environment env) {
777-
return null;
778-
}
779-
780751
@Override
781752
public Map<String, Mixed> evaluate(BindableEvent e, Environment env) throws EventException {
782753
if(!(e instanceof MCBlockFromToEvent)) {
@@ -1110,11 +1081,6 @@ public boolean matches(Map<String, Mixed> prefilter, BindableEvent e, Environmen
11101081
return false;
11111082
}
11121083

1113-
@Override
1114-
public BindableEvent convert(CArray manualObject, Target t, Environment env) {
1115-
return null;
1116-
}
1117-
11181084
@Override
11191085
public Map<String, Mixed> evaluate(BindableEvent e, Environment env) throws EventException {
11201086
MCBlockDispenseEvent event = (MCBlockDispenseEvent) e;
@@ -1257,11 +1223,6 @@ public boolean matches(Map<String, Mixed> prefilter, BindableEvent event, Enviro
12571223
return true;
12581224
}
12591225

1260-
@Override
1261-
public BindableEvent convert(CArray manualObject, Target t, Environment env) {
1262-
return null;
1263-
}
1264-
12651226
@Override
12661227
public Map<String, Mixed> evaluate(BindableEvent event, Environment env) throws EventException {
12671228
if(!(event instanceof MCBlockGrowEvent)) {
@@ -1317,11 +1278,6 @@ public boolean matches(Map<String, Mixed> prefilter, BindableEvent event, Enviro
13171278
return event instanceof MCNotePlayEvent;
13181279
}
13191280

1320-
@Override
1321-
public BindableEvent convert(CArray manualObject, Target t, Environment env) {
1322-
return null;
1323-
}
1324-
13251281
@Override
13261282
public Map<String, Mixed> evaluate(BindableEvent event, Environment env) throws EventException {
13271283
if(!(event instanceof MCNotePlayEvent)) {
@@ -1420,11 +1376,6 @@ public boolean matches(Map<String, Mixed> prefilter, BindableEvent e, Environmen
14201376
return true;
14211377
}
14221378

1423-
@Override
1424-
public BindableEvent convert(CArray manualObject, Target t, Environment env) {
1425-
return null;
1426-
}
1427-
14281379
@Override
14291380
public Map<String, Mixed> evaluate(BindableEvent e, Environment env) throws EventException {
14301381
if(!(e instanceof MCBlockFadeEvent)) {
@@ -1481,11 +1432,6 @@ public boolean matches(Map<String, Mixed> prefilter, BindableEvent e, Environmen
14811432
return e instanceof MCBlockExplodeEvent;
14821433
}
14831434

1484-
@Override
1485-
public BindableEvent convert(CArray manualObject, Target t, Environment env) {
1486-
return null;
1487-
}
1488-
14891435
@Override
14901436
public Map<String, Mixed> evaluate(BindableEvent e, Environment env) throws EventException {
14911437
if(!(e instanceof MCBlockExplodeEvent)) {
@@ -1556,11 +1502,6 @@ public Driver driver() {
15561502
return Driver.BLOCK_FORM;
15571503
}
15581504

1559-
@Override
1560-
public BindableEvent convert(CArray manualObject, Target t, Environment env) {
1561-
return null;
1562-
}
1563-
15641505
@Override
15651506
public Version since() {
15661507
return MSVersion.V3_3_4;

src/main/java/com/laytonsmith/core/events/drivers/CmdlineEvents.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ protected PrefilterBuilder getPrefilterBuilder() {
166166

167167
@Override
168168
public BindableEvent convert(CArray manualObject, Target t, Environment env) {
169-
CmdlinePromptInput cpi = new CmdlinePromptInput(manualObject.get("command", t).val(),
170-
ArgumentValidation.getBoolean(manualObject.get("shellMode", t), t, env));
169+
CmdlinePromptInput cpi = new CmdlinePromptInput(manualObject.get("command", t, env).val(),
170+
ArgumentValidation.getBooleanObject(manualObject.get("shellMode", t, env), t, env));
171171
return cpi;
172172
}
173173

@@ -262,11 +262,6 @@ public boolean matches(Map<String, Mixed> prefilter, BindableEvent e, Environmen
262262
return true;
263263
}
264264

265-
@Override
266-
public BindableEvent convert(CArray manualObject, Target t, Environment env) {
267-
throw new UnsupportedOperationException("Not supported yet.");
268-
}
269-
270265
@Override
271266
public Map<String, Mixed> evaluate(BindableEvent e, Environment env) throws EventException {
272267
return Collections.EMPTY_MAP;

0 commit comments

Comments
 (0)