* BUG: Fix the metadata of item map parts.

This commit is contained in:
Adrien Prokopowicz 2016-07-10 17:16:04 +02:00
parent 5027f5bf71
commit d9bd6ff867
4 changed files with 25 additions and 11 deletions

View File

@ -52,8 +52,8 @@ public class MapDetailGui extends ExplorerGui<Short>
return new ItemStackBuilder(partMaterial) return new ItemStackBuilder(partMaterial)
.title(I.t(getPlayerLocale(), "{green}Map part")) .title(I.t(getPlayerLocale(), "{green}Map part"))
.lore(I.t(getPlayerLocale(), "{gray}Column: {white}{0}", y + 1)) .lore(I.t(getPlayerLocale(), "{gray}Row: {white}{0}", y + 1))
.lore(I.t(getPlayerLocale(), "{gray}Row: {white}{0}", x + 1)) .lore(I.t(getPlayerLocale(), "{gray}Column: {white}{0}", x + 1))
.loreLine() .loreLine()
.lore(I.t(getPlayerLocale(), "{gray}» {white}Click{gray} to get only this part")) .lore(I.t(getPlayerLocale(), "{gray}» {white}Click{gray} to get only this part"))
.item(); .item();

View File

@ -108,13 +108,13 @@ public class PosterMap extends ImageMap
public int getColumnAt(int i) public int getColumnAt(int i)
{ {
if(columnCount == 0) return 0; if(columnCount == 0) return 0;
return (i % columnCount) + 1; return (i % columnCount);
} }
public int getRowAt(int i) public int getRowAt(int i)
{ {
if(columnCount == 0) return 0; if(columnCount == 0) return 0;
return (i / columnCount) + 1; return (i / columnCount);
} }
public int getIndexAt(int col, int row) public int getIndexAt(int col, int row)

View File

@ -87,7 +87,7 @@ public class MapItemManager implements Listener
{ {
if(map.hasColumnData()) if(map.hasColumnData())
{ {
mapPartItem = createMapItem(map, map.getRowAt(i), map.getColumnAt(i)); mapPartItem = createMapItem(map, map.getColumnAt(i), map.getRowAt(i));
} }
else else
{ {
@ -136,13 +136,23 @@ public class MapItemManager implements Listener
static public ItemStack createMapItem(PosterMap map, int index) static public ItemStack createMapItem(PosterMap map, int index)
{ {
/// The name of a map item given to a player, if splatter maps are not used. 0 = map name; 1 = index. /// The name of a map item given to a player, if splatter maps are not used. 0 = map name; 1 = index.
return createMapItem(map.getMapIdAt(index), I.t("{0} (part {1})", map.getName(), index + 1)); return createMapItem(map.getMapIdAt(index), getMapTitle(map, index));
} }
static public ItemStack createMapItem(PosterMap map, int x, int y) static public ItemStack createMapItem(PosterMap map, int x, int y)
{ {
/// The name of a map item given to a player, if splatter maps are not used. 0 = map name; 1 = row; 2 = column. /// The name of a map item given to a player, if splatter maps are not used. 0 = map name; 1 = row; 2 = column.
return createMapItem(map.getMapIdAt(x, y), I.t("{0} (row {1}, column {2})", map.getName(), x + 1, y + 1)); return createMapItem(map.getMapIdAt(x, y), getMapTitle(map, y, x));
}
static public String getMapTitle(PosterMap map, int row, int column)
{
return I.t("{0} (row {1}, column {2})", map.getName(), row + 1, column + 1);
}
static public String getMapTitle(PosterMap map, int index)
{
return I.t("{0} (part {1})", map.getName(), index + 1);
} }
static public ItemStack createMapItem(short mapID, String text) static public ItemStack createMapItem(short mapID, String text)
@ -210,9 +220,9 @@ public class MapItemManager implements Listener
PosterMap poster = (PosterMap) map; PosterMap poster = (PosterMap) map;
int index = poster.getIndex(item.getDurability()); int index = poster.getIndex(item.getDurability());
if(poster.hasColumnData()) if(poster.hasColumnData())
return I.t("{0} (row {1}, column {2})", map.getName(), poster.getRowAt(index), poster.getColumnAt(index)); return getMapTitle(poster, poster.getRowAt(index), poster.getColumnAt(index));
return I.t("{0} (part {1})", map.getName(), index + 1); return getMapTitle(poster, index);
} }
} }
@ -256,7 +266,11 @@ public class MapItemManager implements Listener
} }
if(!MapManager.managesMap(frame.getItem())) return; if(!MapManager.managesMap(frame.getItem())) return;
frame.setItem(ItemUtils.setDisplayName(item, getMapTitle(item)));
frame.setItem(new ItemStackBuilder(item)
.title(getMapTitle(item))
.hideAttributes()
.item());
} }

View File

@ -75,7 +75,7 @@ public class PosterWall
int mapIndex = map.getIndex(mapId); int mapIndex = map.getIndex(mapId);
int x = map.getColumnAt(mapIndex), y = map.getRowAt(mapIndex); int x = map.getColumnAt(mapIndex), y = map.getRowAt(mapIndex);
return getMatchingMapFrames(map, location.clone().add(-x + 1, y - 1)); return getMatchingMapFrames(map, location.clone().add(-x, y));
} }
static public ItemFrame[] getMatchingMapFrames(PosterMap map, FlatLocation location) static public ItemFrame[] getMatchingMapFrames(PosterMap map, FlatLocation location)