MIInventory inventory = MIYamlFiles.con.getInventory(giveplayer, MIPlayerListener.getGroup(world), inventoryName);
// now let's find an empty slot...
boolean noempty = true;
MIItemStack[] items = inventory.getInventoryContents();
for(int i = 0; i < items.length && noempty; i++) {
MIItemStack is = items[i];
if(is.getItemStack() == null) {
items[i] = itemstack;
noempty = false;
}
}
if(noempty) {
return false;
}
MIYamlFiles.con.saveInventory(giveplayer, MIPlayerListener.getGroup(world), inventory, inventoryName);
return true;
} else {
MIPlayerFile config = new MIPlayerFile(giveplayer, MIPlayerListener.getGroup(world));
MIInventory inventory = config.getInventory(inventoryName);
// now let's find an empty slot...
boolean noempty = true;
MIItemStack[] items = inventory.getInventoryContents();
for(int i = 0; i < items.length && noempty; i++) {
MIItemStack is = items[i];
if(is.getItemStack() == null) {
items[i] = itemstack;
noempty = false;
}
}
if(noempty) {
return false;
}
config.saveInventory(inventory, inventoryName);
return true;
}
// If they are currently using the inventory, let's set it...
} else {
if(giveplayer.getInventory().firstEmpty() == -1) {
return false;
}
giveplayer.getInventory().addItem(itemstack.getItemStack());
if(offlineplayer) {
giveplayer.saveData();
}
return true;
}
// They aren't in the same world, so let's just save the inventory.
} else {
String inventoryName = "CREATIVE";
if(GameMode.SURVIVAL == gm) {
inventoryName = "SURVIVAL";
}
if(!MIYamlFiles.config.getBoolean("separateGamemodeInventories", true)) {
inventoryName = "SURVIVAL";
}
if(MIYamlFiles.config.getBoolean("useSQL")) {
MIInventory inventory = MIYamlFiles.con.getInventory(giveplayer, MIPlayerListener.getGroup(world), inventoryName);
// now let's find an empty slot...
boolean noempty = true;
MIItemStack[] items = inventory.getInventoryContents();
for(int i = 0; i < items.length && noempty; i++) {
MIItemStack is = items[i];
if(is.getItemStack() == null) {
items[i] = itemstack;
noempty = false;
}
}
if(noempty) {
return false;
}
MIYamlFiles.con.saveInventory(giveplayer, MIPlayerListener.getGroup(world), inventory, inventoryName);
return true;
} else {
MIPlayerFile config = new MIPlayerFile(giveplayer, MIPlayerListener.getGroup(world));
MIInventory inventory = config.getInventory(inventoryName);
// now let's find an empty slot...
boolean noempty = true;
MIItemStack[] items = inventory.getInventoryContents();
for(int i = 0; i < items.length && noempty; i++) {
MIItemStack is = items[i];
if(is.getItemStack() == null) {
items[i] = itemstack;
noempty = false;
}
}
if(noempty) {