Skip to content

Commit e299493

Browse files
committed
Merge pull request #375 from PseudoKnight/fixes
Fixes
2 parents b80351d + b303261 commit e299493

File tree

3 files changed

+19
-25
lines changed

3 files changed

+19
-25
lines changed

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

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -871,29 +871,26 @@ public Vector3D vector(Vector3D v, Construct c, Target t) {
871871
x = Static.getNumber(va.get(0, t), t);
872872
y = Static.getNumber(va.get(1, t), t);
873873
z = Static.getNumber(va.get(2, t), t);
874-
} else
875-
if(va.size() == 2) { // 2nd dimension vector
874+
} else if(va.size() == 2){ // 2nd dimension vector
876875
x = Static.getNumber(va.get(0, t), t);
877876
y = Static.getNumber(va.get(1, t), t);
878-
z = 0;
879-
} else {
880-
throw new ConfigRuntimeException("Expecting a Vector array, but the array did not meet the format specifications", ExceptionType.FormatException, t);
877+
} else if(va.size() == 1){
878+
x = Static.getNumber(va.get(0, t), t);
879+
}
880+
} else {
881+
if(va.containsKey("x")){
882+
x = Static.getNumber(va.get("x", t), t);
883+
}
884+
if(va.containsKey("y")){
885+
y = Static.getNumber(va.get("y", t), t);
886+
}
887+
if(va.containsKey("z")){
888+
z = Static.getNumber(va.get("z", t), t);
881889
}
882-
}
883-
884-
if(va.containsKey("x")) {
885-
x = Static.getNumber(va.get("x", t), t);
886-
}
887-
if(va.containsKey("y")) {
888-
y = Static.getNumber(va.get("y", t), t);
889-
}
890-
if(va.containsKey("z")) {
891-
z = Static.getNumber(va.get("z", t), t);
892890
}
893891

894892
return new Vector3D(x, y, z);
895-
} else
896-
if(c instanceof CNull) {
893+
} else if(c instanceof CNull) {
897894
// fulfilling the todo?
898895
return v;
899896
} else {

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,18 +1275,12 @@ public static void AssertNonNull(Object var, String message) throws NullPointerE
12751275
* @throws URISyntaxException
12761276
*/
12771277
public static Environment GenerateStandaloneEnvironment() throws IOException, DataSourceException, URISyntaxException, Profiles.InvalidProfileException {
1278-
File jarLocation;
1279-
if (Static.class.getProtectionDomain().getCodeSource().getLocation() != null) {
1280-
jarLocation = new File(Static.class.getProtectionDomain().getCodeSource().getLocation().getFile()).getParentFile();
1281-
} else {
1282-
jarLocation = new File(".");
1283-
}
1284-
File platformFolder = new File(jarLocation, Implementation.GetServerType().getBranding() + "/");
1278+
File platformFolder = MethodScriptFileLocations.getDefault().getConfigDirectory();
12851279
Installer.Install(platformFolder);
12861280
ConnectionMixinFactory.ConnectionMixinOptions options = new ConnectionMixinFactory.ConnectionMixinOptions();
12871281
options.setWorkingDirectory(platformFolder);
12881282
PersistenceNetwork persistenceNetwork = new PersistenceNetwork(MethodScriptFileLocations.getDefault().getPersistenceConfig(),
1289-
new URI("sqlite://" + new File(platformFolder, "persistence.db").getCanonicalPath().replace("\\", "/")), options);
1283+
new URI("sqlite://" + new File(platformFolder, "persistence.db").getCanonicalPath().replace('\\', '/')), options);
12901284
GlobalEnv gEnv = new GlobalEnv(new MethodScriptExecutionQueue("MethodScriptExecutionQueue", "default"),
12911285
new Profiler(MethodScriptFileLocations.getDefault().getProfilerConfigFile()), persistenceNetwork, platformFolder,
12921286
new Profiles(MethodScriptFileLocations.getDefault().getProfilesFile()), new TaskManager());

src/main/java/com/laytonsmith/core/functions/ArrayHandling.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,6 +1399,9 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
13991399
CArray ca = (CArray) args[0];
14001400
CArray.SortType sortType = CArray.SortType.REGULAR;
14011401
CClosure customSort = null;
1402+
if(ca.size() <= 1){
1403+
return ca;
1404+
}
14021405
try {
14031406
if (args.length == 2) {
14041407
if(args[1] instanceof CClosure){

0 commit comments

Comments
 (0)