GithubHelp home page GithubHelp logo

pikamug / localelib Goto Github PK

View Code? Open in Web Editor NEW
48.0 48.0 15.0 143 KB

Show translated names of items, entities & more in client's language

Home Page: https://www.spigotmc.org/resources/localelib.65617/

License: MIT License

Java 100.00%
bukkit-plugin java library maven minecraft spigot-plugin

localelib's People

Contributors

bestbearr avatar fatsaw avatar kamilkime avatar legamemc avatar mart-r avatar pikamug avatar rexlmanu avatar ultragamecoder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

localelib's Issues

ERROR

[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!

Documentation does not show proper access to LocaleManager

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.

Slight improvements

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;
}

No keys for 1.16 items and blocks?

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?

Tropical Fish

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]

NPE while loading translations

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) [?:?]

The translated text is always white color.

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?

Version 1.6 isn't available.

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 :)

I don't know how to install it...

Quests and ChestShop still show item name in english altough menu is in right language. Just placing jar in plugin folder isn't working.

NoClassDefFoundError

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

Missing API functionality

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);

Item Meta discarded

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.

org.bukkit.plugin.UnknownDependencyException

I followed the instruction to install LocaleLib, but spigot wrang : "org.bukkit.plugin.UnknownDependencyException: Unknown dependency LocaleLib. Please download and install LocaleLib to run this plugin."
image
image

Right 1.8 record title mappings

keys.put("GOLD_RECORD", "item.record.name"); // added
keys.put("GREEN_RECORD", "item.record.name"); // added
keys.put("RECORD_6", "item.record.name"); // added
keys.put("RECORD_4", "item.record.name"); // added
keys.put("RECORD_5", "item.record.name"); // added
keys.put("RECORD_6", "item.record.name"); // added
keys.put("RECORD_7", "item.record.name"); // added
keys.put("RECORD_8", "item.record.name"); // added
keys.put("RECORD_9", "item.record.name"); // added
keys.put("RECORD_10", "item.record.name"); // added
keys.put("RECORD_11", "item.record.name"); // added
keys.put("RECORD_12", "item.record.name"); // added

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");

object is not an instance of declaring class

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.