lists and maps copy by reference. use copy to get a copy.
This commit is contained in:
1 parent
848f95cd30
commit
24c1ee8d3d
3 files changed
+10
-5
No files matched your search
@@ -58,6 +58,11 @@ public class ListValue extends AbstractListValue implements ContainerValueInterf
|
||||
items.addAll(list);
|
||||
}
|
||||
|
||||
private ListValue(List<Value> list)
|
||||
{
|
||||
items = list;
|
||||
}
|
||||
|
||||
public static Value fromItemStack(ItemStack itemstack)
|
||||
{
|
||||
if (itemstack == null || itemstack.isEmpty())
|
||||
@@ -307,7 +312,7 @@ public class ListValue extends AbstractListValue implements ContainerValueInterf
|
||||
if (from < 0 || from > size) from = size;
|
||||
if (from > to)
|
||||
return ListValue.of();
|
||||
return new ListValue(getItems().subList((int)from, (int) to));
|
||||
return new ListValue((Collection<? extends Value>) getItems().subList((int)from, (int) to));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -72,9 +72,9 @@ public class MapValue extends AbstractListValue implements ContainerValueInterfa
|
||||
return new MapValue(copyMap);
|
||||
}
|
||||
|
||||
public MapValue(Map<Value,Value> other)
|
||||
private MapValue(Map<Value,Value> other)
|
||||
{
|
||||
map = new HashMap<>(other);
|
||||
map = other;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user