Skip to content

Commit

Permalink
feat: add minecraft translation modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Citymonstret committed Jan 31, 2024
1 parent d5e7234 commit fe1a709
Show file tree
Hide file tree
Showing 13 changed files with 230 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cloud-translations-bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins {
id("cloud-translations.base-conventions")
id("cloud-translations.publishing-conventions")
}

dependencies {
api(projects.cloudTranslationsCore)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// MIT License
//
// Copyright (c) 2024 Incendo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
package org.incendo.cloud.translations.bukkit;

import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.incendo.cloud.CommandManager;
import org.incendo.cloud.caption.CaptionProvider;
import org.incendo.cloud.caption.CaptionRegistry;
import org.incendo.cloud.translations.LocaleExtractor;
import org.incendo.cloud.translations.TranslationBundle;

/**
* A bundle of Bukkit translations.
*
* <p>This can be registered to the command manager by accessing the caption registry using
* {@link CommandManager#captionRegistry()} and then registering the provider using
* {@link CaptionRegistry#registerProvider(CaptionProvider)}:
* <pre>{@code TranslationBundle<C> bundle = BukkitTranslationBundle.bukkit(sender -> sender.locale());
* manager.captionRegistry().registerProvider(translationBundle);}</pre>
*/
@API(status = API.Status.STABLE)
public final class BukkitTranslationBundle {

/**
* Returns the translation bundle for cloud-bukkit translations.
*
* @param <C> command sender type
* @param localeExtractor locale extractor
* @return the translation bundle
*/
public static <C> @NonNull TranslationBundle<C> bukkit(
final @NonNull LocaleExtractor<C> localeExtractor
) {
return TranslationBundle.resourceBundle("org.incendo.cloud.bukkit.lang.messages", localeExtractor);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* cloud-bukkit translations.
*/
package org.incendo.cloud.translations.bukkit;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
argument.parse.failure.enchantment='<input>' is not a valid enchantment
argument.parse.failure.material='<input>' is not a valid material name
argument.parse.failure.offlineplayer=No player found for input '<input>'
argument.parse.failure.player=No player found for input '<input>'
argument.parse.failure.world='<input>' is not a valid Minecraft world
argument.parse.failure.selector.unsupported=Entity selector argument type not supported below Minecraft 1.13.
argument.parse.failure.location.invalid_format='<input>' is not a valid location. Required format is '<x> <y> <z>'
argument.parse.failure.location.mixed_local_absolute=Cannot mix local and absolute coordinates. (either all coordinates use '^' or none do)
argument.parse.failure.namespacedkey.namespace=Invalid namespace '<input>'. Must be [a-z0-9._-]
argument.parse.failure.namespacedkey.key=Invalid key '<input>'. Must be [a-z0-9/._-]
argument.parse.failure.namespacedkey.need_namespace=Invalid input '<input>', requires an explicit namespace.
8 changes: 8 additions & 0 deletions cloud-translations-bungee/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins {
id("cloud-translations.base-conventions")
id("cloud-translations.publishing-conventions")
}

dependencies {
api(projects.cloudTranslationsCore)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// MIT License
//
// Copyright (c) 2024 Incendo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
package org.incendo.cloud.translations.bungee;

import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.incendo.cloud.CommandManager;
import org.incendo.cloud.caption.CaptionProvider;
import org.incendo.cloud.caption.CaptionRegistry;
import org.incendo.cloud.translations.LocaleExtractor;
import org.incendo.cloud.translations.TranslationBundle;

/**
* A bundle of Bungee translations.
*
* <p>This can be registered to the command manager by accessing the caption registry using
* {@link CommandManager#captionRegistry()} and then registering the provider using
* {@link CaptionRegistry#registerProvider(CaptionProvider)}:
* <pre>{@code TranslationBundle<C> bundle = BungeeTranslationBundle.bungee(sender -> sender.locale());
* manager.captionRegistry().registerProvider(translationBundle);}</pre>
*/
@API(status = API.Status.STABLE)
public final class BungeeTranslationBundle {

/**
* Returns the translation bundle for cloud-bungee translations.
*
* @param <C> command sender type
* @param localeExtractor locale extractor
* @return the translation bundle
*/
public static <C> @NonNull TranslationBundle<C> bungee(
final @NonNull LocaleExtractor<C> localeExtractor
) {
return TranslationBundle.resourceBundle("org.incendo.cloud.bukkit.lang.messages", localeExtractor);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* cloud-bungee translations.
*/
package org.incendo.cloud.translations.bungee;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
argument.parse.failure.player='<input>' is not a valid player
argument.parse.failure.server='<input>' is not a valid server
8 changes: 8 additions & 0 deletions cloud-translations-velocity/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins {
id("cloud-translations.base-conventions")
id("cloud-translations.publishing-conventions")
}

dependencies {
api(projects.cloudTranslationsCore)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// MIT License
//
// Copyright (c) 2024 Incendo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
package org.incendo.cloud.translations.velocity;

import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.incendo.cloud.CommandManager;
import org.incendo.cloud.caption.CaptionProvider;
import org.incendo.cloud.caption.CaptionRegistry;
import org.incendo.cloud.translations.LocaleExtractor;
import org.incendo.cloud.translations.TranslationBundle;

/**
* A bundle of Velocity translations.
*
* <p>This can be registered to the command manager by accessing the caption registry using
* {@link CommandManager#captionRegistry()} and then registering the provider using
* {@link CaptionRegistry#registerProvider(CaptionProvider)}:
* <pre>{@code TranslationBundle<C> bundle = VelocityTranslationBundle.velocity(sender -> sender.locale());
* manager.captionRegistry().registerProvider(translationBundle);}</pre>
*/
@API(status = API.Status.STABLE)
public final class VelocityTranslationBundle {

/**
* Returns the translation bundle for cloud-velocity translations.
*
* @param <C> command sender type
* @param localeExtractor locale extractor
* @return the translation bundle
*/
public static <C> @NonNull TranslationBundle<C> velocity(
final @NonNull LocaleExtractor<C> localeExtractor
) {
return TranslationBundle.resourceBundle("org.incendo.cloud.bukkit.lang.messages", localeExtractor);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* cloud-velocity translations.
*/
package org.incendo.cloud.translations.velocity;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
argument.parse.failure.player='<input>' is not a valid player
argument.parse.failure.server='<input>' is not a valid server
5 changes: 5 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,8 @@ dependencyResolutionManagement {
rootProject.name = "cloud-translations"

include(":cloud-translations-core")

// Minecraft modules
include(":cloud-translations-bukkit")
include(":cloud-translations-bungee")
include(":cloud-translations-velocity")

0 comments on commit fe1a709

Please sign in to comment.