Correct lang + replacement mistake with inventory names

This commit is contained in:
Jikoo 2020-04-19 18:04:10 -04:00
parent a1b2df74cc
commit 34e7252d77
4 changed files with 13 additions and 13 deletions

View file

@ -190,19 +190,16 @@ public class PlayerDataManager implements IPlayerDataManager {
String title;
if (inventory instanceof SpecialEnderChest) {
HumanEntity owner = (HumanEntity) ((SpecialEnderChest) inventory).getBukkitOwner();
title = OpenInv.getPlugin(OpenInv.class).getLocalizedMessage(player, "container.enderchest");
title = OpenInv.getPlugin(OpenInv.class).getLocalizedMessage(player, "container.enderchest", "%player%", owner.getName());
if (title == null) {
title = "%player%'s Ender Chest";
title = owner.getName() + "'s Ender Chest";
}
//noinspection ConstantConditions - owner name can be null if loaded by UUID
title = title.replace("%player%", owner.getName() != null ? owner.getName() : owner.getUniqueId().toString());
} else if (inventory instanceof SpecialPlayerInventory) {
EntityHuman owner = ((PlayerInventory) inventory).player;
title = OpenInv.getPlugin(OpenInv.class).getLocalizedMessage(player, "container.player");
title = OpenInv.getPlugin(OpenInv.class).getLocalizedMessage(player, "container.player", "%player%", owner.getName());
if (title == null) {
title = "%player%'s Inventory";
title = owner.getName() + "'s Inventory";
}
title = title.replace("%player%", owner.getName() != null ? owner.getName() : owner.getUniqueID().toString());
} else {
return player.openInventory(inventory.getBukkitInventory());
}

View file

@ -192,17 +192,16 @@ public class PlayerDataManager implements IPlayerDataManager {
String title;
if (inventory instanceof SpecialEnderChest) {
HumanEntity owner = (HumanEntity) ((SpecialEnderChest) inventory).getBukkitOwner();
title = OpenInv.getPlugin(OpenInv.class).getLocalizedMessage(player, "container.enderchest");
title = OpenInv.getPlugin(OpenInv.class).getLocalizedMessage(player, "container.enderchest", "%player%", owner.getName());
if (title == null) {
title = "%player%'s Ender Chest";
title = owner.getName() + "'s Ender Chest";
}
} else if (inventory instanceof SpecialPlayerInventory) {
EntityHuman owner = ((PlayerInventory) inventory).player;
title = OpenInv.getPlugin(OpenInv.class).getLocalizedMessage(player, "container.player");
title = OpenInv.getPlugin(OpenInv.class).getLocalizedMessage(player, "container.player", "%player%", owner.getName());
if (title == null) {
title = "%player%'s Inventory";
title = owner.getName() + "'s Inventory";
}
title = title.replace("%player%", owner.getName() != null ? owner.getName() : owner.getUniqueID().toString());
} else {
return player.openInventory(inventory.getBukkitInventory());
}

View file

@ -313,6 +313,10 @@ public class OpenInv extends JavaPlugin implements IOpenInv {
return this.languageManager.getValue(key, getLocale(sender));
}
public @Nullable String getLocalizedMessage(@NotNull CommandSender sender, @NotNull String key, String... replacements) {
return this.languageManager.getValue(key, getLocale(sender), replacements);
}
@Nullable
private String getLocale(@NotNull CommandSender sender) {
if (sender instanceof Player) {

View file

@ -25,4 +25,4 @@ messages:
off: 'off'
container:
player: '%player%''s Inventory'
enderchest: '%Player''s Ender Chest'
enderchest: '%player%''s Ender Chest'