Skip to content

GH-950 Single Global Language from Config, Remove Per-User and GUI #950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.eternalcode.core.feature.catboy.CatboyService;
import com.eternalcode.core.feature.home.HomeService;
import com.eternalcode.core.feature.jail.JailService;
import com.eternalcode.core.feature.language.LanguageService;
import com.eternalcode.core.feature.privatechat.PrivateChatService;
import com.eternalcode.core.feature.ignore.IgnoreService;
import com.eternalcode.core.feature.randomteleport.RandomTeleportService;
Expand All @@ -24,8 +23,6 @@ public interface EternalCoreApi {

JailService getJailService();

LanguageService getLanguageService();

PrivateChatService getPrivateChatService();

RandomTeleportService getRandomTeleportService();
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.eternalcode.core.feature.home.HomeService;
import com.eternalcode.core.feature.ignore.IgnoreService;
import com.eternalcode.core.feature.jail.JailService;
import com.eternalcode.core.feature.language.LanguageService;
import com.eternalcode.core.feature.privatechat.PrivateChatService;
import com.eternalcode.core.feature.randomteleport.RandomTeleportService;
import com.eternalcode.core.feature.spawn.SpawnService;
Expand Down Expand Up @@ -46,11 +45,6 @@ public JailService getJailService() {
return this.dependencyProvider.getDependency(JailService.class);
}

@Override
public LanguageService getLanguageService() {
return this.dependencyProvider.getDependency(LanguageService.class);
}

@Override
public PrivateChatService getPrivateChatService() {
return this.dependencyProvider.getDependency(PrivateChatService.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.eternalcode.core.bridge.litecommand.argument;

import com.eternalcode.core.feature.language.Language;
import com.eternalcode.core.translation.Translation;
import com.eternalcode.core.translation.TranslationManager;
import dev.rollczi.litecommands.argument.Argument;
Expand All @@ -21,11 +20,11 @@ protected AbstractViewerArgument(TranslationManager translationManager) {
@Override
protected ParseResult<T> parse(Invocation<CommandSender> invocation, Argument<T> context, String argument) {
if (invocation.sender() instanceof Player player) {
Translation translation = this.translationManager.getMessages(player.getUniqueId());
Translation translation = this.translationManager.getMessages();
return this.parse(invocation, argument, translation);
}

Translation translation = this.translationManager.getMessages(Language.DEFAULT);
Translation translation = this.translationManager.getMessages();
return this.parse(invocation, argument, translation);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public ContextResult<Player> provide(Invocation<CommandSender> invocation) {
return ContextResult.ok(() -> player);
}

Translation translation = this.translationManager.getDefaultMessages();
Translation translation = this.translationManager.getMessages();
Notice onlyPlayer = translation.argument().onlyPlayer();

return ContextResult.error(onlyPlayer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ContextResult<User> provide(Invocation<CommandSender> invocation) {
.orElseThrow(() -> new IllegalStateException("Player " + player.getName() + " is not registered!")));
}

Translation translation = this.translationManager.getDefaultMessages();
Translation translation = this.translationManager.getMessages();
Notice onlyPlayer = translation.argument().onlyPlayer();

return ContextResult.error(onlyPlayer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.eternalcode.core.configuration.composer.LanguageComposer;
import com.eternalcode.core.configuration.composer.PositionComposer;
import com.eternalcode.core.configuration.composer.SetComposer;
import com.eternalcode.core.feature.language.Language;
import com.eternalcode.core.translation.Language;
import com.eternalcode.core.injector.annotations.Inject;
import com.eternalcode.core.injector.annotations.component.Service;
import com.eternalcode.core.publish.Publisher;
Expand All @@ -21,7 +21,6 @@
import net.dzikoysk.cdn.CdnFactory;
import net.dzikoysk.cdn.CdnSettings;
import net.dzikoysk.cdn.reflect.Visibility;
import org.bukkit.Sound;

@Service
public class ConfigurationManager {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.eternalcode.core.configuration.composer;

import com.eternalcode.core.feature.language.Language;
import com.eternalcode.core.translation.Language;
import panda.std.Result;
import panda.utilities.text.Joiner;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public class PluginConfiguration implements ReloadableConfig {
@Description("# Whether the player should receive information about new plugin updates upon joining the server")
public boolean shouldReceivePluginUpdates = true;

@Description("# Language, currently supported languages: en, pl")
public String language = "en";

@Description({ " ", "# Database Section" })
public Database database = new Database();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void onAfkSwitch(AfkSwitchEvent event) {
}

User user = this.userManager.getOrCreate(playerUUID, player.getName());
Translation translation = this.translationManager.getMessages(user.getUniqueId());
Translation translation = this.translationManager.getMessages();

Component component = this.miniMessage.deserialize(translation.afk().afkKickReason());
player.kickPlayer(legacySection().serialize(component));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void setUpPlaceholders(PlaceholderRegistry placeholderRegistry, AfkService afkSe
placeholderRegistry.registerPlaceholder(PlaceholderReplacer.of(
"afk_formatted",
player -> {
Translation messages = this.translationManager.getMessages(player.getUniqueId());
Translation messages = this.translationManager.getMessages();
return afkService.isAfk(player.getUniqueId()) ?
messages.afk().afkEnabledPlaceholder() : messages.afk().afkDisabledPlaceholder();
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DisposalCommand {
@Execute
@DescriptionDocs(description = "Opens a disposal")
void execute(@Context Player player) {
Translation translation = this.translationManager.getMessages(player.getUniqueId());
Translation translation = this.translationManager.getMessages();
Component component = this.miniMessage.deserialize(translation.inventory().disposalTitle());
String serialize = AdventureUtil.SECTION_SERIALIZER.serialize(component);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ private String getServerFullMessage(Player player) {

if (userOption.isEmpty()) {
return Joiner.on("\n")
.join(this.translationManager.getDefaultMessages().player().fullServerSlots())
.join(this.translationManager.getMessages().player().fullServerSlots())
.toString();
}

User user = userOption.get();

return Joiner.on("\n")
.join(this.translationManager.getMessages(user.getUniqueId()).player().fullServerSlots())
.join(this.translationManager.getMessages().player().fullServerSlots())
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static String homesLeft(int homesLimit, int amountOfHomes) {

private String ownedHomes(Player targetPlayer) {
Collection<Home> homes = this.homeService.getHomes(targetPlayer.getUniqueId());
Translation translation = this.translationManager.getMessages(targetPlayer.getUniqueId());
Translation translation = this.translationManager.getMessages();

if (homes.isEmpty()) {
return translation.home().noHomesOwnedPlaceholder();
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading