More minor fixes.

* NEW: GUIs are now translated according to the player's locale.
* BUG: Fix some usage parameters.
* BUG: Fix Map initialisation on startup if the map is invalid.
* BUG: PosterMap: remove a debugging message.
* BUG: Fix the command error message for the french locale.
This commit is contained in:
Adrien Prokopowicz 2016-07-08 04:45:08 +02:00
parent 225c76de7c
commit a730aab1f1
8 changed files with 46 additions and 48 deletions

View File

@ -28,7 +28,7 @@ import org.bukkit.ChatColor;
import java.util.List; import java.util.List;
@CommandInfo (name = "delete", usageParameters = "[tool name]") @CommandInfo (name = "delete", usageParameters = "[map name]")
public class DeleteConfirmCommand extends IoMCommand public class DeleteConfirmCommand extends IoMCommand
{ {
@Override @Override

View File

@ -99,7 +99,7 @@ public class ConfirmDeleteMapGui extends ActionGui
protected void onUpdate() protected void onUpdate()
{ {
/// The title of the map deletion GUI. {0}: map name. /// The title of the map deletion GUI. {0}: map name.
setTitle(I.t("{0} » {black}Confirm deletion", mapToDelete.getName())); setTitle(I.t(getPlayerLocale(), "{0} » {black}Confirm deletion", mapToDelete.getName()));
setSize(6 * 9); setSize(6 * 9);
@ -107,13 +107,13 @@ public class ConfirmDeleteMapGui extends ActionGui
action("", 13, new ItemStackBuilder(Material.EMPTY_MAP) action("", 13, new ItemStackBuilder(Material.EMPTY_MAP)
/// The title of the map deletion item /// The title of the map deletion item
.title(I.t("{red}You're about to destroy this map...")) .title(I.t(getPlayerLocale(), "{red}You're about to destroy this map..."))
/// The end, in the lore, of a title starting with You're about to destroy this map.... /// The end, in the lore, of a title starting with You're about to destroy this map....
.lore(I.t("{red}...{italic}forever{red}.")) .lore(I.t(getPlayerLocale(), "{red}...{italic}forever{red}."))
.loreLine() .loreLine()
.lore(I.t("{gray}Name: {white}{0}",mapToDelete.getName())) .lore(I.t(getPlayerLocale(), "{gray}Name: {white}{0}",mapToDelete.getName()))
.lore(I.t("{gray}Map ID: {white}{0}", mapToDelete.getId())) .lore(I.t(getPlayerLocale(), "{gray}Map ID: {white}{0}", mapToDelete.getId()))
.lore(I.t("{gray}Maps inside: {white}{0}", mapToDelete.getMapsIDs().length)) .lore(I.t(getPlayerLocale(), "{gray}Maps inside: {white}{0}", mapToDelete.getMapsIDs().length))
.hideAttributes() .hideAttributes()
); );

View File

@ -51,11 +51,11 @@ public class MapDetailGui extends ExplorerGui<Short>
partMaterial = Material.EMPTY_MAP; partMaterial = Material.EMPTY_MAP;
return new ItemStackBuilder(partMaterial) return new ItemStackBuilder(partMaterial)
.title(I.t("{green}Map part")) .title(I.t(getPlayerLocale(), "{green}Map part"))
.lore(I.t("{gray}Column: {white}{0}", y + 1)) .lore(I.t(getPlayerLocale(), "{gray}Column: {white}{0}", y + 1))
.lore(I.t("{gray}Row: {white}{0}", x + 1)) .lore(I.t(getPlayerLocale(), "{gray}Row: {white}{0}", x + 1))
.loreLine() .loreLine()
.lore(I.t("{gray}» {white}Click{gray} to get only this part")) .lore(I.t(getPlayerLocale(), "{gray}» {white}Click{gray} to get only this part"))
.item(); .item();
} }
@ -68,10 +68,10 @@ public class MapDetailGui extends ExplorerGui<Short>
partMaterial = Material.EMPTY_MAP; partMaterial = Material.EMPTY_MAP;
return new ItemStackBuilder(partMaterial) return new ItemStackBuilder(partMaterial)
.title(I.t("{green}Map part")) .title(I.t(getPlayerLocale(), "{green}Map part"))
.lore(I.t("{gray}Part: {white}{0}", index + 1)) .lore(I.t(getPlayerLocale(), "{gray}Part: {white}{0}", index + 1))
.loreLine() .loreLine()
.lore(I.t("{gray}» {white}Click{gray} to get only this part")) .lore(I.t(getPlayerLocale(), "{gray}» {white}Click{gray} to get only this part"))
.item(); .item();
} }
@ -111,7 +111,7 @@ public class MapDetailGui extends ExplorerGui<Short>
protected void onUpdate() protected void onUpdate()
{ {
/// Title of the map details GUI /// Title of the map details GUI
setTitle(I.t("Your maps » {black}{0}", map.getName())); setTitle(I.t(getPlayerLocale(), "Your maps » {black}{0}", map.getName()));
setKeepHorizontalScrollingSpace(true); setKeepHorizontalScrollingSpace(true);
if(map instanceof PosterMap) if(map instanceof PosterMap)
@ -133,15 +133,15 @@ public class MapDetailGui extends ExplorerGui<Short>
action("rename", getSize() - 7, new ItemStackBuilder(Material.BOOK_AND_QUILL) action("rename", getSize() - 7, new ItemStackBuilder(Material.BOOK_AND_QUILL)
.title(I.t("{blue}Rename this image")) .title(I.t(getPlayerLocale(), "{blue}Rename this image"))
.longLore(I.t("{gray}Click here to rename this image; this is used for your own organization.")) .longLore(I.t(getPlayerLocale(), "{gray}Click here to rename this image; this is used for your own organization."))
); );
action("delete", getSize() - 6, new ItemStackBuilder(Material.BARRIER) action("delete", getSize() - 6, new ItemStackBuilder(Material.BARRIER)
.title("{red}Delete this image") .title(I.t(getPlayerLocale(), "{red}Delete this image"))
.longLore(I.t("{gray}Deletes this map {white}forever{gray}. This action cannot be undone!")) .longLore(I.t(getPlayerLocale(), "{gray}Deletes this map {white}forever{gray}. This action cannot be undone!"))
.loreLine() .loreLine()
.longLore(I.t("{gray}You will be asked to confirm your choice if you click here.")) .longLore(I.t(getPlayerLocale(), "{gray}You will be asked to confirm your choice if you click here."))
); );
@ -153,8 +153,8 @@ public class MapDetailGui extends ExplorerGui<Short>
backSlot++; backSlot++;
action("back", backSlot, new ItemStackBuilder(Material.EMERALD) action("back", backSlot, new ItemStackBuilder(Material.EMERALD)
.title(I.t("{green}« Back")) .title(I.t(getPlayerLocale(), "{green}« Back"))
.lore(I.t("{gray}Go back to the list.")) .lore(I.t(getPlayerLocale(), "{gray}Go back to the list."))
); );
} }
@ -169,12 +169,12 @@ public class MapDetailGui extends ExplorerGui<Short>
{ {
if (newName == null || newName.isEmpty()) if (newName == null || newName.isEmpty())
{ {
getPlayer().sendMessage(I.t("{ce}Map names can't be empty.")); I.sendT(getPlayer(), "{ce}Map names can't be empty.");
return; return;
} }
map.rename(newName); map.rename(newName);
getPlayer().sendMessage(I.t("{cs}Map successfully renamed.")); I.sendT(getPlayer(), "{cs}Map successfully renamed.");
} }
}, map.getName(), this); }, map.getName(), this);
} }

