geforkt von Mirrors/Paper
Add translation keys to GameMode enum (#7081)
Dieser Commit ist enthalten in:
Ursprung
4810e202fe
Commit
d6784f22c1
@ -85,6 +85,38 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ // Paper end
|
+ // Paper end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
diff --git a/src/main/java/org/bukkit/GameMode.java b/src/main/java/org/bukkit/GameMode.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/GameMode.java
|
||||||
|
+++ b/src/main/java/org/bukkit/GameMode.java
|
||||||
|
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable;
|
||||||
|
* Represents the various type of game modes that {@link HumanEntity}s may
|
||||||
|
* have
|
||||||
|
*/
|
||||||
|
-public enum GameMode {
|
||||||
|
+public enum GameMode implements net.kyori.adventure.translation.Translatable { // Paper - implement Translatable
|
||||||
|
/**
|
||||||
|
* Creative mode may fly, build instantly, become invulnerable and create
|
||||||
|
* free items.
|
||||||
|
@@ -0,0 +0,0 @@ public enum GameMode {
|
||||||
|
|
||||||
|
private final int value;
|
||||||
|
private static final Map<Integer, GameMode> BY_ID = Maps.newHashMap();
|
||||||
|
+ // Paper start - translation keys
|
||||||
|
+ private final String translationKey;
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @org.jetbrains.annotations.NotNull String translationKey() {
|
||||||
|
+ return this.translationKey;
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
|
||||||
|
private GameMode(final int value) {
|
||||||
|
this.value = value;
|
||||||
|
+ this.translationKey = "gameMode." + this.name().toLowerCase(java.util.Locale.ENGLISH); // Paper
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
diff --git a/src/main/java/org/bukkit/GameRule.java b/src/main/java/org/bukkit/GameRule.java
|
diff --git a/src/main/java/org/bukkit/GameRule.java b/src/main/java/org/bukkit/GameRule.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
@ -85,8 +85,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
import net.minecraft.network.chat.TranslatableComponent;
|
import net.minecraft.network.chat.TranslatableComponent;
|
||||||
import net.minecraft.world.entity.player.ChatVisiblity;
|
import net.minecraft.world.entity.player.ChatVisiblity;
|
||||||
+import net.minecraft.world.item.CreativeModeTab;
|
+import net.minecraft.world.item.CreativeModeTab;
|
||||||
|
+import net.minecraft.world.level.GameType;
|
||||||
import org.bukkit.Difficulty;
|
import org.bukkit.Difficulty;
|
||||||
+import org.bukkit.FireworkEffect;
|
+import org.bukkit.FireworkEffect;
|
||||||
|
+import org.bukkit.GameMode;
|
||||||
+import org.bukkit.GameRule;
|
+import org.bukkit.GameRule;
|
||||||
+import org.bukkit.attribute.Attribute;
|
+import org.bukkit.attribute.Attribute;
|
||||||
+import org.bukkit.craftbukkit.inventory.CraftCreativeCategory;
|
+import org.bukkit.craftbukkit.inventory.CraftCreativeCategory;
|
||||||
@ -144,5 +146,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ CreativeCategory category = Objects.requireNonNull(CraftCreativeCategory.fromNMS(tab));
|
+ CreativeCategory category = Objects.requireNonNull(CraftCreativeCategory.fromNMS(tab));
|
||||||
+ Assert.assertEquals("translation key mismatch for " + category, ((TranslatableComponent) tab.getDisplayName()).getKey(), category.translationKey());
|
+ Assert.assertEquals("translation key mismatch for " + category, ((TranslatableComponent) tab.getDisplayName()).getKey(), category.translationKey());
|
||||||
+ }
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Test
|
||||||
|
+ public void testGameMode() {
|
||||||
|
+ for (GameType nms : GameType.values()) {
|
||||||
|
+ GameMode bukkit = GameMode.getByValue(nms.getId());
|
||||||
|
+ Assert.assertNotNull(bukkit);
|
||||||
|
+ Assert.assertEquals("translation key mismatch for " + bukkit, ((TranslatableComponent) nms.getLongDisplayName()).getKey(), bukkit.translationKey());
|
||||||
|
+ }
|
||||||
+ }
|
+ }
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren