mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@3fc9358 Show stacktrace when modifyItemStack fails PaperMC/Paper@f175193 Expose server build information (#10729)
This commit is contained in:
@@ -1,72 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MelnCat <melncatuwu@gmail.com>
|
||||
Date: Sat, 1 Oct 2022 17:08:23 -0700
|
||||
Subject: [PATCH] Language API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/language/Language.java b/src/main/java/org/purpurmc/purpur/language/Language.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..38483d908ed830e97883733bee2370f87060f4c7
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/language/Language.java
|
||||
@@ -0,0 +1,60 @@
|
||||
+package org.purpurmc.purpur.language;
|
||||
+
|
||||
+import net.kyori.adventure.translation.Translatable;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * Represents a language that can translate translation keys
|
||||
+ */
|
||||
+public abstract class Language {
|
||||
+ private static Language language;
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the default language of the server
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public static Language getLanguage() {
|
||||
+ return language;
|
||||
+ }
|
||||
+
|
||||
+ public static void setLanguage(@NotNull Language language) {
|
||||
+ if (Language.language != null) {
|
||||
+ throw new UnsupportedOperationException("Cannot redefine singleton Language");
|
||||
+ }
|
||||
+ Language.language = language;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Checks if a certain translation key is translatable with this language
|
||||
+ * @param key The translation key
|
||||
+ * @return Whether this language can translate the key
|
||||
+ */
|
||||
+ abstract public boolean has(@NotNull String key);
|
||||
+
|
||||
+ /**
|
||||
+ * Checks if a certain translation key is translatable with this language
|
||||
+ * @param key The translation key
|
||||
+ * @return Whether this language can translate the key
|
||||
+ */
|
||||
+ public boolean has(@NotNull Translatable key) {
|
||||
+ return has(key.translationKey());
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Translates a translation key to this language
|
||||
+ * @param key The translation key
|
||||
+ * @return The translated key, or the translation key if it couldn't be translated
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ abstract public String getOrDefault(@NotNull String key);
|
||||
+
|
||||
+ /**
|
||||
+ * Translates a translation key to this language
|
||||
+ * @param key The translation key
|
||||
+ * @return The translated key, or the translation key if it couldn't be translated
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public String getOrDefault(@NotNull Translatable key) {
|
||||
+ return getOrDefault(key.translationKey());
|
||||
+ }
|
||||
+}
|
||||
Reference in New Issue
Block a user