Skip to content

Commit

Permalink
Requested Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
UnderscoreTud committed Oct 7, 2023
1 parent a7cbe77 commit 8d42e50
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/main/java/ch/njol/skript/effects/EffCopy.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@

import ch.njol.skript.Skript;
import ch.njol.skript.classes.Changer.ChangeMode;
import ch.njol.skript.doc.*;
import ch.njol.skript.doc.Description;
import ch.njol.skript.doc.Examples;
import ch.njol.skript.doc.Keywords;
import ch.njol.skript.doc.Name;
import ch.njol.skript.doc.Since;
import ch.njol.skript.lang.Effect;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;
Expand All @@ -34,7 +38,10 @@
import java.util.Map;

@Name("Copy")
@Description("Copies objects into a variable. When copying a list over to another list, the source list and its sublists are also copied over.")
@Description({
"Copies objects into a variable. When copying a list over to another list, the source list and its sublists are also copied over.",
"<strong>Note: Copying a value into a variable/list will overwrite the existing data.</strong>"
})
@Examples({
"set {_foo::bar} to 1",
"set {_foo::sublist::foobar} to \"hey\"",
Expand All @@ -44,7 +51,7 @@
"broadcast {_copy::sublist::foobar} # \"hey!\""
})
@Since("INSERT VERSION")
@Keywords({"copy", "clone"})
@Keywords({"clone", "variable", "list"})
public class EffCopy extends Effect {

static {
Expand Down Expand Up @@ -85,7 +92,8 @@ protected void execute(Event event) {
if (source == null)
return;
String target = destination.getName().getSingle(event);
copy(event, source, target.substring(0, target.length() - 3), destination.isLocal());
target = target.substring(0, target.length() - (Variable.SEPARATOR + "*").length()); // Strip the '::*' part from the name
copy(event, source, target, destination.isLocal());
}

@Override
Expand All @@ -104,7 +112,7 @@ private static void copy(Event event, Map<String, Object> source, String targetN
copy(event, (Map<String, Object>) value, node, local);
return;
}
Variables.setVariable(node, value, event, local);
Variables.setVariable(node, Classes.clone(value), event, local);
}
}

Expand Down

0 comments on commit 8d42e50

Please sign in to comment.