* BUG: Map items show correctly their position if they are part of a multiple-map poster.

This commit is contained in:
Prokopyl 2015-02-18 15:27:07 +01:00
parent aa7aa32592
commit bdf35e9eef
3 changed files with 21 additions and 4 deletions

View File

@ -99,6 +99,16 @@ public class PosterImage
return cutImages[x * columns + y];
}
public int getColumnAt(int i)
{
return i % columns;
}
public int getLineAt(int i)
{
return i / columns;
}
/**
*
* @return the number of lines of the poster

View File

@ -68,12 +68,17 @@ public abstract class ImageMap
protected void give(Inventory inventory, short mapID)
{
give(inventory, mapID, getImageName());
}
protected void give(Inventory inventory, short mapID, String itemName)
{
ItemStack itemMap = new ItemStack(Material.MAP, 1, mapID);
if(isNamed())
if(itemName != null)
{
ItemMeta meta = itemMap.getItemMeta();
meta.setDisplayName(imageName);
meta.setDisplayName(itemName);
itemMap.setItemMeta(meta);
}
inventory.addItem(itemMap);

View File

@ -96,9 +96,11 @@ public class PosterMap extends ImageMap
@Override
public void give(Inventory inv)
{
for(short mapID : mapsIDs)
String itemName;
for(int i = 0; i < mapsIDs.length; i++)
{
give(inv, mapID);
itemName = "Map (row " + (image.getLineAt(i) + 1) + ", column " + (image.getColumnAt(i) + 1) + ")";
give(inv, mapsIDs[i], itemName);
}
}