simplei18n fixed
This commit is contained in:
		@@ -5,7 +5,7 @@ plugins {
 | 
				
			|||||||
    id 'com.github.johnrengelman.shadow' version '4.0.4'
 | 
					    id 'com.github.johnrengelman.shadow' version '4.0.4'
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
group = 'me.skymc'
 | 
					group = 'me.skymc'
 | 
				
			||||||
version = '4.83'
 | 
					version = '4.84'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
sourceCompatibility = 1.8
 | 
					sourceCompatibility = 1.8
 | 
				
			||||||
targetCompatibility = 1.8
 | 
					targetCompatibility = 1.8
 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -1,10 +1,12 @@
 | 
				
			|||||||
package me.skymc.taboolib.common.util;
 | 
					package me.skymc.taboolib.common.util;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.ilummc.tlib.resources.TLocaleLoader;
 | 
					import com.ilummc.tlib.resources.TLocaleLoader;
 | 
				
			||||||
 | 
					import me.skymc.taboolib.Main;
 | 
				
			||||||
import me.skymc.taboolib.TabooLib;
 | 
					import me.skymc.taboolib.TabooLib;
 | 
				
			||||||
import me.skymc.taboolib.common.function.TFunction;
 | 
					import me.skymc.taboolib.common.function.TFunction;
 | 
				
			||||||
import me.skymc.taboolib.common.nms.NMSHandler;
 | 
					import me.skymc.taboolib.common.nms.NMSHandler;
 | 
				
			||||||
import me.skymc.taboolib.fileutils.ConfigUtils;
 | 
					import me.skymc.taboolib.fileutils.ConfigUtils;
 | 
				
			||||||
 | 
					import me.skymc.taboolib.fileutils.FileUtils;
 | 
				
			||||||
import org.bukkit.configuration.file.FileConfiguration;
 | 
					import org.bukkit.configuration.file.FileConfiguration;
 | 
				
			||||||
import org.bukkit.configuration.file.YamlConfiguration;
 | 
					import org.bukkit.configuration.file.YamlConfiguration;
 | 
				
			||||||
import org.bukkit.entity.Entity;
 | 
					import org.bukkit.entity.Entity;
 | 
				
			||||||
@@ -24,6 +26,7 @@ import java.util.Optional;
 | 
				
			|||||||
public class SimpleI18n {
 | 
					public class SimpleI18n {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static FileConfiguration lang;
 | 
					    private static FileConfiguration lang;
 | 
				
			||||||
 | 
					    private static boolean released;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static void init() {
 | 
					    static void init() {
 | 
				
			||||||
        File localeFile = getLocaleFile(TabooLib.instance());
 | 
					        File localeFile = getLocaleFile(TabooLib.instance());
 | 
				
			||||||
@@ -32,6 +35,11 @@ public class SimpleI18n {
 | 
				
			|||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            lang = ConfigUtils.load(TabooLib.instance(), localeFile);
 | 
					            lang = ConfigUtils.load(TabooLib.instance(), localeFile);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        if (lang.getInt("version") < 2 && !released) {
 | 
				
			||||||
 | 
					            released = true;
 | 
				
			||||||
 | 
					            FileUtils.deleteAllFile(new File(Main.getInst().getDataFolder(), "simpleI18n"));
 | 
				
			||||||
 | 
					            init();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static String getCustomName(Entity entity) {
 | 
					    public static String getCustomName(Entity entity) {
 | 
				
			||||||
@@ -47,7 +55,7 @@ public class SimpleI18n {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static String getName(Entity entity) {
 | 
					    public static String getName(Entity entity) {
 | 
				
			||||||
        return entity == null ? "-" : lang.getString(NMSHandler.getHandler().getName(entity), entity.getName());
 | 
					        return entity == null ? "-" : lang.getString(NMSHandler.getHandler().getName(entity).replace(".", "_"), entity.getName());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static String getName(ItemStack item) {
 | 
					    public static String getName(ItemStack item) {
 | 
				
			||||||
@@ -57,13 +65,13 @@ public class SimpleI18n {
 | 
				
			|||||||
        if (TabooLib.getVersionNumber() < 11300) {
 | 
					        if (TabooLib.getVersionNumber() < 11300) {
 | 
				
			||||||
            ItemMeta itemMeta = item.getItemMeta();
 | 
					            ItemMeta itemMeta = item.getItemMeta();
 | 
				
			||||||
            if (itemMeta instanceof SpawnEggMeta) {
 | 
					            if (itemMeta instanceof SpawnEggMeta) {
 | 
				
			||||||
                String spawnEggType = lang.getString("entity." + ((SpawnEggMeta) itemMeta).getSpawnedType().getEntityClass().getSimpleName() + ".name");
 | 
					                String spawnEggType = lang.getString("entity_" + ((SpawnEggMeta) itemMeta).getSpawnedType().getEntityClass().getSimpleName().replace(".", "_") + "_name");
 | 
				
			||||||
                if (spawnEggType != null) {
 | 
					                if (spawnEggType != null) {
 | 
				
			||||||
                    return lang.getString(NMSHandler.getHandler().getName(item), item.getType().name().toLowerCase().replace("_", "")) + " " + spawnEggType;
 | 
					                    return lang.getString(NMSHandler.getHandler().getName(item).replace(".", "_"), item.getType().name().toLowerCase().replace("_", "")) + " " + spawnEggType;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return lang.getString(NMSHandler.getHandler().getName(item), item.getType().name().toLowerCase().replace("_", ""));
 | 
					        return lang.getString(NMSHandler.getHandler().getName(item).replace(".", "_"), item.getType().name().toLowerCase().replace("_", ""));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static void releaseLocales(Plugin plugin) {
 | 
					    private static void releaseLocales(Plugin plugin) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user