View File

@ -41,7 +41,7 @@ public class MapListGui extends ExplorerGui<ImageMap>
if (map instanceof SingleMap) if (map instanceof SingleMap)
{ {
/// Displayed subtitle description of a single map on the list GUI /// Displayed subtitle description of a single map on the list GUI
mapDescription = I.t("{white}Single map"); mapDescription = I.t(getPlayerLocale(), "{white}Single map");
} }
else else
{ {
@ -49,25 +49,25 @@ public class MapListGui extends ExplorerGui<ImageMap>
if(poster.hasColumnData()) if(poster.hasColumnData())
{ {
/// Displayed subtitle description of a poster map on the list GUI (columns × rows in english) /// Displayed subtitle description of a poster map on the list GUI (columns × rows in english)
mapDescription = I.t("{white}Poster map ({0} × {1})", poster.getColumnCount(), poster.getRowCount()); mapDescription = I.t(getPlayerLocale(), "{white}Poster map ({0} × {1})", poster.getColumnCount(), poster.getRowCount());
} }
else else
{ {
/// Displayed subtitle description of a poster map without column data on the list GUI /// Displayed subtitle description of a poster map without column data on the list GUI
mapDescription = I.t("{white}Poster map ({0} parts)", poster.getMapCount()); mapDescription = I.t(getPlayerLocale(), "{white}Poster map ({0} parts)", poster.getMapCount());
} }
} }
return new ItemStackBuilder(Material.MAP) return new ItemStackBuilder(Material.MAP)
/// Displayed title of a map on the list GUI /// Displayed title of a map on the list GUI
.title(I.t("{green}{bold}{0}", map.getName())) .title(I.t(getPlayerLocale(), "{green}{bold}{0}", map.getName()))
.lore(mapDescription) .lore(mapDescription)
.loreLine() .loreLine()
/// Map ID displayed in the tooltip of a map on the list GUI /// Map ID displayed in the tooltip of a map on the list GUI
.lore(I.t("{gray}Map ID: {0}", map.getId())) .lore(I.t(getPlayerLocale(), "{gray}Map ID: {0}", map.getId()))
.loreLine() .loreLine()
.lore(I.t("{gray}» {white}Left-click{gray} to get this map")) .lore(I.t(getPlayerLocale(), "{gray}» {white}Left-click{gray} to get this map"))
.lore(I.t("{gray}» {white}Right-click{gray} for details and options")) .lore(I.t(getPlayerLocale(), "{gray}» {white}Right-click{gray} for details and options"))
.item(); .item();
} }
@ -76,8 +76,8 @@ public class MapListGui extends ExplorerGui<ImageMap>
protected ItemStack getEmptyViewItem() protected ItemStack getEmptyViewItem()
{ {
return new ItemStackBuilder(Material.BARRIER) return new ItemStackBuilder(Material.BARRIER)
.title(I.t("{red}You don't have any map.")) .title(I.t(getPlayerLocale(), "{red}You don't have any map."))
.longLore(I.t("{gray}Get started by creating a new one using {white}/tomap <URL> [resize]{gray}!")) .longLore(I.t(getPlayerLocale(), "{gray}Get started by creating a new one using {white}/tomap <URL> [resize]{gray}!"))
.item(); .item();
} }
@ -115,7 +115,7 @@ public class MapListGui extends ExplorerGui<ImageMap>
ImageMap[] maps = MapManager.getMaps(getPlayer().getUniqueId()); ImageMap[] maps = MapManager.getMaps(getPlayer().getUniqueId());
setData(maps); setData(maps);
/// The maps list GUI title /// The maps list GUI title
setTitle(I.t("{black}Your maps {reset}({0})", maps.length)); setTitle(I.t(getPlayerLocale(), "{black}Your maps {reset}({0})", maps.length));
setKeepHorizontalScrollingSpace(true); setKeepHorizontalScrollingSpace(true);
@ -144,24 +144,24 @@ public class MapListGui extends ExplorerGui<ImageMap>
double percentageUsed = mapPartLeft < 0 ? 0 : ((double) mapPartCount) / ((double) (mapPartCount + mapPartLeft)) * 100; double percentageUsed = mapPartLeft < 0 ? 0 : ((double) mapPartCount) / ((double) (mapPartCount + mapPartLeft)) * 100;
ItemStackBuilder statistics = new ItemStackBuilder(Material.ENCHANTED_BOOK) ItemStackBuilder statistics = new ItemStackBuilder(Material.ENCHANTED_BOOK)
.title(I.t("{blue}Usage statistics")) .title(I.t(getPlayerLocale(), "{blue}Usage statistics"))
.loreLine() .loreLine()
.lore(I.tn("{white}{0}{gray} image rendered", "{white}{0}{gray} images rendered", imagesCount)) .lore(I.tn(getPlayerLocale(), "{white}{0}{gray} image rendered", "{white}{0}{gray} images rendered", imagesCount))
.lore(I.tn("{white}{0}{gray} Minecraft map used", "{white}{0}{gray} Minecraft maps used", mapPartCount)); .lore(I.tn(getPlayerLocale(), "{white}{0}{gray} Minecraft map used", "{white}{0}{gray} Minecraft maps used", mapPartCount));
if(mapPartLeft >= 0) if(mapPartLeft >= 0)
{ {
statistics statistics
.lore("", I.t("{blue}Minecraft maps limits"), "") .lore("", I.t(getPlayerLocale(), "{blue}Minecraft maps limits"), "")
.lore(mapGlobalLimit == 0 .lore(mapGlobalLimit == 0
? I.t("{gray}Server-wide limit: {white}unlimited") ? I.t(getPlayerLocale(), "{gray}Server-wide limit: {white}unlimited")
: I.t("{gray}Server-wide limit: {white}{0}", mapGlobalLimit)) : I.t(getPlayerLocale(), "{gray}Server-wide limit: {white}{0}", mapGlobalLimit))
.lore(mapPersonalLimit == 0 .lore(mapPersonalLimit == 0
? I.t("{gray}Per-player limit: {white}unlimited") ? I.t(getPlayerLocale(), "{gray}Per-player limit: {white}unlimited")
: I.t("{gray}Per-player limit: {white}{0}", mapPersonalLimit)) : I.t(getPlayerLocale(), "{gray}Per-player limit: {white}{0}", mapPersonalLimit))
.loreLine() .loreLine()
.lore(I.t("{white}{0} %{gray} of your quota used", (int) Math.rint(percentageUsed))) .lore(I.t(getPlayerLocale(), "{white}{0} %{gray} of your quota used", (int) Math.rint(percentageUsed)))
.lore(I.tn("{white}{0}{gray} map left", "{white}{0}{gray} maps left", mapPartLeft)); .lore(I.tn(getPlayerLocale(), "{white}{0}{gray} map left", "{white}{0}{gray} maps left", mapPartLeft));
} }
statistics.hideAttributes(); statistics.hideAttributes();

