Skip to content

Commit 842f18e

Browse files
committed
Update to 1.3.0
1 parent c2da5d0 commit 842f18e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2872
-31
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ apply plugin: 'maven-publish'
1010

1111
group = 'com.meowj'
1212
archivesBaseName = 'LangUtils'
13-
version = '1.2.0.1-1.7.10'
13+
version = '1.3.0-1.7.10'
1414

1515
final def EULA_ACCEPT = true
1616

src/main/java/com/meowj/langutils/lang/LanguageHelper.java

Lines changed: 119 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.meowj.langutils.lang.convert.*;
1414
import com.meowj.langutils.locale.LocaleHelper;
1515
import org.bukkit.Material;
16+
import org.bukkit.enchantments.Enchantment;
1617
import org.bukkit.entity.Entity;
1718
import org.bukkit.entity.EntityType;
1819
import org.bukkit.entity.LivingEntity;
@@ -41,7 +42,7 @@ public static String getItemDisplayName(ItemStack item, String locale) {
4142
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName())
4243
return item.getItemMeta().getDisplayName();
4344
else
44-
return LanguageHelper.getItemName(item, locale);
45+
return getItemName(item, locale);
4546
}
4647

4748
/**
@@ -128,7 +129,8 @@ public static String getEntityUnlocalizedName(EntityType entityType) {
128129
* @return The name of the entity
129130
*/
130131
public static String getEntityDisplayName(Entity entity, String locale) {
131-
return (entity instanceof LivingEntity) && ((LivingEntity) entity).getCustomName() != null ? ((LivingEntity) entity).getCustomName() :
132+
return (entity instanceof LivingEntity) && ((LivingEntity) entity).getCustomName() != null ?
133+
((LivingEntity) entity).getCustomName() :
132134
getEntityName(entity, locale);
133135
}
134136

@@ -187,6 +189,121 @@ public static String getEntityName(EntityType entityType, Player player) {
187189
return getEntityName(entityType, LocaleHelper.getPlayerLanguage(player));
188190
}
189191

