Locales : added meta.banner, meta.auhors and meta.version

This commit is contained in:
Florian CUNY 2018-08-07 16:26:37 +02:00
parent cd7f8ddf24
commit 1455d6e7f5
8 changed files with 70 additions and 52 deletions

View File

@ -1,5 +1,7 @@
package world.bentobox.bentobox.api.localization; package world.bentobox.bentobox.api.localization;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@ -15,13 +17,22 @@ public class BentoBoxLocale {
private Locale locale; private Locale locale;
private YamlConfiguration config; private YamlConfiguration config;
private ItemStack banner; private ItemStack banner;
private List<String> authors;
private boolean obsolete;
public BentoBoxLocale(Locale locale, YamlConfiguration config) { public BentoBoxLocale(Locale locale, YamlConfiguration config) {
this.locale = locale; this.locale = locale;
this.config = config; this.config = config;
// Load the banner from the configuration // Load the banner from the configuration
banner = ItemParser.parse(config.getString("banner")); banner = ItemParser.parse(config.getString("meta.banner"));
// Load authors from the configuration
authors = new LinkedList<>();
updateAuthors(config);
// TODO Check if obsolete
obsolete = false;
} }
/** /**
@ -76,19 +87,39 @@ public class BentoBoxLocale {
return banner; return banner;
} }
public List<String> getAuthors() {
return authors;
}
public boolean isObsolete() {
return obsolete;
}
/** /**
* Merges a language YAML file to this locale * Merges a language YAML file to this locale
* @param toBeMerged the YamlConfiguration of the language file * @param toBeMerged the YamlConfiguration of the language file
*/ */
public void merge(YamlConfiguration toBeMerged) { public void merge(YamlConfiguration toBeMerged) {
for (String key : toBeMerged.getKeys(true)) { for (String key : toBeMerged.getKeys(true)) {
if (!config.contains(key)) { if (!key.startsWith("meta") && !config.contains(key)) {
config.set(key, toBeMerged.get(key)); config.set(key, toBeMerged.get(key));
} }
} }
updateAuthors(toBeMerged);
} }
public boolean contains(String reference) { public boolean contains(String reference) {
return config.contains(reference); return config.contains(reference);
} }
private void updateAuthors(YamlConfiguration yamlConfiguration) {
List<String> list = yamlConfiguration.getStringList("meta.authors");
if (!list.isEmpty()) {
for (String author : list) {
if (!authors.contains(author)) {
authors.add(author);
}
}
}
}
} }

View File

@ -3,14 +3,11 @@
# the one at http://yaml-online-parser.appspot.com # # the one at http://yaml-online-parser.appspot.com #
########################################################################################### ###########################################################################################
### Credits ### meta:
# Tastybento: maintainer authors:
# Poslovitch: maintainer - markusmarkusz
# markusmarkusz: translator banner: "RED_BANNER:1:STRIPE_RIGHT:BLACK:STRIPE_LEFT:YELLOW"
# version: "alpha-1"
# This translation is adapted to version : [alpha-1]
banner: "RED_BANNER:1:STRIPE_RIGHT:BLACK:STRIPE_LEFT:YELLOW"
not-setup: not-setup:
header: |- header: |-

View File

@ -3,13 +3,11 @@
# the one at http://yaml-online-parser.appspot.com # # the one at http://yaml-online-parser.appspot.com #
########################################################################################### ###########################################################################################
### Credits ### meta:
# Tastybento: maintainer authors:
# Poslovitch: maintainer - tastybento
# banner: "BLUE_BANNER:1:STRIPE_DOWNLEFT:WHITE:STRIPE_DOWNRIGHT:WHITE:STRIPE_CENTER:WHITE:STRIPE_MIDDLE:WHITE:STRAIGHT_CROSS:RED:CROSS:RED"
# This translation is adapted to version : [alpha-1] version: "alpha-1"
banner: "BLUE_BANNER:1:STRIPE_DOWNLEFT:WHITE:STRIPE_DOWNRIGHT:WHITE:STRIPE_CENTER:WHITE:STRIPE_MIDDLE:WHITE:STRAIGHT_CROSS:RED:CROSS:RED"
protection: protection:
flags: flags:

View File