View File

@ -106,6 +106,7 @@ public class MapInitEvent implements Listener
static protected void initMap(MapView map) static protected void initMap(MapView map)
{ {
if(map == null) return;
if(Renderer.isHandled(map)) return; if(Renderer.isHandled(map)) return;
File imageFile = ImageOnMap.getPlugin().getImageFile(map.getId()); File imageFile = ImageOnMap.getPlugin().getImageFile(map.getId());

View File

@ -140,7 +140,6 @@ public class PosterMap extends ImageMap
{ {
int x = index % (columnCount); int x = index % (columnCount);
int y = index / (columnCount); int y = index / (columnCount);
System.out.println(x + " : " + (rowCount - y - 1) + " (" + index);
return getMapIdAt(x, rowCount - y - 1); return getMapIdAt(x, rowCount - y - 1);
} }

View File

@ -87,8 +87,6 @@ public class PosterWall
{ {
for(int x = 0; x < map.getColumnCount(); ++x) for(int x = 0; x < map.getColumnCount(); ++x)
{ {
//Location newLocation = WorldUtils.addToLocation(topLeftLocation, x, -y, facing);
//System.out.println("Checking : " + loc);
int mapIndex = map.getIndexAt(x, y); int mapIndex = map.getIndexAt(x, y);
ItemFrame frame = getMapFrameAt(loc, map); ItemFrame frame = getMapFrameAt(loc, map);
if(frame != null) frames[mapIndex] = frame; if(frame != null) frames[mapIndex] = frame;

View File

@ -20,7 +20,7 @@ msgstr ""
#: src/main/java/fr/moribus/imageonmap/commands/IoMCommand.java:40 #: src/main/java/fr/moribus/imageonmap/commands/IoMCommand.java:40
msgid "You need to give a map name." msgid "You need to give a map name."
msgstr "Vous devez donner un nom à la carte." msgstr "Vous devez donner le nom d'une carte."
#: src/main/java/fr/moribus/imageonmap/commands/IoMCommand.java:57 #: src/main/java/fr/moribus/imageonmap/commands/IoMCommand.java:57
#: src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteNoConfirmCommand.java:51 #: src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteNoConfirmCommand.java:51