diff --git a/CHANGELOG.md b/CHANGELOG.md index 199e16224..408babc1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,12 +36,14 @@ * Added translations for Recipe Types ### Changes +* Researches now use their namespaced keys in the Researches.yml ### Fixes * Fixed #1553 * Fixed #1513 * Fixed #1557 * Fixed #1558 +* Fixed a translation not showing properly ## Release Candidate 6 (16 Feb 2020) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/ChestSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/ChestSlimefunGuide.java index cceac9a34..4138f0ef6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/ChestSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/ChestSlimefunGuide.java @@ -449,7 +449,7 @@ public class ChestSlimefunGuide implements ISlimefunGuide { ChestMenu menu = create(p); if (item.hasWiki()) { - menu.addItem(8, new CustomItem(Material.KNOWLEDGE_BOOK, ChatColor.RESET + SlimefunPlugin.getLocal().getMessage("guide.tooltips.wiki"), "", ChatColor.GRAY + "\u21E8 " + ChatColor.GREEN + SlimefunPlugin.getLocal().getMessage(p, "guide.tooltips.open-category"))); + menu.addItem(8, new CustomItem(Material.KNOWLEDGE_BOOK, ChatColor.RESET + SlimefunPlugin.getLocal().getMessage(p, "guide.tooltips.wiki"), "", ChatColor.GRAY + "\u21E8 " + ChatColor.GREEN + SlimefunPlugin.getLocal().getMessage(p, "guide.tooltips.open-category"))); menu.addMenuClickHandler(8, (pl, slot, itemstack, action) -> { pl.closeInventory(); ChatUtils.sendURL(pl, item.getWiki()); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Translators.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Translators.java index 8f6b7279e..8108b21e7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Translators.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Translators.java @@ -89,7 +89,7 @@ public class Translators { addTranslator("mohkamfer", "citBabY", "ar", false); // Translators - Japanese - addTranslator("bito-blosh", "ja", true); + addTranslator("bito-blosh", "Bloshop", "ja", true); // Translators - Portuguese (Brazil) addTranslator("G4stavoM1ster", "pt-BR", true); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java index 1d7ff4843..a473d739c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java @@ -360,7 +360,12 @@ public final class SlimefunItemSetup { .register(plugin); SlimefunManager.registerArmorSet(new ItemStack(Material.GLOWSTONE), new ItemStack[] {SlimefunItems.GLOWSTONE_HELMET, SlimefunItems.GLOWSTONE_CHESTPLATE, SlimefunItems.GLOWSTONE_LEGGINGS, SlimefunItems.GLOWSTONE_BOOTS}, "GLOWSTONE", - new PotionEffect[][] {new PotionEffect[] {new PotionEffect(PotionEffectType.NIGHT_VISION, 600, 0)}, new PotionEffect[] {new PotionEffect(PotionEffectType.NIGHT_VISION, 600, 0)}, new PotionEffect[] {new PotionEffect(PotionEffectType.NIGHT_VISION, 600, 0)}, new PotionEffect[] {new PotionEffect(PotionEffectType.NIGHT_VISION, 600, 0)}}, true, true); + new PotionEffect[][] { + new PotionEffect[] {new PotionEffect(PotionEffectType.NIGHT_VISION, 600, 0)}, + new PotionEffect[] {new PotionEffect(PotionEffectType.NIGHT_VISION, 600, 0)}, + new PotionEffect[] {new PotionEffect(PotionEffectType.NIGHT_VISION, 600, 0)}, + new PotionEffect[] {new PotionEffect(PotionEffectType.NIGHT_VISION, 600, 0)} + }, true, plugin); SlimefunManager.registerArmorSet(SlimefunItems.DAMASCUS_STEEL_INGOT, new ItemStack[] {SlimefunItems.DAMASCUS_STEEL_HELMET, SlimefunItems.DAMASCUS_STEEL_CHESTPLATE, SlimefunItems.DAMASCUS_STEEL_LEGGINGS, SlimefunItems.DAMASCUS_STEEL_BOOTS}, "DAMASCUS_STEEL", true, false); diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/Research.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/Research.java index 3704140ab..d1805c3ae 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/Research.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/Research.java @@ -1,11 +1,8 @@ package me.mrCookieSlime.Slimefun.Objects; -import java.util.ArrayList; -import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; import java.util.List; -import java.util.UUID; import java.util.logging.Level; import org.bukkit.Bukkit; @@ -13,7 +10,6 @@ import org.bukkit.GameMode; import org.bukkit.Keyed; import org.bukkit.NamespacedKey; import org.bukkit.Sound; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import io.github.thebusybiscuit.cscorelib2.data.PersistentDataAPI; @@ -140,34 +136,6 @@ public class Research implements Keyed { return items; } - /** - * Convenience method to check if the player unlocked this research. - * - * @param p Player to check - * @return true if he unlocked the research, otherwise false - * - * @since 4.0 - * @see #hasUnlocked(UUID) - */ - @Deprecated - public boolean hasUnlocked(Player p) { - return hasUnlocked(p.getUniqueId()); - } - - /** - * Checks if the player unlocked this research. - * - * @param uuid UUID of the player to check - * @return true if he unlocked the research, otherwise false - * - * @since 4.0 - * @see #hasUnlocked(Player) - */ - @Deprecated - public boolean hasUnlocked(UUID uuid) { - return PlayerProfile.fromUUID(uuid).hasUnlocked(this); - } - /** * Checks if the player can unlock this research. * @@ -246,8 +214,11 @@ public class Research implements Keyed { */ public void register() { SlimefunPlugin.getResearchCfg().setDefaultValue("enable-researching", true); + + String path = key.getNamespace() + "." + key.getKey(); + migrate(id, path); - if (SlimefunPlugin.getResearchCfg().contains(this.getID() + ".enabled") && !SlimefunPlugin.getResearchCfg().getBoolean(this.getID() + ".enabled")) { + if (SlimefunPlugin.getResearchCfg().contains(path + ".enabled") && !SlimefunPlugin.getResearchCfg().getBoolean(path + ".enabled")) { Iterator iterator = items.iterator(); while (iterator.hasNext()) { SlimefunItem item = iterator.next(); @@ -257,11 +228,11 @@ public class Research implements Keyed { return; } - SlimefunPlugin.getResearchCfg().setDefaultValue(this.getID() + ".cost", this.getCost()); - SlimefunPlugin.getResearchCfg().setDefaultValue(this.getID() + ".enabled", true); + SlimefunPlugin.getResearchCfg().setDefaultValue(path + ".cost", this.getCost()); + SlimefunPlugin.getResearchCfg().setDefaultValue(path + ".enabled", true); - this.cost = SlimefunPlugin.getResearchCfg().getInt(this.getID() + ".cost"); - this.enabled = SlimefunPlugin.getResearchCfg().getBoolean(this.getID() + ".enabled"); + this.cost = SlimefunPlugin.getResearchCfg().getInt(path + ".cost"); + this.enabled = SlimefunPlugin.getResearchCfg().getBoolean(path + ".enabled"); SlimefunPlugin.getRegistry().getResearches().add(this); SlimefunPlugin.getRegistry().getResearchIds().add(this); @@ -271,6 +242,18 @@ public class Research implements Keyed { } } + private void migrate(int id, String path) { + if (SlimefunPlugin.getResearchCfg().contains(id + ".enabled")) { + SlimefunPlugin.getResearchCfg().setValue(path + ".enabled", SlimefunPlugin.getResearchCfg().getBoolean(id + ".enabled")); + } + + if (SlimefunPlugin.getResearchCfg().contains(id + ".cost")) { + SlimefunPlugin.getResearchCfg().setValue(path + ".cost", SlimefunPlugin.getResearchCfg().getInt(id + ".cost")); + } + + SlimefunPlugin.getResearchCfg().setValue(String.valueOf(id), null); + } + /** * Gets if the specified player is currently unlocking a research. * @@ -283,21 +266,6 @@ public class Research implements Keyed { return SlimefunPlugin.getRegistry().getCurrentlyResearchingPlayers().contains(p.getUniqueId()); } - /** - * Gets the title of the specified player. - * - * @param p Player to get the rank - * @param researched List of the player's unlocked researches - * @return the title of the specified player - * - * @since 4.0 - * @see #sendStats(CommandSender, Player) - */ - @Deprecated - public static String getTitle(Player p, Collection researched) { - return PlayerProfile.get(p).getTitle(); - } - /** * Attempts to get the research with the given ID. * @@ -312,24 +280,6 @@ public class Research implements Keyed { } return null; } - - /** - * Gets the list of unlocked researches for a player using his UUID. - * - * @param uuid UUID of the player - * @return the list of unlocked researches for the player - * - * @since 4.0 - * @see #getResearches(String) - */ - @Deprecated - public static List getResearches(UUID uuid) { - List researched = new ArrayList<>(); - for (Research research : SlimefunPlugin.getRegistry().getResearches()) { - if (research.hasUnlocked(uuid)) researched.add(research); - } - return researched; - } @Override public String toString() { diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Setup/SlimefunManager.java b/src/main/java/me/mrCookieSlime/Slimefun/Setup/SlimefunManager.java index 39dfa828e..2bed8c063 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Setup/SlimefunManager.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Setup/SlimefunManager.java @@ -12,6 +12,7 @@ import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.potion.PotionEffect; import io.github.thebusybiscuit.cscorelib2.item.ImmutableItemMeta; +import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; import io.github.thebusybiscuit.slimefun4.core.attributes.Soulbound; import me.mrCookieSlime.EmeraldEnchants.EmeraldEnchants; import me.mrCookieSlime.EmeraldEnchants.ItemEnchantment; @@ -32,9 +33,9 @@ public final class SlimefunManager { private SlimefunManager() {} - public static void registerArmorSet(ItemStack baseComponent, ItemStack[] items, String idSyntax, PotionEffect[][] effects, boolean special, boolean slimefun) { + public static void registerArmorSet(ItemStack baseComponent, ItemStack[] items, String idSyntax, PotionEffect[][] effects, boolean magical, SlimefunAddon addon) { String[] components = new String[] {"_HELMET", "_CHESTPLATE", "_LEGGINGS", "_BOOTS"}; - Category category = special ? Categories.MAGIC_ARMOR: Categories.ARMOR; + Category category = magical ? Categories.MAGIC_ARMOR: Categories.ARMOR; List recipes = new ArrayList<>(); recipes.add(new ItemStack[] {baseComponent, baseComponent, baseComponent, baseComponent, null, baseComponent, null, null, null}); @@ -44,10 +45,10 @@ public final class SlimefunManager { for (int i = 0; i < 4; i++) { if (i < effects.length && effects[i].length > 0) { - new SlimefunArmorPiece(category, new SlimefunItemStack(idSyntax + components[i], items[i]), RecipeType.ARMOR_FORGE, recipes.get(i), effects[i]).register(slimefun); + new SlimefunArmorPiece(category, new SlimefunItemStack(idSyntax + components[i], items[i]), RecipeType.ARMOR_FORGE, recipes.get(i), effects[i]).register(addon); } else { - new SlimefunItem(category, new SlimefunItemStack(idSyntax + components[i], items[i]), RecipeType.ARMOR_FORGE, recipes.get(i)).register(slimefun); + new SlimefunItem(category, new SlimefunItemStack(idSyntax + components[i], items[i]), RecipeType.ARMOR_FORGE, recipes.get(i)).register(addon); } } }