Permalink
Browse files

Fixed a few bugs with the uploader

Now the API page works, but it doesn't have all the info in it yet.
  • Loading branch information...
LadyCailin committed Jul 27, 2017
1 parent ce32fcc commit 2f876e2d5df178070dd79a0c61c8a8569c6ea4d0
@@ -153,14 +153,14 @@ public Construct exec(Target t, Environment env, Construct... args) throws Cance
if (args[0] instanceof CArray) {
CArray ca = (CArray) args[0];
if (index instanceof CSlice) {
// Deep clone the array if the "index" is the initial one.
if (((CSlice) index).getStart() == 0 && ((CSlice) index).getFinish() == -1) {
return ca.deepClone(t);
} else if(ca.inAssociativeMode()) {
throw new CRECastException("Array slices are not allowed with an associative array", t);
}
//It's a range
long start = ((CSlice) index).getStart();
long finish = ((CSlice) index).getFinish();
@@ -432,7 +432,7 @@ public Boolean runAsync() {
+ "msg(@array);\n"
+ "@array[0] = 'value0';\n"
+ "msg(@array);"),
new ExampleScript("Demonstrates functional usage",
new ExampleScript("Demonstrates functional usage",
"array @array = array(null);\n"
+ "msg(@array);\n"
+ "array_set(@array, 0, 'value0');\n"
@@ -512,13 +512,13 @@ public Boolean runAsync() {
+ " operator is that this occurs on the Left Hand Side (LHS) of the assignment.",
"array @array = array();\n"
+ "@array[] = 'new value';"),
new ExampleScript("Demonstrates functional usage",
new ExampleScript("Demonstrates functional usage",
"array @array = array();\n"
+ "msg(@array);\n"
+ "array_push(@array, 0);\n"
+ "msg(@array);"),
new ExampleScript("Demonstrates pushing multiple values (note that it is not possible to use the bracket notation"
+ " and push multiple values)",
+ " and push multiple values)",
"array @array = array();\n"
+ "msg(@array);\n"
+ "array_push(@array, 0, 1, 2);\n"
@@ -961,12 +961,12 @@ public CArray exec(Target t, Environment env, Construct... args) throws ConfigRu
@Override
public ExampleScript[] examples() throws ConfigCompileException {
return new ExampleScript[]{
new ExampleScript("Demonstrates basic usage",
new ExampleScript("Demonstrates basic usage",
"array @array = array();\n"
+ "msg(@array);\n"
+ "array_resize(@array, 2);\n"
+ "msg(@array);"),
new ExampleScript("Demonstrates custom fill",
new ExampleScript("Demonstrates custom fill",
"array @array = array();\n"
+ "msg(@array);\n"
+ "array_resize(@array, 2, 'a');\n"
@@ -2441,7 +2441,7 @@ public Version since() {
}
}
@api
public static class array_shallow_clone extends AbstractFunction {
@@ -1,11 +1,6 @@
package com.laytonsmith.core.functions;
import com.laytonsmith.PureUtilities.Common.OSUtils;
import com.laytonsmith.PureUtilities.Common.ReflectionUtils;
import com.laytonsmith.PureUtilities.Common.StreamUtils;
import com.laytonsmith.abstraction.MCPlayer;
import com.laytonsmith.abstraction.MCServer;
import com.laytonsmith.commandhelper.CommandHelperPlugin;
import com.laytonsmith.core.AliasCore;
import com.laytonsmith.core.MethodScriptCompiler;
import com.laytonsmith.core.MethodScriptComplete;
@@ -14,23 +9,15 @@
import com.laytonsmith.core.Script;
import com.laytonsmith.core.Static;
import com.laytonsmith.core.constructs.Variable;
import com.laytonsmith.core.environments.CommandHelperEnvironment;
import com.laytonsmith.core.environments.Environment;
import com.laytonsmith.core.exceptions.CRE.AbstractCREException;
import com.laytonsmith.core.exceptions.ConfigCompileException;
import com.laytonsmith.core.exceptions.ConfigCompileGroupException;
import com.laytonsmith.core.exceptions.ConfigRuntimeException;
import com.laytonsmith.persistence.DataSourceException;
import org.bukkit.Server;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.URISyntaxException;
import java.util.ArrayList;
@@ -52,9 +39,6 @@
String output;
StringBuilder playerOutput = null;
MCPlayer fakePlayer;
static MCServer fakeServer;
static Plugin fakePlugin;
static AliasCore fakeCore;
static boolean init = false;
@@ -93,7 +77,7 @@ public ExampleScript(String description, String script, String output) throws Co
* @param script
* @param output
* @param intentionalCompileError
* @throws ConfigCompileException
* @throws ConfigCompileException
*/
private ExampleScript(String description, String script, String output, boolean intentionalCompileError) throws ConfigCompileException{
this.description = description;
@@ -117,68 +101,6 @@ private ExampleScript(String description, String script, String output, boolean
}
playerOutput = new StringBuilder();
fakePlayer = (MCPlayer)Proxy.newProxyInstance(ExampleScript.class.getClassLoader(), new Class[]{MCPlayer.class}, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if(method.getName().equals("getName") || method.getName().equals("getDisplayName")){
return "Player";
}
if(method.getName().equals("getServer")){
return fakeServer;
}
if(method.getName().equals("sendMessage")){
playerOutput.append(args[0].toString()).append("\n");
}
if(method.getName().equals("isOnline")){
return true;
}
return genericReturn(method.getReturnType());
}
});
if(!init){
init = true;
fakeServer = (MCServer)Proxy.newProxyInstance(ExampleScript.class.getClassLoader(), new Class[]{MCServer.class}, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return genericReturn(method.getReturnType());
}
});
final PluginManager bukkitPluginManager = (PluginManager)Proxy.newProxyInstance(ExampleScript.class.getClassLoader(), new Class[]{PluginManager.class}, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
StreamUtils.GetSystemOut().println(method.getReturnType().getSimpleName() + " " + method.getName());
return genericReturn(method.getReturnType());
}
});
final Server bukkitServer = (Server)Proxy.newProxyInstance(ExampleScript.class.getClassLoader(), new Class[]{Server.class}, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
StreamUtils.GetSystemOut().println(method.getReturnType().getSimpleName() + " " + method.getName());
if(method.getName().equals("getPluginManager")){
return bukkitPluginManager;
}
return genericReturn(method.getReturnType());
}
});
fakePlugin = (Plugin)Proxy.newProxyInstance(ExampleScript.class.getClassLoader(), new Class[]{Plugin.class}, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
StreamUtils.GetSystemOut().println(method.getReturnType().getSimpleName() + " " + method.getName());
if(method.getName().equals("getServer")){
return bukkitServer;
}
return genericReturn(method.getReturnType());
}
});
fakeCore = new FakeCore();
ReflectionUtils.set(CommandHelperPlugin.class, "ac", fakeCore);
}
}
public String getDescription() {
@@ -238,7 +160,6 @@ public String getOutput() throws IOException, DataSourceException, URISyntaxExce
} catch (Profiles.InvalidProfileException ex) {
throw new RuntimeException(ex);
}
env.getEnv(CommandHelperEnvironment.class).SetPlayer(fakePlayer);
final StringBuilder finalOutput = new StringBuilder();
String thrown = null;
try{
Oops, something went wrong.

0 comments on commit 2f876e2

Please sign in to comment.