0.3h Fix userOrder

This commit is contained in:
BuildTools 2016-03-17 21:52:37 +01:00 committed by Olof Larsson
parent dc89b439a0
commit 7b69175c0f
2 changed files with 19 additions and 3 deletions

View File

@ -87,7 +87,14 @@ public abstract class TypeAbstract<T> implements Type<T>
private List<Integer> userOrder = null; private List<Integer> userOrder = null;
@Override public void setUserOrder(List<Integer> userOrder) { this.userOrder = userOrder; } @Override public void setUserOrder(List<Integer> userOrder) { this.userOrder = userOrder; }
@Override public void setUserOrder(Integer... userOrder) { this.setUserOrder(Arrays.asList(userOrder)); } @Override public void setUserOrder(Integer... userOrder) { this.setUserOrder(Arrays.asList(userOrder)); }
@Override public List<Integer> getUserOrder() { return this.userOrder; } @Override public List<Integer> getUserOrder()
{
if (this.userOrder == null)
{
this.userOrder = MUtil.range(0, this.getInnerTypes().size());
}
return this.userOrder;
}
@Override @Override
public Integer getIndexUser(int indexTechy) public Integer getIndexUser(int indexTechy)
{ {

View File

@ -17,12 +17,12 @@ import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.regex.Pattern;
import java.util.Set; import java.util.Set;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.UUID;
import java.util.regex.Pattern;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -554,6 +554,15 @@ public class MUtil
} }
return ret; return ret;
} }
public static List<Integer> range(int from, int to)
{
List<Integer> ret = new MassiveList<>(to - from);
for (int i = from; i < to; i++)
{
ret.add(i);
}
return ret;
}
public static void keepLeft(List<?> list, int maxlength) public static void keepLeft(List<?> list, int maxlength)
{ {