@ -3,13 +3,12 @@
# the one at http://yaml-online-parser.appspot.com # # the one at http://yaml-online-parser.appspot.com #
########################################################################################### ###########################################################################################
### Credits ### meta:
# tastybento: maintainer authors:
# Poslovitch: maintainer - tastybento
# - Poslovitch
# This translation is adapted to version : [alpha-2] banner: "WHITE_BANNER:1:STRIPE_SMALL:RED:SQUARE_TOP_RIGHT:CYAN:SQUARE_TOP_RIGHT:BLUE"
version: "FC-0.81"
banner: "WHITE_BANNER:1:STRIPE_SMALL:RED:SQUARE_TOP_RIGHT:CYAN:SQUARE_TOP_RIGHT:BLUE"
general: general:
success: "&aSuccess!" success: "&aSuccess!"

View File

@ -3,13 +3,12 @@
# utilisant un parser YAML, tel que http://yaml-online-parser.appspot.com # # utilisant un parser YAML, tel que http://yaml-online-parser.appspot.com #
########################################################################################### ###########################################################################################
### Credits ### meta:
# MrSheepSheep: translater authors:
# Poslovitch: maintainer - MrSheepSheep
# - Poslovitch
# Cette traduction est adaptée pour la version : [alpha-2] banner: "WHITE_BANNER:1:STRIPE_BOTTOM:RED:STRIPE_TOP:BLUE"
version: "alpha-1"
banner: "WHITE_BANNER:1:STRIPE_BOTTOM:RED:STRIPE_TOP:BLUE"
general: general:
deaths: "morts" deaths: "morts"

View File

@ -3,12 +3,11 @@
# the one at http://yaml-online-parser.appspot.com # # the one at http://yaml-online-parser.appspot.com #
########################################################################################### ###########################################################################################
### Credits ### meta:
# RikoDEV: maintainer authors:
# - RikoDEV
# This translation is adapted to version : [alpha-2] banner: "WHITE_BANNER:1:HALF_VERTICAL:RED"
version: "FC-0.8"
banner: "WHITE_BANNER:1:HALF_VERTICAL:RED"
general: general:
success: "&aSukces!" success: "&aSukces!"

View File

@ -3,14 +3,11 @@
# cái này http://yaml-online-parser.appspot.com # # cái này http://yaml-online-parser.appspot.com #
########################################################################################### ###########################################################################################
### Credits ### meta:
# tastybento: Người cung cấp bản YML gốc authors:
# Poslovitch: Người cung cấp bản YML gốc - Banbeucmas
# banner: "RED_BANNER:1:CREEPER:YELLOW:RHOMBUS_MIDDLE:YELLOW:TRIANGLES_BOTTOM:RED:SQUARE_BOTTOM_LEFT:RED:SQUARE_BOTTOM_RIGHT:RED"
# Banbeucmas: Người dịch bản YML gốc version: "alpha-1"
# This translation is adapted to version : [alpha-2]
banner: "RED_BANNER:1:CREEPER:YELLOW:RHOMBUS_MIDDLE:YELLOW:TRIANGLES_BOTTOM:RED:SQUARE_BOTTOM_LEFT:RED:SQUARE_BOTTOM_RIGHT:RED"
general: general:
deaths: "Chết" deaths: "Chết"

View File

@ -3,13 +3,11 @@
# the one at http://yaml-online-parser.appspot.com # # the one at http://yaml-online-parser.appspot.com #
########################################################################################### ###########################################################################################
### Credits ### meta:
# Tastybento: maintainer authors:
# Poslovitch: maintainer - DuckSoft
# DuckSoft: translator banner: "RED_BANNER:1:SQUARE_TOP_RIGHT:YELLOW:CROSS:RED:CURLY_BORDER:RED:MOJANG:YELLOW:HALF_HORIZONTAL_MIRROR:RED:HALF_VERTICAL:RED"
# This translation is adapted to version : [alpha-1] version: "alpha-1"
banner: "RED_BANNER:1:SQUARE_TOP_RIGHT:YELLOW:CROSS:RED:CURLY_BORDER:RED:MOJANG:YELLOW:HALF_HORIZONTAL_MIRROR:RED:HALF_VERTICAL:RED"
not-setup: not-setup:
header: |- header: |-