pikamug / localelib Goto Github PK
View Code? Open in Web Editor NEWShow translated names of items, entities & more in client's language
Home Page: https://www.spigotmc.org/resources/localelib.65617/
License: MIT License
Show translated names of items, entities & more in client's language
Home Page: https://www.spigotmc.org/resources/localelib.65617/
License: MIT License
LocaleLib/src/main/java/me/pikamug/localelib/LocaleKeys.java
Lines 35 to 36 in 6090bb0
Acacia needs to be 4.
And DarkOak has to be 5.
[13:58:20 ERROR]: [STDERR] [org.bukkit.craftbukkit.v1_18_R2.legacy.CraftLegacy] Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!
LocaleLib/src/main/java/me/pikamug/localelib/LocaleKeys.java
Lines 278 to 279 in 398781f
keys.put("LAPIS_BLOCK", "tile.blockLapis.name");
keys.put("LAPIS_ORE", "tile.oreLapis.name");
In the documentation on spigot there is this line of code to show how to grab the LocaleManager (Version 1.2):
private LocaleManager localeManager;
@Override
public void onEnable() {
localeManager = LocaleLib.getLocaleManager();
}
However this does not work as getLocaleManager is not statically accessible.
Either you need to make getLocaleManager work statically or change your documentation to this:
public void onEnable() {
LocaleLib localeLib = (LocaleLib) getServer().getPluginManager().getPlugin("LocaleLib");
manager = localeLib.getLocaleManager();
}
Though for sake of keeping the current documentation minimally changed, making getLocaleManager static would be the best option.
On line 57, I would suggest checking if Material.getMaterial("LINGERING_POTION")
returns null
as opposed to looping through all the materials.
I would also suggest making your key maps final
and your methods to create keys return immutable maps instead of making a new map each time.
Lastly, your use of a switch statement on line 282 can be simplified by removing the return true;
after each case except for the last one like so:
switch(bukkitVersion) {
case "1.12.2" :
case "1.12.1" :
case "1.12" :
...
case "1.7.2" :
return true;
default:
return false;
}
LocaleLib/src/main/java/me/pikamug/localelib/LocaleKeys.java
Lines 71 to 74 in 6090bb0
Right mappings:
LONG_GRASS.0
= tile.tallgrass.shrub.name
LONG_GRASS.1
= tile.tallgrass.grass.name
LONG_GRASS.2
= tile.tallgrass.fern.name
Looking through the code out of interest, I noticed that LocaleKeys.java doesn't contain any keys for the new 1.16 items such as netherrite, lanterns and more new items from 1.16, is this intentional or just an oversight somehere?
Feature Request:
support for translating tropical fish entities, specifically the predefined varieties (the ones with the translate keys that look like this):
entity.minecraft.tropical_fish.predefined.[0-21]
Latest change 71eac6d (on version <= 3.3 everything works normal) for some reason cause NullPointerException
(even if assets/minecraft/lang/en_us.json
actually exists in runtime). I tested it on 1.12.2 and 1.16.5 and same error appears (both on Java 8).
Also I don't think loading english translations always is necessary - it's only used in LocaleManager#toServerLocale
which don't appear to be used anywhere in LocaleLib itself
java.lang.NullPointerException: inStream parameter is null
at java.util.Objects.requireNonNull(Objects.java:233) ~[?:?]
at java.util.Properties.load(Properties.java:407) ~[?:?]
at net.dzikoysk.funnyguilds.libs.me.pikamug.localelib.LocaleKeys.loadTranslations(LocaleKeys.java:987) ~[?:?]
at net.dzikoysk.funnyguilds.libs.me.pikamug.localelib.LocaleManager.<init>(LocaleManager.java:99) ~[?:?]
at net.dzikoysk.funnyguilds.FunnyGuilds.onEnable(FunnyGuilds.java:251) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:518) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:432) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:599) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:298) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1074) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-794]
at java.lang.Thread.run(Thread.java:831) [?:?]
First, sorry for my bad English.
I use the LocaleLib-1.8 in my plugin, and my server version is 1.16.5.
I found that I can't change the color of the translated text, it will always be white.
the code:
localeManager.sendMessage(player, "Just a " + ChatColor.YELLOW + "<mob>", EntityType.CREEPER, null);
in game:
the code:
localeManager.sendMessage(player, ChatColor.GREEN + "Just a " + ChatColor.YELLOW + "<item>", Material.DIAMOND, (short)0, null);
in game:
is this a bug?
Going to the maven repo for the plugin, we have three versions, 1.0, 1.1 and af35481
, but not 1.6, as the documentation says.
Just thought I'd let you know so it can be sorted out :)
Quests and ChestShop still show item name in english altough menu is in right language. Just placing jar in plugin folder isn't working.
I added it to my gradle build.
I'm trying to use it as
private final LocaleManager localeManager = new LocaleManager();
but I get a NoClassDefFoundError error
I assume this was left over from transitioning LocaleLib over from Quests or something, but it can be confusing (if the message ever gets sent, that is)
Project names are not automatically translated and project names are not displayed
I use on 1.18.2 paper server
I think this API is missing the ability to obtain the item name by material and damage value.
It consist the ability to get the item by material.
String itemName = localeManager.queryMaterial(material);
But I'd also like to add a damage value to get what type of the material to use.
String itemName = localeManager.queryMaterial(material, (short) 5);
Or even make it obtainable through the player:
String playerLangItemName = localeManager.queryMaterial(player, material, (short) 5);
When querying an item stack (LocaleManager#queryItemStack), e.g. a potion, the item meta gets discarded in versions below 1.13. I haven't tested on any versions above, but this line in LocaleManager
ItemStack i = new ItemStack(material, 1, durability);
discards any useful meta, which means all potions becomes "potion.effect.empty". This is because queryItemStack actually just uses the item stack's material to call queryMaterial, and then queryMaterial just reconstructs an item stack (see above line) without the meta.
The following 2 if statements should be merged to allow other rabittypes to be translated
LocaleLib/src/main/java/me/pikamug/localelib/LocaleManager.java
Lines 159 to 160 in 6090bb0
LocaleLib/src/main/java/me/pikamug/localelib/LocaleKeys.java
Lines 601 to 612 in 6090bb0
keys.put("GOLD_RECORD", "item.record.13.desc");
keys.put("GREEN_RECORD", "item.record.cat.desc");
keys.put("RECORD_3", "item.record.blocks.desc");
keys.put("RECORD_4", "item.record.chirp.desc");
keys.put("RECORD_5", "item.record.far.desc");
keys.put("RECORD_6", "item.record.mall.desc");
keys.put("RECORD_7", "item.record.mellohi.desc");
keys.put("RECORD_8", "item.record.stal.desc");
keys.put("RECORD_9", "item.record.strad.desc");
keys.put("RECORD_10", "item.record.ward.desc");
keys.put("RECORD_11", "item.record.11.desc");
keys.put("RECORD_12", "item.record.wait.desc");
keys.put("RECORD", "item.record.name");
java.lang.IllegalArgumentException: object is not an instance of declaring class
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
at me.pikamug.localelib.LocaleManager.toServerLocale(LocaleManager.java:463) ~[LocaleLib-3.2.jar:?]
at kr.maint.customshop.ShopEvent.clickEvent(ShopEvent.java:115) ~[CustomShop-1.0-SNAPSHOT.jar:?]
at com.destroystokyo.paper.event.executor.StaticMethodHandleEventExecutor.execute(StaticMethodHandleEventExecutor.java:40) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:git-Paper-406]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54) ~[paper-1.19.3.jar:git-Paper-406]
at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:126) ~[paper-1.19.3.jar:git-Paper-406]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:615) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.handleContainerClick(ServerGamePacketListenerImpl.java:3165) ~[?:?]
at net.minecraft.network.protocol.game.ServerboundContainerClickPacket.handle(ServerboundContainerClickPacket.java:58) ~[?:?]
at net.minecraft.network.protocol.game.ServerboundContainerClickPacket.handle(ServerboundContainerClickPacket.java:23) ~[?:?]
at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$1(PacketUtils.java:51) ~[?:?]
at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.19.3.jar:git-Paper-406]
at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]
at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]
at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1341) ~[paper-1.19.3.jar:git-Paper-406]
at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:197) ~[paper-1.19.3.jar:git-Paper-406]
at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1318) ~[paper-1.19.3.jar:git-Paper-406]
at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1311) ~[paper-1.19.3.jar:git-Paper-406]
at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1289) ~[paper-1.19.3.jar:git-Paper-406]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1177) ~[paper-1.19.3.jar:git-Paper-406]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:316) ~[paper-1.19.3.jar:git-Paper-406]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
String key = localeManager.queryMaterial(Material.LAPIS_LAZULI);
String englishName = "";
try {
englishName = localeManager.toServerLocale(key);
} catch (IllegalAccessException | InvocationTargetException err) {
err.printStackTrace();
}
System.out.println(englishName);`
I used the basic example, but I get an error
REDSTONE_ORE
should be REDSTONE_BLOCK
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.