A5H73Y / Carz

Drive in Minecraft.
https://a5h73y.github.io/Carz/
MIT License
10 stars 8 forks source link

[DEV] String not found: [StringName] #23

Closed TheGreyDiamond closed 4 years ago

TheGreyDiamond commented 4 years ago

Hi, I forked your repo and tried to compile it. Everything worked well. Except that I'am geting the error: "String not found: [StringName]". Why ist that happening?

A5H73Y commented 4 years ago

Looking at your commit history, you've changed the method that get translations by removing the "Message." prefix. You'll see that all the strings in the config.yml start with "Messages." which is why it isn't matching. This isn't a problem for the main plugin and is something you've introduced so I will be closing this ticket.

TheGreyDiamond commented 4 years ago

I just forgot to commit my change back. My newest version looks like this:

public static String getTranslation(String translationKey, boolean prefix) {
        if (!Validation.isStringValid(translationKey)) {
            return "Invalid translation.";
        }

        String translated = Carz.getInstance().getSettings().getStringsConfig().getString("Message." + translationKey);
        translated = translated != null ? colour(translated) : "String not found: " + translationKey;
        return prefix ? Carz.getPrefix().concat(translated) : translated;
    }

I change the strings.yml to this:

Message:
  Prefix: '&0[&bCarz&0]&7 '
  SignHeader: '&0[&bCarz&0]'
  Commands: To Display all commands enter &f/Carz cmds
  ConfigReloaded: The config has been reloaded.
  Spawned: Car Spawned!
  Purchased: Car purchased!
  Refuel: Car Refuelled!
  EngineStart: You switch the engine on.
  EngineStop: You switch the engine off.
  CarLocked: You lock the car.
  CarUnlocked: You unlock the car.
  PlayerCar: '%PLAYER%''s car'
  FuelEmpty: This car has run out of fuel!
  KeyReceived: You receive a key.
  LiquidDamage: Your car has been destroyed by liquid!
  UpgradeSpeed: 'New top speed: %SPEED%'
  NoPermission: 'You do not have permission: &b%PERMISSION%'
  SignProtected: This sign is protected!
  UnknownCommand: Unknown Command!
  UnknownSignCommand: Unknown Sign Command!
  CommandDisabled: This command has been disabled!
  InCar: You are already in a car!
  NotInCar: You are not in a car!
  HaveCar: You already have a car!
  FuelDisabled: Fuel is disabled.
  PurchaseFailed: 'Purchase failed. Cost: %COST%'
  FullyUpgraded: Your car is already fully upgraded!
  Owned: This car is owned by %PLAYER%!

The original version was:

Carz:
  Prefix: '&0[&bCarz&0]&7 '
  SignHeader: '&0[&bCarz&0]'
  Commands: To Display all commands enter &f/Carz cmds
  ConfigReloaded: The config has been reloaded.
Car:
  Spawned: Car Spawned!
  Purchased: Car purchased!
  Refuel: Car Refuelled!
  EngineStart: You switch the engine on.
  EngineStop: You switch the engine off.
  CarLocked: You lock the car.
  CarUnlocked: You unlock the car.
  PlayerCar: '%PLAYER%''s car'
  FuelEmpty: This car has run out of fuel!
  KeyReceived: You receive a key.
  LiquidDamage: Your car has been destroyed by liquid!
  UpgradeSpeed: 'New top speed: %SPEED%'
Error:
  NoPermission: 'You do not have permission: &b%PERMISSION%'
  SignProtected: This sign is protected!
  UnknownCommand: Unknown Command!
  UnknownSignCommand: Unknown Sign Command!
  CommandDisabled: This command has been disabled!
  InCar: You are already in a car!
  NotInCar: You are not in a car!
  HaveCar: You already have a car!
  FuelDisabled: Fuel is disabled.
  PurchaseFailed: 'Purchase failed. Cost: %COST%'
  FullyUpgraded: Your car is already fully upgraded!
  Owned: This car is owned by %PLAYER%!

These changes fixed the problem.