-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
375 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
dependencies { | ||
compileOnly project(":common") | ||
compileOnly "org.spigotmc:spigot:1.20-R0.1-SNAPSHOT" | ||
} |
112 changes: 112 additions & 0 deletions
112
nms/1_20_R1/src/main/java/ru/boomearo/langhelper/versions/Translate1_20_R1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package ru.boomearo.langhelper.versions; | ||
|
||
import com.google.common.base.Preconditions; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemLingeringPotion; | ||
import net.minecraft.world.item.ItemPotion; | ||
import net.minecraft.world.item.ItemSplashPotion; | ||
import net.minecraft.world.item.alchemy.PotionUtil; | ||
import org.bukkit.Material; | ||
import org.bukkit.block.Biome; | ||
import org.bukkit.craftbukkit.v1_20_R1.inventory.CraftItemStack; | ||
import org.bukkit.enchantments.Enchantment; | ||
import org.bukkit.entity.EntityType; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.plugin.Plugin; | ||
import org.bukkit.potion.PotionEffectType; | ||
import ru.boomearo.langhelper.managers.ConfigManager; | ||
|
||
import java.util.Locale; | ||
import java.util.logging.Level; | ||
|
||
public class Translate1_20_R1 extends JsonTranslateManager { | ||
|
||
public Translate1_20_R1(Plugin plugin, ConfigManager configManager) { | ||
super("1.20", plugin, configManager); | ||
} | ||
|
||
@Override | ||
public String getItemName(ItemStack item, LangType langType) { | ||
Preconditions.checkArgument(item != null); | ||
Preconditions.checkArgument(langType != null); | ||
|
||
try { | ||
net.minecraft.world.item.ItemStack itemStack = CraftItemStack.asNMSCopy(item); | ||
|
||
String name; | ||
Item i = itemStack.d(); | ||
if (i instanceof ItemSplashPotion) { | ||
name = "item.minecraft." + PotionUtil.d(itemStack).b("splash_potion.effect."); | ||
} else if (i instanceof ItemLingeringPotion) { | ||
name = "item.minecraft." + PotionUtil.d(itemStack).b("lingering_potion.effect."); | ||
} else if (i instanceof ItemPotion) { | ||
name = "item.minecraft." + PotionUtil.d(itemStack).b("potion.effect."); | ||
} else { | ||
name = i.a(); | ||
} | ||
|
||
if (item.getType() != Material.AIR) { | ||
if (name.equals("block.minecraft.air")) { | ||
return null; | ||
} | ||
} | ||
|
||
return getTranslate(name, langType); | ||
} catch (Exception e) { | ||
this.plugin.getLogger().log(Level.SEVERE, "Failed to get item name for " + item, e); | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public String getEntityName(EntityType entityType, LangType langType) { | ||
Preconditions.checkArgument(entityType != null); | ||
Preconditions.checkArgument(langType != null); | ||
|
||
return getTranslate("entity.minecraft." + entityType.getKey().getKey(), langType); | ||
} | ||
|
||
@Override | ||
public String getEnchantmentName(Enchantment enchant, LangType langType) { | ||
Preconditions.checkArgument(enchant != null); | ||
Preconditions.checkArgument(langType != null); | ||
|
||
return getTranslate("enchantment.minecraft." + enchant.getKey().getKey(), langType); | ||
} | ||
|
||
@Override | ||
public String getEnchantmentLevelName(int level, LangType langType) { | ||
Preconditions.checkArgument(langType != null); | ||
|
||
return getTranslate("enchantment.level." + level, langType); | ||
} | ||
|
||
@Override | ||
public String getPotionEffectName(PotionEffectType potionEffectType, LangType langType) { | ||
Preconditions.checkArgument(potionEffectType != null); | ||
Preconditions.checkArgument(langType != null); | ||
|
||
String effectName = switch (potionEffectType.getName().toLowerCase(Locale.ROOT)) { | ||
case "fast_digging" -> "haste"; | ||
case "harm" -> "instant_damage"; | ||
case "heal" -> "instant_health"; | ||
case "jump" -> "jump_boost"; | ||
case "slow_digging" -> "mining_fatigue"; | ||
case "confusion" -> "nausea"; | ||
case "damage_resistance" -> "resistance"; | ||
case "slow" -> "slowness"; | ||
case "increase_damage" -> "strength"; | ||
default -> potionEffectType.getName().toLowerCase(Locale.ROOT); | ||
}; | ||
String name = "effect.minecraft." + effectName; | ||
return getTranslate(name, langType); | ||
} | ||
|
||
@Override | ||
public String getBiomeName(Biome biome, LangType langType) { | ||
Preconditions.checkArgument(biome != null); | ||
Preconditions.checkArgument(langType != null); | ||
|
||
return getTranslate("biome.minecraft." + biome.name().toLowerCase(Locale.ROOT), langType); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
dependencies { | ||
compileOnly project(":common") | ||
compileOnly "org.spigotmc:spigot:1.20.2-R0.1-SNAPSHOT" | ||
} |
112 changes: 112 additions & 0 deletions
112
nms/1_20_R2/src/main/java/ru/boomearo/langhelper/versions/Translate1_20_R2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package ru.boomearo.langhelper.versions; | ||
|
||
import com.google.common.base.Preconditions; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemLingeringPotion; | ||
import net.minecraft.world.item.ItemPotion; | ||
import net.minecraft.world.item.ItemSplashPotion; | ||
import net.minecraft.world.item.alchemy.PotionUtil; | ||
import org.bukkit.Material; | ||
import org.bukkit.block.Biome; | ||
import org.bukkit.craftbukkit.v1_20_R2.inventory.CraftItemStack; | ||
import org.bukkit.enchantments.Enchantment; | ||
import org.bukkit.entity.EntityType; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.plugin.Plugin; | ||
import org.bukkit.potion.PotionEffectType; | ||
import ru.boomearo.langhelper.managers.ConfigManager; | ||
|
||
import java.util.Locale; | ||
import java.util.logging.Level; | ||
|
||
public class Translate1_20_R2 extends JsonTranslateManager { | ||
|
||
public Translate1_20_R2(Plugin plugin, ConfigManager configManager) { | ||
super("1.20.2", plugin, configManager); | ||
} | ||
|
||
@Override | ||
public String getItemName(ItemStack item, LangType langType) { | ||
Preconditions.checkArgument(item != null); | ||
Preconditions.checkArgument(langType != null); | ||
|
||
try { | ||
net.minecraft.world.item.ItemStack itemStack = CraftItemStack.asNMSCopy(item); | ||
|
||
String name; | ||
Item i = itemStack.d(); | ||
if (i instanceof ItemSplashPotion) { | ||
name = "item.minecraft." + PotionUtil.d(itemStack).b("splash_potion.effect."); | ||
} else if (i instanceof ItemLingeringPotion) { | ||
name = "item.minecraft." + PotionUtil.d(itemStack).b("lingering_potion.effect."); | ||
} else if (i instanceof ItemPotion) { | ||
name = "item.minecraft." + PotionUtil.d(itemStack).b("potion.effect."); | ||
} else { | ||
name = i.a(); | ||
} | ||
|
||
if (item.getType() != Material.AIR) { | ||
if (name.equals("block.minecraft.air")) { | ||
return null; | ||
} | ||
} | ||
|
||
return getTranslate(name, langType); | ||
} catch (Exception e) { | ||
this.plugin.getLogger().log(Level.SEVERE, "Failed to get item name for " + item, e); | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public String getEntityName(EntityType entityType, LangType langType) { | ||
Preconditions.checkArgument(entityType != null); | ||
Preconditions.checkArgument(langType != null); | ||
|
||
return getTranslate("entity.minecraft." + entityType.getKey().getKey(), langType); | ||
} | ||
|
||
@Override | ||
public String getEnchantmentName(Enchantment enchant, LangType langType) { | ||
Preconditions.checkArgument(enchant != null); | ||
Preconditions.checkArgument(langType != null); | ||
|
||
return getTranslate("enchantment.minecraft." + enchant.getKey().getKey(), langType); | ||
} | ||
|
||
@Override | ||
public String getEnchantmentLevelName(int level, LangType langType) { | ||
Preconditions.checkArgument(langType != null); | ||
|
||
return getTranslate("enchantment.level." + level, langType); | ||
} | ||
|
||
@Override | ||
public String getPotionEffectName(PotionEffectType potionEffectType, LangType langType) { | ||
Preconditions.checkArgument(potionEffectType != null); | ||
Preconditions.checkArgument(langType != null); | ||
|
||
String effectName = switch (potionEffectType.getName().toLowerCase(Locale.ROOT)) { | ||
case "fast_digging" -> "haste"; | ||
case "harm" -> "instant_damage"; | ||
case "heal" -> "instant_health"; | ||
case "jump" -> "jump_boost"; | ||
case "slow_digging" -> "mining_fatigue"; | ||
case "confusion" -> "nausea"; | ||
case "damage_resistance" -> "resistance"; | ||
case "slow" -> "slowness"; | ||
case "increase_damage" -> "strength"; | ||
default -> potionEffectType.getName().toLowerCase(Locale.ROOT); | ||
}; | ||
String name = "effect.minecraft." + effectName; | ||
return getTranslate(name, langType); | ||
} | ||
|
||
@Override | ||
public String getBiomeName(Biome biome, LangType langType) { | ||
Preconditions.checkArgument(biome != null); | ||
Preconditions.checkArgument(langType != null); | ||
|
||
return getTranslate("biome.minecraft." + biome.name().toLowerCase(Locale.ROOT), langType); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
dependencies { | ||
compileOnly project(":common") | ||
compileOnly "org.spigotmc:spigot:1.20.3-R0.1-SNAPSHOT" | ||
} |
112 changes: 112 additions & 0 deletions
112
nms/1_20_R3/src/main/java/ru/boomearo/langhelper/versions/Translate1_20_R3.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package ru.boomearo.langhelper.versions; | ||
|
||
import com.google.common.base.Preconditions; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemLingeringPotion; | ||
import net.minecraft.world.item.ItemPotion; | ||
import net.minecraft.world.item.ItemSplashPotion; | ||
import net.minecraft.world.item.alchemy.PotionUtil; | ||
import org.bukkit.Material; | ||
import org.bukkit.block.Biome; | ||
import org.bukkit.craftbukkit.v1_20_R3.inventory.CraftItemStack; | ||
import org.bukkit.enchantments.Enchantment; | ||
import org.bukkit.entity.EntityType; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.plugin.Plugin; | ||
import org.bukkit.potion.PotionEffectType; | ||
import ru.boomearo.langhelper.managers.ConfigManager; | ||
|
||
import java.util.Locale; | ||
import java.util.logging.Level; | ||
|
||
public class Translate1_20_R3 extends JsonTranslateManager { | ||
|
||
public Translate1_20_R3(Plugin plugin, ConfigManager configManager) { | ||
super("1.20.3", plugin, configManager); | ||
} | ||
|
||
@Override | ||
public String getItemName(ItemStack item, LangType langType) { | ||
Preconditions.checkArgument(item != null); | ||
Preconditions.checkArgument(langType != null); | ||
|
||
try { | ||
net.minecraft.world.item.ItemStack itemStack = CraftItemStack.asNMSCopy(item); | ||
|
||
String name; | ||
Item i = itemStack.d(); | ||
if (i instanceof ItemSplashPotion) { | ||
name = "item.minecraft." + PotionUtil.d(itemStack).b("splash_potion.effect."); | ||
} else if (i instanceof ItemLingeringPotion) { | ||
name = "item.minecraft." + PotionUtil.d(itemStack).b("lingering_potion.effect."); | ||
} else if (i instanceof ItemPotion) { | ||
name = "item.minecraft." + PotionUtil.d(itemStack).b("potion.effect."); | ||
} else { | ||
name = i.a(); | ||
} | ||
|
||
if (item.getType() != Material.AIR) { | ||
if (name.equals("block.minecraft.air")) { | ||
return null; | ||
} | ||
} | ||
|
||
return getTranslate(name, langType); | ||
} catch (Exception e) { | ||
this.plugin.getLogger().log(Level.SEVERE, "Failed to get item name for " + item, e); | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public String getEntityName(EntityType entityType, LangType langType) { | ||
Preconditions.checkArgument(entityType != null); | ||
Preconditions.checkArgument(langType != null); | ||
|
||
return getTranslate("entity.minecraft." + entityType.getKey().getKey(), langType); | ||
} | ||
|
||
@Override | ||
public String getEnchantmentName(Enchantment enchant, LangType langType) { | ||
Preconditions.checkArgument(enchant != null); | ||
Preconditions.checkArgument(langType != null); | ||
|
||
return getTranslate("enchantment.minecraft." + enchant.getKey().getKey(), langType); | ||
} | ||
|
||
@Override | ||
public String getEnchantmentLevelName(int level, LangType langType) { | ||
Preconditions.checkArgument(langType != null); | ||
|
||
return getTranslate("enchantment.level." + level, langType); | ||
} | ||
|
||
@Override | ||
public String getPotionEffectName(PotionEffectType potionEffectType, LangType langType) { | ||
Preconditions.checkArgument(potionEffectType != null); | ||
Preconditions.checkArgument(langType != null); | ||
|
||
String effectName = switch (potionEffectType.getName().toLowerCase(Locale.ROOT)) { | ||
case "fast_digging" -> "haste"; | ||
case "harm" -> "instant_damage"; | ||
case "heal" -> "instant_health"; | ||
case "jump" -> "jump_boost"; | ||
case "slow_digging" -> "mining_fatigue"; | ||
case "confusion" -> "nausea"; | ||
case "damage_resistance" -> "resistance"; | ||
case "slow" -> "slowness"; | ||
case "increase_damage" -> "strength"; | ||
default -> potionEffectType.getName().toLowerCase(Locale.ROOT); | ||
}; | ||
String name = "effect.minecraft." + effectName; | ||
return getTranslate(name, langType); | ||
} | ||
|
||
@Override | ||
public String getBiomeName(Biome biome, LangType langType) { | ||
Preconditions.checkArgument(biome != null); | ||
Preconditions.checkArgument(langType != null); | ||
|
||
return getTranslate("biome.minecraft." + biome.name().toLowerCase(Locale.ROOT), langType); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
dependencies { | ||
compileOnly project(":common") | ||
compileOnly "org.spigotmc:spigot:1.20.6-R0.1-SNAPSHOT" | ||
compileOnly "org.spigotmc:spigot:1.20.5-R0.1-SNAPSHOT" | ||
} |
Oops, something went wrong.