diff --git a/src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java b/src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java index 7ce724c..c2f7f29 100644 --- a/src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java +++ b/src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java @@ -52,8 +52,8 @@ public class MapDetailGui extends ExplorerGui return new ItemStackBuilder(partMaterial) .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}", x + 1)) + .lore(I.t(getPlayerLocale(), "{gray}Row: {white}{0}", y + 1)) + .lore(I.t(getPlayerLocale(), "{gray}Column: {white}{0}", x + 1)) .loreLine() .lore(I.t(getPlayerLocale(), "{gray}ยป {white}Click{gray} to get only this part")) .item(); diff --git a/src/main/java/fr/moribus/imageonmap/map/PosterMap.java b/src/main/java/fr/moribus/imageonmap/map/PosterMap.java index 525eaf2..37199ef 100644 --- a/src/main/java/fr/moribus/imageonmap/map/PosterMap.java +++ b/src/main/java/fr/moribus/imageonmap/map/PosterMap.java @@ -108,13 +108,13 @@ public class PosterMap extends ImageMap public int getColumnAt(int i) { if(columnCount == 0) return 0; - return (i % columnCount) + 1; + return (i % columnCount); } public int getRowAt(int i) { if(columnCount == 0) return 0; - return (i / columnCount) + 1; + return (i / columnCount); } public int getIndexAt(int col, int row) diff --git a/src/main/java/fr/moribus/imageonmap/ui/MapItemManager.java b/src/main/java/fr/moribus/imageonmap/ui/MapItemManager.java index c6c55c1..6f9309b 100644 --- a/src/main/java/fr/moribus/imageonmap/ui/MapItemManager.java +++ b/src/main/java/fr/moribus/imageonmap/ui/MapItemManager.java @@ -87,7 +87,7 @@ public class MapItemManager implements Listener { if(map.hasColumnData()) { - mapPartItem = createMapItem(map, map.getRowAt(i), map.getColumnAt(i)); + mapPartItem = createMapItem(map, map.getColumnAt(i), map.getRowAt(i)); } else { @@ -136,13 +136,23 @@ public class MapItemManager implements Listener 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. - 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) { /// 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) @@ -210,9 +220,9 @@ public class MapItemManager implements Listener PosterMap poster = (PosterMap) map; int index = poster.getIndex(item.getDurability()); 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; - frame.setItem(ItemUtils.setDisplayName(item, getMapTitle(item))); + + frame.setItem(new ItemStackBuilder(item) + .title(getMapTitle(item)) + .hideAttributes() + .item()); } diff --git a/src/main/java/fr/moribus/imageonmap/ui/PosterWall.java b/src/main/java/fr/moribus/imageonmap/ui/PosterWall.java index 7c7a429..8db4630 100644 --- a/src/main/java/fr/moribus/imageonmap/ui/PosterWall.java +++ b/src/main/java/fr/moribus/imageonmap/ui/PosterWall.java @@ -75,7 +75,7 @@ public class PosterWall int mapIndex = map.getIndex(mapId); 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)