mirror of
https://github.com/zDevelopers/ImageOnMap.git
synced 2025-01-07 16:27:38 +01:00
* BUG: Map items show correctly their position if they are part of a multiple-map poster.
This commit is contained in:
parent
aa7aa32592
commit
bdf35e9eef
@ -99,6 +99,16 @@ public class PosterImage
|
|||||||
return cutImages[x * columns + y];
|
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
|
* @return the number of lines of the poster
|
||||||
|
@ -68,12 +68,17 @@ public abstract class ImageMap
|
|||||||
|
|
||||||
|
|
||||||
protected void give(Inventory inventory, short mapID)
|
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);
|
ItemStack itemMap = new ItemStack(Material.MAP, 1, mapID);
|
||||||
if(isNamed())
|
if(itemName != null)
|
||||||
{
|
{
|
||||||
ItemMeta meta = itemMap.getItemMeta();
|
ItemMeta meta = itemMap.getItemMeta();
|
||||||
meta.setDisplayName(imageName);
|
meta.setDisplayName(itemName);
|
||||||
itemMap.setItemMeta(meta);
|
itemMap.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
inventory.addItem(itemMap);
|
inventory.addItem(itemMap);
|
||||||
|
@ -96,9 +96,11 @@ public class PosterMap extends ImageMap
|
|||||||
@Override
|
@Override
|
||||||
public void give(Inventory inv)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user