No one cares about ComplexItemLayout
This commit is contained in:
parent
9ddd0bd9cc
commit
89892097d0
@ -1,113 +0,0 @@
|
||||
package mineplex.core.itemstack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ComplexItemLayout
|
||||
{
|
||||
|
||||
private int _invSize = 0;
|
||||
private HashMap<Character, ArrayList<Integer>> placing = new HashMap<Character, ArrayList<Integer>>();
|
||||
|
||||
public ComplexItemLayout(String... strings)
|
||||
{
|
||||
_invSize = strings.length * 9;
|
||||
for (int row = 0; row < strings.length; row++)
|
||||
{
|
||||
final String string = strings[row];
|
||||
char[] cArray = string.toCharArray();
|
||||
int entries = 0;
|
||||
for (int i = 0; i < cArray.length; i++)
|
||||
{
|
||||
entries++;
|
||||
if (cArray[i] == '(')
|
||||
{
|
||||
for (; i < cArray.length; i++)
|
||||
{
|
||||
if (cArray[i] == ')')
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!placing.containsKey(cArray[i]))
|
||||
{
|
||||
placing.put(cArray[i], new ArrayList<Integer>());
|
||||
}
|
||||
placing.get(cArray[i]).add((row * 9) + i);
|
||||
}
|
||||
if (i + 1 >= cArray.length)
|
||||
{
|
||||
throw new IllegalArgumentException("String '" + string + "' does not have a enclosing ) after the (");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!placing.containsKey(cArray[i]))
|
||||
{
|
||||
placing.put(cArray[i], new ArrayList<Integer>());
|
||||
}
|
||||
placing.get(cArray[i]).add((row * 9) + i);
|
||||
}
|
||||
}
|
||||
if (entries != 9)
|
||||
throw new IllegalArgumentException("String '" + string + "' does not 9 entries but instead has " + entries
|
||||
+ " entries");
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack[] generate(char toReplace, ArrayList<ItemStack> items, boolean replaceExistingItems)
|
||||
{
|
||||
return generate(toReplace, items.toArray(new ItemStack[0]), replaceExistingItems);
|
||||
}
|
||||
|
||||
public ItemStack[] generate(ItemStack[] existingItems, char toReplace, ItemStack[] items, boolean replaceExistingItems)
|
||||
{
|
||||
ArrayList<Integer> list = placing.get(toReplace);
|
||||
for (int i = 0; i < list.size(); i++)
|
||||
{
|
||||
if (i < items.length && i < existingItems.length)
|
||||
{
|
||||
ItemStack item = existingItems[list.get(i)];
|
||||
if (replaceExistingItems || item == null || item.getType() == Material.AIR)
|
||||
{
|
||||
existingItems[list.get(i)] = items[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return existingItems;
|
||||
}
|
||||
|
||||
public ItemStack[] generate(char toReplace, ItemStack[] items, boolean replaceExistingItems)
|
||||
{
|
||||
return generate(new ItemStack[this._invSize], toReplace, items, replaceExistingItems);
|
||||
}
|
||||
|
||||
public ItemStack[] generate(ItemStack[] existingItems, char toReplace, ItemStack item, boolean replaceExistingItems)
|
||||
{
|
||||
ArrayList<Integer> list = placing.get(toReplace);
|
||||
for (int i = 0; i < list.size(); i++)
|
||||
{
|
||||
if (i < existingItems.length)
|
||||
{
|
||||
ItemStack checkItem = existingItems[list.get(i)];
|
||||
if (replaceExistingItems || checkItem == null || checkItem.getType() == Material.AIR)
|
||||
{
|
||||
existingItems[list.get(i)] = item;
|
||||
}
|
||||
}
|
||||
}
|
||||
return existingItems;
|
||||
}
|
||||
|
||||
public ItemStack[] generate(char toReplace, ItemStack item, boolean replaceExistingItems)
|
||||
{
|
||||
return generate(new ItemStack[this._invSize], toReplace, item, replaceExistingItems);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user