192+
193+
/**
194+
* Return the unlocalized name of the enchantment level(Minecraft convention)
195+
*
196+
* @param level The enchantment level
197+
* @return The unlocalized name.(if level is greater than 10, it will only return the number of the level)
198+
*/
199+
public static String getEnchantmentLevelUnlocalizedName(int level) {
200+
EnumEnchantmentLevel enumEnchLevel = EnumEnchantmentLevel.get(level);
201+
return enumEnchLevel != null ? enumEnchLevel.getUnlocalizedName() : Integer.toString(level);
202+
}
203+
204+
/**
205+
* Return the name of the enchantment level
206+
*
207+
* @param level The enchantment level
208+
* @param player The language of the level
209+
* @return The name of the level.(if level is greater than 10, it will only return the number of the level)
210+
*/
211+
public static String getEnchantmentLevelName(int level, Player player) {
212+
return translateToLocal(getEnchantmentLevelUnlocalizedName(level), LocaleHelper.getPlayerLanguage(player));
213+
}
214+
215+
/**
216+
* Return the name of the enchantment level
217+
*
218+
* @param level The enchantment level
219+
* @param locale The language of the level
220+
* @return The name of the level.(if level is greater than 10, it will only return the number of the level)
221+
*/
222+
public static String getEnchantmentLevelName(int level, String locale) {
223+
return translateToLocal(getEnchantmentLevelUnlocalizedName(level), locale);
224+
}
225+
226+
/**
227+
* Return the unlocalized name of the enchantment(Minecraft convention)
228+
*
229+
* @param enchantment The enchantment
230+
* @return The unlocalized name.
231+
*/
232+
public static String getEnchantmentUnlocalizedName(Enchantment enchantment) {
233+
EnumEnchantment enumEnch = EnumEnchantment.get(enchantment);
234+
return (enumEnch != null ? enumEnch.getUnlocalizedName() : enchantment.getName());
235+
}
236+
237+
/**
238+
* Return the name of the enchantment.
239+
*
240+
* @param enchantment The enchantment
241+
* @param player The receiver of the name
242+
* @return The name of the enchantment
243+
*/
244+
public static String getEnchantmentName(Enchantment enchantment, Player player) {
245+
return getEnchantmentName(enchantment, LocaleHelper.getPlayerLanguage(player));
246+
}
247+
248+
/**
249+
* Return the name of the enchantment.
250+
*
251+
* @param enchantment The enchantment
252+
* @param locale The language of the name
253+
* @return The name of the enchantment
254+
*/
255+
public static String getEnchantmentName(Enchantment enchantment, String locale) {
256+
return translateToLocal(getEnchantmentUnlocalizedName(enchantment), locale);
257+
}
258+
259+
/**
260+
* Return the display name of the enchantment(with level).
261+
*
262+
* @param enchantment The enchantment
263+
* @param level The enchantment level
264+
* @param player The receiver of the name
265+
* @return The name of the item
266+
*/
267+
public static String getEnchantmentDisplayName(Enchantment enchantment, int level, Player player) {
268+
return getEnchantmentDisplayName(enchantment, level, LocaleHelper.getPlayerLanguage(player));
269+
}
270+
271+
/**
272+
* Return the display name of the enchantment(with level).
273+
*
274+
* @param enchantment The enchantment
275+
* @param level The enchantment level
276+
* @param locale The language of the name
277+
* @return The name of the item
278+
*/
279+
public static String getEnchantmentDisplayName(Enchantment enchantment, int level, String locale) {
280+
String name = getEnchantmentName(enchantment, locale);
281+
String enchLevel = getEnchantmentLevelName(level, locale);
282+
return name + (enchLevel.length() > 0 ? " " + enchLevel : "");
283+
}
284+
285+
/**
286+
* Return the display name of the enchantment(with level).
287+
*
288+
* @param entry The Entry of an enchantment with level The type is {@code Map.Entry<Enchantment, Integer>}
289+
* @param locale The language of the name
290+
* @return The name of the item
291+
*/
292+
public static String getEnchantmentDisplayName(Map.Entry<Enchantment, Integer> entry, String locale) {
293+
return getEnchantmentDisplayName(entry.getKey(), entry.getValue(), locale);
294+
}
295+
296+
/**
297+
* Return the display name of the enchantment(with level).
298+
*
299+
* @param entry The Entry of an enchantment with level The type is {@code Map.Entry<Enchantment, Integer>}
300+
* @param player The receiver of the name
301+
* @return The name of the item
302+
*/
303+
public static String getEnchantmentDisplayName(Map.Entry<Enchantment, Integer> entry, Player player) {
304+
return getEnchantmentDisplayName(entry.getKey(), entry.getValue(), player);
305+
}
306+
190307
/**
191308
* Translate unlocalized field to localized field.
192309
*
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/*
2+
* Copyright (c) 2015 Jerrell Fang
3+
*
4+
* This project is Open Source and distributed under The MIT License (MIT)
5+
* (http://opensource.org/licenses/MIT)
6+
*
7+
* You should have received a copy of the The MIT License along with
8+
* this project. If not, see <http://opensource.org/licenses/MIT>.
9+
*/
10+
11+
package com.meowj.langutils.lang.convert;
12+
13+
import org.bukkit.enchantments.Enchantment;
14+
15+
import java.util.EnumSet;
16+
import java.util.HashMap;
17+
import java.util.Map;
18+
19+
/**
20+
* This file is part of LanguageUtils
21+
* <p>
22+
* A list of enchantments.
23+
*
24+
* @author <b>hexosse</b> (<a href="https://github.com/hexosse">hexosse on GitHub</a>).
25+
*/
26+
public enum EnumEnchantment {
27+
28+
PROTECTION_ENVIRONMENTAL(Enchantment.PROTECTION_ENVIRONMENTAL, "enchantment.protect.all"),
29+
PROTECTION_FIRE(Enchantment.PROTECTION_FIRE, "enchantment.protect.fire"),
30+
PROTECTION_FALL(Enchantment.PROTECTION_FALL, "enchantment.protect.fall"),
31+
PROTECTION_EXPLOSIONS(Enchantment.PROTECTION_EXPLOSIONS, "enchantment.protect.explosion"),
32+
PROTECTION_PROJECTILE(Enchantment.PROTECTION_PROJECTILE, "enchantment.protect.projectile"),
33+
OXYGEN(Enchantment.OXYGEN, "enchantment.oxygen"),
34+
WATER_WORKER(Enchantment.WATER_WORKER, "enchantment.waterWorker"),
35+
THORNS(Enchantment.THORNS, "enchantment.thorns"),
36+
DAMAGE_ALL(Enchantment.DAMAGE_ALL, "enchantment.damage.all"),
37+
DAMAGE_UNDEAD(Enchantment.DAMAGE_UNDEAD, "enchantment.damage.undead"),
38+
DAMAGE_ARTHROPODS(Enchantment.DAMAGE_ARTHROPODS, "enchantment.damage.arthropods"),
39+
KNOCKBACK(Enchantment.KNOCKBACK, "enchantment.knockback"),
40+
FIRE_ASPECT(Enchantment.FIRE_ASPECT, "enchantment.fire"),
41+
LOOT_BONUS_MOBS(Enchantment.LOOT_BONUS_MOBS, "enchantment.lootBonus"),
42+
DIG_SPEED(Enchantment.DIG_SPEED, "enchantment.digging"),
43+
SILK_TOUCH(Enchantment.SILK_TOUCH, "enchantment.untouching"),
44+
DURABILITY(Enchantment.DURABILITY, "enchantment.durability"),
45+
LOOT_BONUS_BLOCKS(Enchantment.LOOT_BONUS_BLOCKS, "enchantment.lootBonusDigger"),
46+
ARROW_DAMAGE(Enchantment.ARROW_DAMAGE, "enchantment.arrowDamage"),
47+
ARROW_KNOCKBACK(Enchantment.ARROW_KNOCKBACK, "enchantment.arrowKnockback"),
48+
ARROW_FIRE(Enchantment.ARROW_FIRE, "enchantment.arrowFire"),
49+
ARROW_INFINITE(Enchantment.ARROW_INFINITE, "enchantment.arrowInfinite"),
50+
LUCK(Enchantment.LUCK, "enchantment.lootBonusFishing"),
51+
LURE(Enchantment.LURE, "enchantment.fishingSpeed");
52+
53+
/**
54+
* @return The {@link Enchantment} of the enchantment.
55+
*/
56+
public Enchantment getEnchantment() {
57+
return enchantment;
58+
}
59+
60+
/**
61+
* @return The unlocalized name of the enchantment.
62+
*/
63+
public String getUnlocalizedName() {
64+
return unlocalizedName;
65+
}
66+
67+
68+
/**
69+
* Create an index of enchantments.
70+
*/
71+
EnumEnchantment(Enchantment enchantment, String unlocalizedName) {
72+
this(enchantment, 0, unlocalizedName);
73+
}
74+
75+
/**
76+
* Create an index of enchantments.
77+
*/
78+
EnumEnchantment(Enchantment enchantment, int level, String unlocalizedName) {
79+
this.enchantment = enchantment;
80+
this.unlocalizedName = unlocalizedName;
81+
}
82+
83+
private static final Map<Enchantment, EnumEnchantment> lookup = new HashMap<Enchantment, EnumEnchantment>();
84+
85+
static {
86+
for (EnumEnchantment enchantment : EnumSet.allOf(EnumEnchantment.class))
87+
lookup.put(enchantment.enchantment, enchantment);
88+
}
89+
90+
/**
91+
* Get the index of an enchantment based on {@link EnumEnchantment}.
92+
*
93+
* @param enchantment The enchantment.
94+
* @return The index of the item.
95+
*/
96+
public static EnumEnchantment get(Enchantment enchantment) {
97+
return lookup.containsKey(enchantment) ? lookup.get(enchantment) : null;
98+
}
99+
100+
private Enchantment enchantment;
101+
private String unlocalizedName;
102+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Copyright (c) 2015 Hexosse
3+
*
4+
* This project is Open Source and distributed under The MIT License (MIT)
5+
* (http://opensource.org/licenses/MIT)
6+
*
7+
* You should have received a copy of the The MIT License along with
8+
* this project. If not, see <http://opensource.org/licenses/MIT>.
9+
*/
10+
11+
package com.meowj.langutils.lang.convert;
12+
13+
import java.util.EnumSet;
14+
import java.util.HashMap;
15+
import java.util.Map;
16+
17+
/**
18+
* This file is part of LanguageUtils
19+
* <p>
20+
* A list of enchantments level.
21+
*
22+
* @author <b>hexosse</b> (<a href="https://github.com/hexosse">hexosse on GitHub</a>).
23+
*/
24+
public enum EnumEnchantmentLevel {
25+
26+
LEVEL1(1, "enchantment.level.1"),
27+
LEVEL2(2, "enchantment.level.2"),
28+
LEVEL3(3, "enchantment.level.3"),
29+
LEVEL4(4, "enchantment.level.4"),
30+
LEVEL5(5, "enchantment.level.5"),
31+
LEVEL6(6, "enchantment.level.6"),
32+
LEVEL7(7, "enchantment.level.7"),
33+
LEVEL8(8, "enchantment.level.8"),
34+
LEVEL9(9, "enchantment.level.9"),
35+
LEVEL10(10, "enchantment.level.10"),;
36+
37+
/**
38+
* Create an index of enchantments.
39+
*/
40+
EnumEnchantmentLevel(int level, String unlocalizedName) {
41+
this.level = level;
42+
this.unlocalizedName = unlocalizedName;
43+
}
44+
45+
/**
46+
* @return Enchantment level
47+
*/
48+
public int getLevel() {
49+
return level;
50+
}
51+
52+
/**
53+
* @return The unlocalized name of the enchantment level
54+
*/
55+
public String getUnlocalizedName() {
56+
return unlocalizedName;
57+
}
58+
59+
private static final Map<Integer, EnumEnchantmentLevel> lookup = new HashMap<Integer, EnumEnchantmentLevel>();
60+
61+
static {
62+
for (EnumEnchantmentLevel level : EnumSet.allOf(EnumEnchantmentLevel.class))
63+
lookup.put(level.getLevel(), level);
64+
}
65+
66+
/**
67+
* @param level Enchantment level.
68+
* @return The index of a level.
69+
*/
70+
public static EnumEnchantmentLevel get(Integer level) {
71+
return lookup.containsKey(level) ? lookup.get(level) : null;
72+
}
73+
74+
private int level;
75+
private String unlocalizedName;
76+
}

src/main/resources/lang/af_ZA.lang

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
1+
enchantment.arrowDamage=Krag
2+
enchantment.arrowFire=Vuur
3+
enchantment.arrowInfinite=Oneindigheid
4+
enchantment.arrowKnockback=Moker
5+
enchantment.damage.all=Skerpheid
6+
enchantment.damage.arthropods=Verderwer van Geleedpotiges
7+
enchantment.damage.undead=Verslaning
8+
enchantment.digging=Doeltreffendheid
9+
enchantment.durability=Onbreekbare
10+
enchantment.fire=Vuur Aspek
11+
enchantment.fishingSpeed=Lokaas
12+
enchantment.knockback=Terugstoot
13+
enchantment.level.1=I
14+
enchantment.level.10=X
15+
enchantment.level.2=II
16+
enchantment.level.3=III
17+
enchantment.level.4=IV
18+
enchantment.level.5=V
19+
enchantment.level.6=VI
20+
enchantment.level.7=VII
21+
enchantment.level.8=VIII
22+
enchantment.level.9=IX
23+
enchantment.lootBonus=Plundering
24+
enchantment.lootBonusDigger=Geluk
25+
enchantment.lootBonusFishing=Geluk van die See
26+
enchantment.oxygen=Asemhaling
27+
enchantment.protect.all=Beskerming
28+
enchantment.protect.explosion=Ontploffings Beskerming
29+
enchantment.protect.fall=Gekussingde val
30+
enchantment.protect.fire=Brandbeskerming
31+
enchantment.protect.projectile=Projektiel Beskerming
32+
enchantment.thorns=Dorings
33+
enchantment.untouching=Sagte Aanraking
34+
enchantment.waterWorker=Waterwerking
135
entity.Arrow.name=pyl
236
entity.Bat.name=Vlêrmuis
337
entity.Blaze.name=Opvlammer

0 commit comments

Comments
 (0)