From 0005a0fdbfb84c521fee4275b53b72538aaf3764 Mon Sep 17 00:00:00 2001 From: phinner <62483793+phinner@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:49:58 +0100 Subject: [PATCH 01/11] chore: Prepare 4.1 --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 1c92d714..ed3bd765 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,7 +2,7 @@ plugins { id("distributor.parent-conventions") } -version = "4.0.2" + if (indraGit.headTag() == null) "-SNAPSHOT" else "" +version = "4.1.0" + if (indraGit.headTag() == null) "-SNAPSHOT" else "" group = "com.xpdustry" description = "The Mindustry plugin of ur dreams..." From 0cb9ceb99f61928f5acff453ec82ecd09eb19867 Mon Sep 17 00:00:00 2001 From: phinner <62483793+phinner@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:50:17 +0100 Subject: [PATCH 02/11] feat: Added WindowManager#getActiveWindow --- .../distributor/api/gui/WindowManager.java | 16 ++++++++++++++++ .../AbstractTransformerWindowManager.java | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/WindowManager.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/WindowManager.java index f8bb6380..e3a4839e 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/WindowManager.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/WindowManager.java @@ -18,8 +18,10 @@ */ package com.xpdustry.distributor.api.gui; +import com.xpdustry.distributor.api.player.MUUID; import java.util.Collection; import mindustry.gen.Player; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A factory creating {@link Window} instances. @@ -47,6 +49,20 @@ public interface WindowManager { */ Collection getActiveWindows(); + /** + * Returns the active window of the given viewer. + * + * @param viewer the viewer + * @return the active window + */ + default @Nullable Window getActiveWindow(final Player viewer) { + final var target = MUUID.from(viewer); + return getActiveWindows().stream() + .filter(window -> MUUID.from(window.getViewer()).equals(target)) + .findFirst() + .orElse(null); + } + /** * Disposes this window manager. */ diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/transform/AbstractTransformerWindowManager.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/transform/AbstractTransformerWindowManager.java index 7f5dd463..95ea247b 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/transform/AbstractTransformerWindowManager.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/transform/AbstractTransformerWindowManager.java @@ -87,6 +87,11 @@ public final Collection getActiveWindows() { return Collections.unmodifiableCollection(this.windows.values()); } + @Override + public @Nullable Window getActiveWindow(final Player viewer) { + return windows.get(MUUID.from(viewer)); + } + @Override public final void addTransformer(final Transformer

transformer) { transformers.add(Objects.requireNonNull(transformer)); From b8593713ebb1f74b618330571c74551669f11c96 Mon Sep 17 00:00:00 2001 From: phinner <62483793+phinner@users.noreply.github.com> Date: Wed, 25 Dec 2024 17:15:48 +0100 Subject: [PATCH 03/11] feat: Added ComponentAccumulator --- .../render/ComponentAccumulator.java | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/ComponentAccumulator.java diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/ComponentAccumulator.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/ComponentAccumulator.java new file mode 100644 index 00000000..fe43c926 --- /dev/null +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/ComponentAccumulator.java @@ -0,0 +1,84 @@ +/* + * Distributor, a feature-rich framework for Mindustry plugins. + * + * Copyright (C) 2024 Xpdustry + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.xpdustry.distributor.api.component.render; + +import com.xpdustry.distributor.api.component.Component; +import com.xpdustry.distributor.api.key.KeyContainer; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import org.checkerframework.checker.nullness.qual.Nullable; + +import static com.xpdustry.distributor.api.component.TextComponent.text; + +/** + * A special {@link ComponentStringBuilder} that does not build a string with its appended elements. + * Instead, they are accumulated in a freely accessible list. + */ +public final class ComponentAccumulator implements ComponentStringBuilder { + + /** + * Creates a new {@link ComponentAccumulator} instance. + */ + public static ComponentAccumulator create() { + return new ComponentAccumulator(); + } + + private final List components = new ArrayList<>(); + + ComponentAccumulator() {} + + /** + * Returns an immutable view of the accumulated components. + */ + public List getComponents() { + return Collections.unmodifiableList(components); + } + + @Override + public KeyContainer getContext() { + return KeyContainer.empty(); + } + + @Override + public ComponentAccumulator append(final Component component) { + this.components.add(component); + return this; + } + + @Override + public ComponentAccumulator append(final @Nullable CharSequence csq) { + return append(text(csq == null ? "null" : csq.toString())); + } + + @Override + public ComponentAccumulator append(final @Nullable CharSequence csq, final int start, final int end) { + return append(text(csq == null ? "null" : csq.subSequence(start, end).toString())); + } + + @Override + public ComponentAccumulator append(final char c) { + return append(text(c)); + } + + @Override + public String toString() { + return "CompCompStringBuilder{" + "components=" + this.components + '}'; + } +} From b43d4d2a8d6713a82f7313b8761a5c001b715b61 Mon Sep 17 00:00:00 2001 From: phinner <62483793+phinner@users.noreply.github.com> Date: Wed, 25 Dec 2024 17:16:49 +0100 Subject: [PATCH 04/11] feat: Added Translation#formatAsComponent and deprecated Translation#formatTo --- .../MessageFormatTranslationImpl.java | 2 +- .../api/translation/Translation.java | 23 ++++++++++++++++--- .../StandardComponentRendererProvider.java | 4 ++-- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/MessageFormatTranslationImpl.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/MessageFormatTranslationImpl.java index a811d65c..54778c05 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/MessageFormatTranslationImpl.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/MessageFormatTranslationImpl.java @@ -59,7 +59,7 @@ public String format(final TranslationArguments parameters) { return createFormat().format(getArguments(parameters).toArray()); } - @SuppressWarnings("JdkObsolete") + @SuppressWarnings({"JdkObsolete", "removal"}) @Override public void formatTo(final TranslationArguments parameters, final ComponentStringBuilder builder) { final var format = createFormat(); diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/Translation.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/Translation.java index a69f3abc..fda89b3b 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/Translation.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/Translation.java @@ -18,6 +18,9 @@ */ package com.xpdustry.distributor.api.translation; +import com.xpdustry.distributor.api.component.Component; +import com.xpdustry.distributor.api.component.ListComponent; +import com.xpdustry.distributor.api.component.render.ComponentAccumulator; import com.xpdustry.distributor.api.component.render.ComponentStringBuilder; /** @@ -26,20 +29,34 @@ public interface Translation { /** - * Formats the translation with the given parameters. + * Formats the translation with the given parameters and return a string. * * @param parameters the translation parameters - * @return the formatted translation + * @return the formatted translation as a string */ String format(final TranslationArguments parameters); + /** + * Formats the translation with the given parameters and return a component. + * + * @param parameters the translation parameters + * @return the formatted translation as a component + */ + default Component formatAsComponent(final TranslationArguments parameters) { + final var accumulator = ComponentAccumulator.create(); + this.formatTo(parameters, accumulator); + return ListComponent.components(accumulator.getComponents()); + } + /** * Formats the translation to the given {@link ComponentStringBuilder}. * * @param parameters the translation parameters * @param builder the builder + * @deprecated This method has been replaced by {@link #formatAsComponent(TranslationArguments)}. */ + @Deprecated(since = "4.1", forRemoval = true) default void formatTo(final TranslationArguments parameters, final ComponentStringBuilder builder) { - builder.append(format(parameters)); + builder.append(this.format(parameters)); } } diff --git a/distributor-common/src/main/java/com/xpdustry/distributor/common/component/render/StandardComponentRendererProvider.java b/distributor-common/src/main/java/com/xpdustry/distributor/common/component/render/StandardComponentRendererProvider.java index c9ebb4ec..64de7ecc 100644 --- a/distributor-common/src/main/java/com/xpdustry/distributor/common/component/render/StandardComponentRendererProvider.java +++ b/distributor-common/src/main/java/com/xpdustry/distributor/common/component/render/StandardComponentRendererProvider.java @@ -103,14 +103,14 @@ private static final class TranslatableComponentRenderer implements ComponentRen @Override public void render(final TranslatableComponent component, final ComponentStringBuilder builder) { - Distributor.get() + builder.append(Distributor.get() .getGlobalTranslationSource() .getTranslationOrMissing( component.getKey(), builder.getContext() .getOptional(StandardKeys.LOCALE) .orElseGet(Locale::getDefault)) - .formatTo(component.getParameters(), builder); + .formatAsComponent(component.getParameters())); } } From 1e334c2f6a09f17d0552fdf1e432e763cdb5ea1f Mon Sep 17 00:00:00 2001 From: phinner <62483793+phinner@users.noreply.github.com> Date: Wed, 25 Dec 2024 17:17:39 +0100 Subject: [PATCH 05/11] feat: Added DescriptionFacade#getComponent --- .../api/command/DescriptionFacade.java | 21 +++++++++++++- .../command/TranslatedDescriptionFacade.java | 29 ++++++++++++++----- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/command/DescriptionFacade.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/command/DescriptionFacade.java index 7ad7c060..0a6f48b7 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/command/DescriptionFacade.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/command/DescriptionFacade.java @@ -18,6 +18,8 @@ */ package com.xpdustry.distributor.api.command; +import com.xpdustry.distributor.api.Distributor; +import com.xpdustry.distributor.api.component.Component; import com.xpdustry.distributor.internal.annotation.DistributorDataClass; import java.util.Locale; import org.immutables.value.Value; @@ -59,7 +61,7 @@ static DescriptionFacade translated(final String key, final Locale defaultLocale String getText(); /** - * Returns the description text for the given locale holder. + * Returns the description text for the given command sender. * * @param sender the command sender * @return the description text @@ -68,6 +70,23 @@ default String getText(final CommandSender sender) { return this.getText(); } + /** + * Returns the description text as a {@link Component}. + */ + default Component getComponent() { + return Distributor.get().getMindustryComponentDecoder().decode(this.getText()); + } + + /** + * Returns the description text as a {@link Component} for the given command sender. + * + * @param sender the command sender + * @return the description {@link Component} + */ + default Component getComponent(final CommandSender sender) { + return Distributor.get().getMindustryComponentDecoder().decode(this.getText(sender)); + } + /** * Returns whether this description is empty. */ diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/command/TranslatedDescriptionFacade.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/command/TranslatedDescriptionFacade.java index 080841ee..f50ebc92 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/command/TranslatedDescriptionFacade.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/command/TranslatedDescriptionFacade.java @@ -19,25 +19,32 @@ package com.xpdustry.distributor.api.command; import com.xpdustry.distributor.api.Distributor; +import com.xpdustry.distributor.api.component.Component; +import com.xpdustry.distributor.api.translation.Translation; import com.xpdustry.distributor.api.translation.TranslationArguments; import java.util.Locale; +import org.checkerframework.checker.nullness.qual.Nullable; record TranslatedDescriptionFacade(String key, Locale defaultLocale) implements DescriptionFacade { @Override public String getText() { - return Distributor.get() - .getGlobalTranslationSource() - .getTranslationOrMissing(key, this.defaultLocale) - .format(TranslationArguments.empty()); + return getTranslation(null).format(TranslationArguments.empty()); } @Override public String getText(final CommandSender sender) { - return Distributor.get() - .getGlobalTranslationSource() - .getTranslationOrMissing(key, sender.getLocale()) - .format(TranslationArguments.empty()); + return getTranslation(sender).format(TranslationArguments.empty()); + } + + @Override + public Component getComponent() { + return getTranslation(null).formatAsComponent(TranslationArguments.empty()); + } + + @Override + public Component getComponent(final CommandSender sender) { + return getTranslation(sender).formatAsComponent(TranslationArguments.empty()); } @Override @@ -49,4 +56,10 @@ public boolean isEmpty() { public boolean isEmpty(final CommandSender sender) { return Distributor.get().getGlobalTranslationSource().getTranslation(key, sender.getLocale()) == null; } + + private Translation getTranslation(final @Nullable CommandSender sender) { + return Distributor.get() + .getGlobalTranslationSource() + .getTranslationOrMissing(key, sender != null ? sender.getLocale() : this.defaultLocale); + } } From 71d1c5b91d3307584d9866c2694291017e7614bd Mon Sep 17 00:00:00 2001 From: phinner <62483793+phinner@users.noreply.github.com> Date: Wed, 25 Dec 2024 17:27:43 +0100 Subject: [PATCH 06/11] chore: Fix typo in CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13d5244c..96447c85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,7 +30,7 @@ Javadocs are mostly done, the wiki is next. Final beta release. All major feature I wanted for distributor 4 have been implemented. -It is now time to use it in more production plugins to asses the usability of the new APIs. +It is now time to use it in more production plugins to assess the usability of the new APIs. ## v4.0.0-beta.2 - 2024-04-08 From 79fb0558f4af073a5505b6204de969ccca4e91b1 Mon Sep 17 00:00:00 2001 From: phinner <62483793+phinner@users.noreply.github.com> Date: Wed, 25 Dec 2024 17:29:34 +0100 Subject: [PATCH 07/11] chore: Add missing "this" --- .../api/command/cloud/CloudCommandFacade.java | 20 +++--- .../cloud/MindustryCommandManager.java | 10 +-- .../command/cloud/parser/ContentParser.java | 8 +-- .../api/command/cloud/parser/TeamParser.java | 2 +- .../annotation/MethodAnnotationProcessor.java | 2 +- .../distributor/api/audience/Audience.java | 4 +- .../api/audience/ForwardingAudience.java | 24 +++---- .../api/collection/MindustryList.java | 2 +- .../api/collection/MindustryMap.java | 10 +-- .../api/collection/MindustrySet.java | 6 +- .../api/command/MindustryCommandFacade.java | 10 +-- .../api/command/PlayerCommandSender.java | 4 +- .../api/command/ServerCommandSender.java | 4 +- .../command/TranslatedDescriptionFacade.java | 14 ++-- .../api/component/ListComponent.java | 2 +- .../api/component/ListComponentImpl.java | 4 +- .../api/component/NumberComponentImpl.java | 6 +- .../api/component/TemporalComponentImpl.java | 6 +- .../api/component/TextComponentImpl.java | 4 +- .../component/TranslatableComponentImpl.java | 2 +- .../render/AnsiComponentStringBuilder.java | 66 ++++++++++--------- .../render/ComponentAccumulator.java | 9 +-- .../MindustryComponentStringBuilder.java | 28 ++++---- .../render/PlainComponentStringBuilder.java | 2 +- .../api/component/style/ComponentColor.java | 6 +- .../api/component/style/TextStyle.java | 4 +- .../api/component/style/TextStyleImpl.java | 12 ++-- .../xpdustry/distributor/api/gui/Action.java | 6 +- .../distributor/api/gui/DisplayUnit.java | 2 +- .../distributor/api/gui/WindowManager.java | 2 +- .../api/gui/input/TextInputManagerImpl.java | 14 ++-- .../api/gui/input/TextInputPane.java | 8 ++- .../api/gui/input/TextInputPaneImpl.java | 27 ++++---- .../api/gui/menu/ListTransformer.java | 49 +++++++------- .../distributor/api/gui/menu/MenuGrid.java | 4 +- .../api/gui/menu/MenuGridImpl.java | 30 ++++----- .../api/gui/menu/MenuManagerImpl.java | 16 ++--- .../distributor/api/gui/menu/MenuPane.java | 4 +- .../api/gui/menu/MenuPaneImpl.java | 26 ++++---- .../api/gui/popup/PopupManagerImpl.java | 14 ++-- .../distributor/api/gui/popup/PopupPane.java | 2 +- .../api/gui/popup/PopupPaneImpl.java | 10 +-- .../AbstractTransformerWindowManager.java | 42 ++++++------ .../api/key/DynamicKeyContainerImpl.java | 10 +-- .../api/key/ImmutableKeyContainer.java | 2 +- .../api/key/MutableKeyContainerImpl.java | 10 +-- .../api/key/SettingsKeyContainer.java | 14 ++-- .../permission/ImmutablePermissionTree.java | 4 +- .../api/permission/MutablePermissionTree.java | 10 +-- .../permission/MutablePermissionTreeImpl.java | 4 +- .../distributor/api/player/MUUID.java | 6 +- .../distributor/api/player/PlayerLookup.java | 6 +- .../api/plugin/AbstractMindustryPlugin.java | 5 +- .../api/plugin/WrappingMindustryPlugin.java | 2 +- .../distributor/api/scheduler/PluginTask.java | 6 +- .../MessageFormatTranslationImpl.java | 14 ++-- .../api/translation/ResourceBundles.java | 2 +- .../translation/RouterTranslationSource.java | 2 +- .../api/translation/TranslationSource.java | 4 +- .../distributor/api/util/TypeToken.java | 6 +- .../annotation/EventHandlerProcessorTest.java | 2 +- .../annotation/TaskHandlerProcessorTest.java | 18 ++--- .../TriggerHandlerProcessorTest.java | 2 +- .../component/TranslatableComponentTest.java | 2 +- .../MindustryComponentStringBuilderTest.java | 24 +++---- .../api/player/SimplePlayerLookupTest.java | 24 +++---- .../distributor/api/test/ManageScheduler.java | 14 ++-- .../BundleTranslationSourceImplTest.java | 6 +- .../common/DistributorCommonPlugin.java | 18 ++--- .../common/audience/AudienceProviderImpl.java | 31 ++++----- .../audience/BaseNetConnectionAudience.java | 22 ++++--- .../common/audience/PlayerAudienceImpl.java | 4 +- .../common/audience/ServerAudience.java | 10 +-- .../component/codec/MindustryDecoderImpl.java | 2 +- .../ServiceComponentRendererProvider.java | 2 +- .../codec/MindustryDecoderImplTest.java | 24 +++---- .../permission/rank/LinearEnumRankNode.java | 4 +- .../rank/YamlRankPermissionSource.java | 8 +-- .../api/permission/rank/CircularRankNode.java | 4 +- .../rank/RankPermissionReaderTest.java | 2 +- .../rank/YamlRankPermissionSourceTest.java | 6 +- 81 files changed, 437 insertions(+), 426 deletions(-) diff --git a/distributor-command-cloud/src/main/java/com/xpdustry/distributor/api/command/cloud/CloudCommandFacade.java b/distributor-command-cloud/src/main/java/com/xpdustry/distributor/api/command/cloud/CloudCommandFacade.java index cd86febf..eac01b96 100644 --- a/distributor-command-cloud/src/main/java/com/xpdustry/distributor/api/command/cloud/CloudCommandFacade.java +++ b/distributor-command-cloud/src/main/java/com/xpdustry/distributor/api/command/cloud/CloudCommandFacade.java @@ -74,7 +74,7 @@ public String getName() { @Override public DescriptionFacade getDescription() { - return descriptionFacade; + return this.descriptionFacade; } @Override @@ -84,17 +84,19 @@ public boolean isAlias() { @Override public boolean isVisible(final CommandSender sender) { - final var mapped = manager.senderMapper().map(sender); - return manager.commands().stream() - .anyMatch(command -> command.rootComponent().name().equalsIgnoreCase(realName) - && manager.testPermission(mapped, command.commandPermission()) + final var mapped = this.manager.senderMapper().map(sender); + return this.manager.commands().stream() + .anyMatch(command -> command.rootComponent().name().equalsIgnoreCase(this.realName) + && this.manager + .testPermission(mapped, command.commandPermission()) .allowed()); } @Override public CommandHelp getHelp(final CommandSender sender, final String query) { - final var mapped = manager.senderMapper().map(sender); - final var result = manager.createHelpHandler().query(HelpQuery.of(mapped, getRealName() + " " + query)); + final var mapped = this.manager.senderMapper().map(sender); + final var result = + this.manager.createHelpHandler().query(HelpQuery.of(mapped, this.getRealName() + " " + query)); if (result instanceof MultipleCommandResult multi) { return CommandHelp.Suggestion.of(multi.longestPath(), multi.childSuggestions()); } else if (result instanceof VerboseCommandResult verbose) { @@ -107,8 +109,8 @@ public CommandHelp getHelp(final CommandSender sender, final String query) { this.manager .descriptionMapper() .map(command.commandDescription().verboseDescription()), - getArguments(command), - getFlags(command)); + this.getArguments(command), + this.getFlags(command)); } else { return CommandHelp.Empty.of(); } diff --git a/distributor-command-cloud/src/main/java/com/xpdustry/distributor/api/command/cloud/MindustryCommandManager.java b/distributor-command-cloud/src/main/java/com/xpdustry/distributor/api/command/cloud/MindustryCommandManager.java index 97c1889c..b7b970f0 100644 --- a/distributor-command-cloud/src/main/java/com/xpdustry/distributor/api/command/cloud/MindustryCommandManager.java +++ b/distributor-command-cloud/src/main/java/com/xpdustry/distributor/api/command/cloud/MindustryCommandManager.java @@ -102,8 +102,8 @@ public MindustryCommandManager( this.captionRegistry() .registerProvider( - createCaptionProviderFromSource(Distributor.get().getGlobalTranslationSource())) - .registerProvider(createCaptionProviderFromSource(DEFAULT_TRANSLATION_SOURCE)); + this.createCaptionProviderFromSource(Distributor.get().getGlobalTranslationSource())) + .registerProvider(this.createCaptionProviderFromSource(DEFAULT_TRANSLATION_SOURCE)); this.parserRegistry().registerParser(PlayerParser.playerParser()); this.parserRegistry().registerParser(TeamParser.teamParser()); @@ -152,7 +152,7 @@ public final void descriptionMapper(final DescriptionMapper descrip @Override public boolean hasPermission(final @NonNull C sender, final String permission) { return permission.isEmpty() - || senderMapper() + || this.senderMapper() .reverse(sender) .getPermissions() .getPermission(permission) @@ -176,11 +176,11 @@ protected void registerDefaultExceptionHandlers() { this.registerDefaultExceptionHandlers( triplet -> { final var context = triplet.first(); - senderMapper() + this.senderMapper() .reverse(context.sender()) .error(context.formatCaption(triplet.second(), triplet.third())); }, - pair -> logger.error(pair.first(), pair.second())); + pair -> this.logger.error(pair.first(), pair.second())); } private CaptionProvider createCaptionProviderFromSource(final TranslationSource source) { diff --git a/distributor-command-cloud/src/main/java/com/xpdustry/distributor/api/command/cloud/parser/ContentParser.java b/distributor-command-cloud/src/main/java/com/xpdustry/distributor/api/command/cloud/parser/ContentParser.java index b04401fa..3c197f78 100644 --- a/distributor-command-cloud/src/main/java/com/xpdustry/distributor/api/command/cloud/parser/ContentParser.java +++ b/distributor-command-cloud/src/main/java/com/xpdustry/distributor/api/command/cloud/parser/ContentParser.java @@ -62,9 +62,9 @@ public ContentParser(final CTypeKey contentType) { @Override public ArgumentParseResult parse(final CommandContext ctx, final CommandInput input) { final var name = input.readString().toLowerCase(Locale.ROOT); - final var content = Vars.content.getByName(contentType.getContentType(), name); + final var content = Vars.content.getByName(this.contentType.getContentType(), name); return (content == null) - ? ArgumentParseResult.failure(new ContentParseException(ctx, name, contentType)) + ? ArgumentParseResult.failure(new ContentParseException(ctx, name, this.contentType)) : ArgumentParseResult.success((T) content); } @@ -95,11 +95,11 @@ public ContentParseException(final CommandContext ctx, final String input, fi } public String getInput() { - return input; + return this.input; } public CTypeKey getContentType() { - return contentType; + return this.contentType; } } } diff --git a/distributor-command-cloud/src/main/java/com/xpdustry/distributor/api/command/cloud/parser/TeamParser.java b/distributor-command-cloud/src/main/java/com/xpdustry/distributor/api/command/cloud/parser/TeamParser.java index 38667c38..d68b8cc2 100644 --- a/distributor-command-cloud/src/main/java/com/xpdustry/distributor/api/command/cloud/parser/TeamParser.java +++ b/distributor-command-cloud/src/main/java/com/xpdustry/distributor/api/command/cloud/parser/TeamParser.java @@ -78,7 +78,7 @@ public ArgumentParseResult parse(final CommandContext ctx, final Comman @Override public @NonNull SuggestionProvider suggestionProvider() { return SuggestionProvider.suggestingStrings( - getTeamIndex().keySet().stream().sorted().toArray(String[]::new)); + this.getTeamIndex().keySet().stream().sorted().toArray(String[]::new)); } private Map getTeamIndex() { diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/annotation/MethodAnnotationProcessor.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/annotation/MethodAnnotationProcessor.java index 699e33d3..5ff8964c 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/annotation/MethodAnnotationProcessor.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/annotation/MethodAnnotationProcessor.java @@ -43,7 +43,7 @@ public final Optional process(final Object instance) { results.add(this.process(instance, method, (A) annotation)); } } - return reduce(Collections.unmodifiableList(results)); + return this.reduce(Collections.unmodifiableList(results)); } protected abstract R process(final Object instance, final Method method, final A annotation); diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/audience/Audience.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/audience/Audience.java index 86c857e1..f6b325d8 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/audience/Audience.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/audience/Audience.java @@ -148,7 +148,7 @@ default void showLabel(final Component label, final float x, final float y, fina * @param duration the duration */ default void kick(final Component reason, final Duration duration) { - kick(reason, duration, true); + this.kick(reason, duration, true); } /** @@ -167,7 +167,7 @@ default void kick(final Component reason, final Duration duration, final boolean * @param duration the duration */ default void kick(final Packets.KickReason reason, final Duration duration) { - kick(reason, duration, true); + this.kick(reason, duration, true); } /** diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/audience/ForwardingAudience.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/audience/ForwardingAudience.java index 1ef41cea..5e7fc382 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/audience/ForwardingAudience.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/audience/ForwardingAudience.java @@ -40,7 +40,7 @@ public interface ForwardingAudience extends Audience { @Override default Stream toStream() { - final var audiences = getAudiences(); + final var audiences = this.getAudiences(); final Stream stream; if (audiences instanceof Collection collection) { stream = collection.stream(); @@ -56,77 +56,77 @@ default Stream toStream() { @Override default void sendMessage(final Component component) { - for (final var audience : getAudiences()) { + for (final var audience : this.getAudiences()) { audience.sendMessage(component); } } @Override default void sendMessage(final Component component, final Component unformatted, final Audience sender) { - for (final var audience : getAudiences()) { + for (final var audience : this.getAudiences()) { audience.sendMessage(component, unformatted, sender); } } @Override default void sendWarning(final Component component) { - for (final var audience : getAudiences()) { + for (final var audience : this.getAudiences()) { audience.sendWarning(component); } } @Override default void showHUDText(final Component component) { - for (final var audience : getAudiences()) { + for (final var audience : this.getAudiences()) { audience.showHUDText(component); } } @Override default void hideHUDText() { - for (final var audience : getAudiences()) { + for (final var audience : this.getAudiences()) { audience.hideHUDText(); } } @Override default void sendNotification(final Component component, final char icon) { - for (final var audience : getAudiences()) { + for (final var audience : this.getAudiences()) { audience.sendNotification(component, icon); } } @Override default void sendAnnouncement(final Component component) { - for (final var audience : getAudiences()) { + for (final var audience : this.getAudiences()) { audience.sendAnnouncement(component); } } @Override default void openURI(final URI uri) { - for (final var audience : getAudiences()) { + for (final var audience : this.getAudiences()) { audience.openURI(uri); } } @Override default void showLabel(final Component label, final float x, final float y, final Duration duration) { - for (final var audience : getAudiences()) { + for (final var audience : this.getAudiences()) { audience.showLabel(label, x, y, duration); } } @Override default void kick(final Component reason, final Duration duration, final boolean log) { - for (final var audience : getAudiences()) { + for (final var audience : this.getAudiences()) { audience.kick(reason, duration, log); } } @Override default void kick(final Packets.KickReason reason, final Duration duration, final boolean log) { - for (final var audience : getAudiences()) { + for (final var audience : this.getAudiences()) { audience.kick(reason, duration, log); } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/collection/MindustryList.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/collection/MindustryList.java index bb18b11d..46678c18 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/collection/MindustryList.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/collection/MindustryList.java @@ -63,7 +63,7 @@ public boolean contains(final Object o) { @SuppressWarnings("SuspiciousSystemArraycopy") @Override public T[] toArray(final T[] a) { - if (a.length >= size()) { + if (a.length >= this.size()) { System.arraycopy(this.seq.items, 0, a, 0, this.seq.size); Arrays.fill(a, this.seq.size, a.length, null); return a; diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/collection/MindustryMap.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/collection/MindustryMap.java index 64855a63..c62cabf8 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/collection/MindustryMap.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/collection/MindustryMap.java @@ -60,27 +60,27 @@ public boolean containsValue(final Object value) { @SuppressWarnings("unchecked") @Override public boolean containsKey(final Object key) { - checkNullKey(key); + this.checkNullKey(key); return this.map.containsKey((K) key); } @SuppressWarnings("unchecked") @Override public V get(final Object key) { - checkNullKey(key); + this.checkNullKey(key); return this.map.get((K) key); } @Override public V put(final K key, final V value) { - checkNullKey(key); + this.checkNullKey(key); return this.map.put(key, value); } @SuppressWarnings("unchecked") @Override public V remove(final Object key) { - checkNullKey(key); + this.checkNullKey(key); return this.map.remove((K) key); } @@ -92,7 +92,7 @@ public void clear() { @SuppressWarnings("unchecked") @Override public V getOrDefault(final Object key, final V defaultValue) { - checkNullKey(key); + this.checkNullKey(key); return this.map.get((K) key, defaultValue); } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/collection/MindustrySet.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/collection/MindustrySet.java index d0c81a87..e1c9a5a5 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/collection/MindustrySet.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/collection/MindustrySet.java @@ -55,20 +55,20 @@ public boolean isEmpty() { @SuppressWarnings("unchecked") @Override public boolean contains(final Object o) { - checkNullElement(o); + this.checkNullElement(o); return this.set.contains((E) o); } @Override public boolean add(final E e) { - checkNullElement(e); + this.checkNullElement(e); return this.set.add(e); } @SuppressWarnings("unchecked") @Override public boolean remove(final Object o) { - checkNullElement(o); + this.checkNullElement(o); return this.set.remove((E) o); } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/command/MindustryCommandFacade.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/command/MindustryCommandFacade.java index d41a796e..5ed681ac 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/command/MindustryCommandFacade.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/command/MindustryCommandFacade.java @@ -37,12 +37,12 @@ final class MindustryCommandFacade implements CommandFacade { @Override public String getRealName() { - return command.text; + return this.command.text; } @Override public String getName() { - return command.text; + return this.command.text; } @Override @@ -63,10 +63,10 @@ public boolean isVisible(final CommandSender sender) { @Override public CommandHelp getHelp(final CommandSender sender, final String query) { return CommandHelp.Entry.of( - command.params.length == 0 ? command.text : command.text + " " + command.paramText, - getDescription(), + this.command.params.length == 0 ? this.command.text : this.command.text + " " + this.command.paramText, + this.getDescription(), DescriptionFacade.EMPTY, - Arrays.stream(command.params) + Arrays.stream(this.command.params) .map(p -> CommandElement.Argument.of( p.name, DescriptionFacade.EMPTY, diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/command/PlayerCommandSender.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/command/PlayerCommandSender.java index 92ff504f..f07282b8 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/command/PlayerCommandSender.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/command/PlayerCommandSender.java @@ -41,7 +41,7 @@ public void reply(final String text) { @Override public void reply(final Component component) { - getAudience().sendMessage(component); + this.getAudience().sendMessage(component); } @Override @@ -51,7 +51,7 @@ public void error(final String text) { @Override public void error(final Component component) { - getAudience().sendMessage(ListComponent.components(ComponentColor.RED, component)); + this.getAudience().sendMessage(ListComponent.components(ComponentColor.RED, component)); } @Override diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/command/ServerCommandSender.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/command/ServerCommandSender.java index e8196636..5a98161e 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/command/ServerCommandSender.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/command/ServerCommandSender.java @@ -41,7 +41,7 @@ public void reply(final String text) { @Override public void reply(final Component component) { - getAudience().sendMessage(component); + this.getAudience().sendMessage(component); } @Override @@ -51,7 +51,7 @@ public void error(final String text) { @Override public void error(final Component component) { - getAudience().sendWarning(component); + this.getAudience().sendWarning(component); } @Override diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/command/TranslatedDescriptionFacade.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/command/TranslatedDescriptionFacade.java index f50ebc92..75e810f7 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/command/TranslatedDescriptionFacade.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/command/TranslatedDescriptionFacade.java @@ -29,37 +29,37 @@ record TranslatedDescriptionFacade(String key, Locale defaultLocale) implements @Override public String getText() { - return getTranslation(null).format(TranslationArguments.empty()); + return this.getTranslation(null).format(TranslationArguments.empty()); } @Override public String getText(final CommandSender sender) { - return getTranslation(sender).format(TranslationArguments.empty()); + return this.getTranslation(sender).format(TranslationArguments.empty()); } @Override public Component getComponent() { - return getTranslation(null).formatAsComponent(TranslationArguments.empty()); + return this.getTranslation(null).formatAsComponent(TranslationArguments.empty()); } @Override public Component getComponent(final CommandSender sender) { - return getTranslation(sender).formatAsComponent(TranslationArguments.empty()); + return this.getTranslation(sender).formatAsComponent(TranslationArguments.empty()); } @Override public boolean isEmpty() { - return Distributor.get().getGlobalTranslationSource().getTranslation(key, this.defaultLocale) == null; + return Distributor.get().getGlobalTranslationSource().getTranslation(this.key, this.defaultLocale) == null; } @Override public boolean isEmpty(final CommandSender sender) { - return Distributor.get().getGlobalTranslationSource().getTranslation(key, sender.getLocale()) == null; + return Distributor.get().getGlobalTranslationSource().getTranslation(this.key, sender.getLocale()) == null; } private Translation getTranslation(final @Nullable CommandSender sender) { return Distributor.get() .getGlobalTranslationSource() - .getTranslationOrMissing(key, sender != null ? sender.getLocale() : this.defaultLocale); + .getTranslationOrMissing(this.key, sender != null ? sender.getLocale() : this.defaultLocale); } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/ListComponent.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/ListComponent.java index 204166f5..444eec34 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/ListComponent.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/ListComponent.java @@ -133,7 +133,7 @@ interface Builder extends BuildableComponent.Builder components) implem @Override public List getComponents() { - return components; + return this.components; } @Override @@ -87,7 +87,7 @@ public Builder append(final Collection components) { @Override public ListComponentImpl build() { - return new ListComponentImpl(textStyle, components); + return new ListComponentImpl(this.textStyle, this.components); } } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/NumberComponentImpl.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/NumberComponentImpl.java index a136ec5c..a8b0e69a 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/NumberComponentImpl.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/NumberComponentImpl.java @@ -26,12 +26,12 @@ record NumberComponentImpl(TextStyle textStyle, Number number) implements Number @Override public Number getNumber() { - return number; + return this.number; } @Override public TextStyle getTextStyle() { - return textStyle; + return this.textStyle; } @Override @@ -65,7 +65,7 @@ public Builder setNumber(final Number number) { @Override public NumberComponent build() { - return new NumberComponentImpl(textStyle, Objects.requireNonNull(number)); + return new NumberComponentImpl(this.textStyle, Objects.requireNonNull(this.number)); } } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/TemporalComponentImpl.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/TemporalComponentImpl.java index 8833f0be..2eb65602 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/TemporalComponentImpl.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/TemporalComponentImpl.java @@ -34,12 +34,12 @@ public Temporal getTemporal() { @Override public TemporalStyle getTemporalStyle() { - return format; + return this.format; } @Override public TextStyle getTextStyle() { - return textStyle; + return this.textStyle; } @Override @@ -81,7 +81,7 @@ public Builder setTemporalStyle(final TemporalStyle temporalStyle) { @Override public TemporalComponent build() { - return new TemporalComponentImpl(textStyle, Objects.requireNonNull(temporal), format); + return new TemporalComponentImpl(this.textStyle, Objects.requireNonNull(this.temporal), this.format); } } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/TextComponentImpl.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/TextComponentImpl.java index 2065d95b..e405e730 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/TextComponentImpl.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/TextComponentImpl.java @@ -29,7 +29,7 @@ record TextComponentImpl(TextStyle textStyle, String content) implements TextCom @Override public String getContent() { - return content; + return this.content; } @Override @@ -70,7 +70,7 @@ public TextComponent.Builder setContent(final String content) { @Override public TextComponent build() { - return new TextComponentImpl(textStyle, content); + return new TextComponentImpl(this.textStyle, this.content); } } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/TranslatableComponentImpl.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/TranslatableComponentImpl.java index e39844b7..2beedb11 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/TranslatableComponentImpl.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/TranslatableComponentImpl.java @@ -82,7 +82,7 @@ public Builder setParameters(final TranslationArguments parameters) { @Override public TranslatableComponent build() { - return new TranslatableComponentImpl(textStyle, this.key, this.parameters); + return new TranslatableComponentImpl(this.textStyle, this.key, this.parameters); } } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/AnsiComponentStringBuilder.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/AnsiComponentStringBuilder.java index 60872712..895c60d8 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/AnsiComponentStringBuilder.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/AnsiComponentStringBuilder.java @@ -50,30 +50,30 @@ final class AnsiComponentStringBuilder implements ComponentStringBuilder { @Override public KeyContainer getContext() { - return context; + return this.context; } @Override public ComponentStringBuilder append(final Component component) { - escape(); + this.escape(); { - final var previous = styles.peek(); + final var previous = this.styles.peek(); final var next = previous == null ? component.getTextStyle() : previous.merge(component.getTextStyle()); - styles.push(next); + this.styles.push(next); if (!Objects.equals(previous, next)) { - appendStyle(next); + this.appendStyle(next); } } - final var renderer = provider.getRenderer(component); + final var renderer = this.provider.getRenderer(component); if (renderer != null) renderer.render(component, this); { - final var popped = styles.pop(); - final var head = styles.peek(); + final var popped = this.styles.pop(); + final var head = this.styles.peek(); if (!Objects.equals(popped, head)) { - appendStyle(head == null ? TextStyle.of() : head); + this.appendStyle(head == null ? TextStyle.of() : head); } } @@ -82,83 +82,84 @@ public ComponentStringBuilder append(final Component component) { @Override public ComponentStringBuilder append(final @Nullable CharSequence csq) { - builder.append(csq); + this.builder.append(csq); return this; } @Override public ComponentStringBuilder append(final @Nullable CharSequence csq, final int start, final int end) { - builder.append(csq, start, end); + this.builder.append(csq, start, end); return this; } @Override public ComponentStringBuilder append(final char c) { - builder.append(c); + this.builder.append(c); return this; } @Override public String toString() { - escape(); - return builder.toString(); + this.escape(); + return this.builder.toString(); } private void escape() { - escape(builder.length()); + this.escape(this.builder.length()); } private void escape(final int end) { - if (!ANSI_SUPPORTED || builder.length() == mark) return; - final var matcher = ANSI_PATTERN.matcher(builder.substring(mark, end)); - builder.delete(mark, end); + if (!ANSI_SUPPORTED || this.builder.length() == this.mark) return; + final var matcher = ANSI_PATTERN.matcher(this.builder.substring(this.mark, end)); + this.builder.delete(this.mark, end); final var insert = new StringBuilder(); while (matcher.find()) matcher.appendReplacement(insert, ""); matcher.appendTail(insert); - builder.insert(mark, insert); - mark = builder.length(); + this.builder.insert(this.mark, insert); + this.mark = this.builder.length(); } private void appendStyle(final TextStyle style) { - final var start = builder.length(); - appendReset(); + final var start = this.builder.length(); + this.appendReset(); final var textColor = style.getTextColor(); if (textColor != null) { - appendForegroundColor(textColor); + this.appendForegroundColor(textColor); } final var backColor = style.getBackColor(); if (backColor != null) { - appendBackgroundColor(backColor); + this.appendBackgroundColor(backColor); } for (final var entry : style.getDecorations().entrySet()) { final var decoration = entry.getKey(); if (!entry.getValue()) continue; - appendDecoration(decoration); + this.appendDecoration(decoration); } - escape(start); + this.escape(start); } private void appendReset() { if (!ANSI_SUPPORTED) return; - builder.append(ANSI_ESCAPE_START).append(0).append(ANSI_ESCAPE_CLOSE); + this.builder.append(ANSI_ESCAPE_START).append(0).append(ANSI_ESCAPE_CLOSE); } private void appendDecoration(final TextDecoration decoration) { if (!ANSI_SUPPORTED) return; - builder.append(ANSI_ESCAPE_START); - builder.append( + this.builder.append(ANSI_ESCAPE_START); + this.builder.append( switch (decoration) { case BOLD -> 1; case ITALIC -> 3; case UNDERLINED -> 4; case STRIKETHROUGH -> 9; }); - builder.append(ANSI_ESCAPE_CLOSE); + this.builder.append(ANSI_ESCAPE_CLOSE); } private void appendForegroundColor(final ComponentColor color) { if (!ANSI_SUPPORTED) return; - builder.append(ANSI_ESCAPE_START) + this.builder + .append(ANSI_ESCAPE_START) .append(38) .append(';') .append(2) @@ -173,7 +174,8 @@ private void appendForegroundColor(final ComponentColor color) { private void appendBackgroundColor(final ComponentColor color) { if (!ANSI_SUPPORTED) return; - builder.append(ANSI_ESCAPE_START) + this.builder + .append(ANSI_ESCAPE_START) .append(48) .append(';') .append(2) diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/ComponentAccumulator.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/ComponentAccumulator.java index fe43c926..adb6d604 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/ComponentAccumulator.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/ComponentAccumulator.java @@ -48,7 +48,7 @@ public static ComponentAccumulator create() { * Returns an immutable view of the accumulated components. */ public List getComponents() { - return Collections.unmodifiableList(components); + return Collections.unmodifiableList(this.components); } @Override @@ -64,17 +64,18 @@ public ComponentAccumulator append(final Component component) { @Override public ComponentAccumulator append(final @Nullable CharSequence csq) { - return append(text(csq == null ? "null" : csq.toString())); + return this.append(text(csq == null ? "null" : csq.toString())); } @Override public ComponentAccumulator append(final @Nullable CharSequence csq, final int start, final int end) { - return append(text(csq == null ? "null" : csq.subSequence(start, end).toString())); + return this.append( + text(csq == null ? "null" : csq.subSequence(start, end).toString())); } @Override public ComponentAccumulator append(final char c) { - return append(text(c)); + return this.append(text(c)); } @Override diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/MindustryComponentStringBuilder.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/MindustryComponentStringBuilder.java index bd0b85c1..150f528f 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/MindustryComponentStringBuilder.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/MindustryComponentStringBuilder.java @@ -37,7 +37,7 @@ final class MindustryComponentStringBuilder implements ComponentStringBuilder { @Override public KeyContainer getContext() { - return context; + return this.context; } @Override @@ -45,21 +45,21 @@ public ComponentStringBuilder append(final Component component) { { var color = component.getTextStyle().getTextColor(); final var rgb = color == null ? -1 : color.getRGB(); - final var previous = colors.isEmpty() ? -1 : colors.peek(); - colors.add(rgb); + final var previous = this.colors.isEmpty() ? -1 : this.colors.peek(); + this.colors.add(rgb); if (rgb != -1 && rgb != previous) { - builder.append("[#").append(String.format("%06X", rgb)).append(']'); + this.builder.append("[#").append(String.format("%06X", rgb)).append(']'); } } - final var renderer = provider.getRenderer(component); + final var renderer = this.provider.getRenderer(component); if (renderer != null) renderer.render(component, this); { - final var popped = colors.pop(); - final var previous = colors.isEmpty() ? -1 : colors.peek(); + final var popped = this.colors.pop(); + final var previous = this.colors.isEmpty() ? -1 : this.colors.peek(); if (popped != -1 && popped != previous) { - builder.append("[]"); + this.builder.append("[]"); } } @@ -68,16 +68,16 @@ public ComponentStringBuilder append(final Component component) { @Override public ComponentStringBuilder append(final @Nullable CharSequence csq) { - return append(csq, 0, csq == null ? 0 : csq.length()); + return this.append(csq, 0, csq == null ? 0 : csq.length()); } @Override public ComponentStringBuilder append(final @Nullable CharSequence csq, final int start, final int end) { if (csq == null) { - builder.append("null"); + this.builder.append("null"); } else { for (int i = start; i < end; i++) { - append(csq.charAt(i)); + this.append(csq.charAt(i)); } } return this; @@ -86,15 +86,15 @@ public ComponentStringBuilder append(final @Nullable CharSequence csq, final int @Override public ComponentStringBuilder append(final char c) { if (c == '[') { - builder.append("[["); + this.builder.append("[["); } else { - builder.append(c); + this.builder.append(c); } return this; } @Override public String toString() { - return builder.toString(); + return this.builder.toString(); } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/PlainComponentStringBuilder.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/PlainComponentStringBuilder.java index 9d2c9c06..f51cdc00 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/PlainComponentStringBuilder.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/PlainComponentStringBuilder.java @@ -35,7 +35,7 @@ public PlainComponentStringBuilder(final KeyContainer context, final ComponentRe @Override public KeyContainer getContext() { - return context; + return this.context; } @Override diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/style/ComponentColor.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/style/ComponentColor.java index aefeefb2..2165889b 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/style/ComponentColor.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/style/ComponentColor.java @@ -90,20 +90,20 @@ static ComponentColor from(final arc.graphics.Color color) { * Returns the red value of this color. */ default int getR() { - return getRGB() >> 16 & 0xFF; + return this.getRGB() >> 16 & 0xFF; } /** * Returns the green value of this color. */ default int getG() { - return getRGB() >> 8 & 0xFF; + return this.getRGB() >> 8 & 0xFF; } /** * Returns the blue value of this color. */ default int getB() { - return getRGB() & 0xFF; + return this.getRGB() & 0xFF; } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/style/TextStyle.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/style/TextStyle.java index 8f3bc1a2..6f374f38 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/style/TextStyle.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/style/TextStyle.java @@ -156,7 +156,7 @@ static TextStyle of(final TextDecoration... decorations) { * @return this setter or a copy */ default TextStyle addDecoration(final TextDecoration decoration) { - return setDecoration(decoration, TriState.TRUE); + return this.setDecoration(decoration, TriState.TRUE); } /** @@ -173,7 +173,7 @@ default TextStyle setDecoration(final TextDecoration decoration, final TriState } else { copy.put(decoration, state.asBoolean()); } - return setDecorations(copy); + return this.setDecorations(copy); } /** diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/style/TextStyleImpl.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/style/TextStyleImpl.java index 3f9256d3..3400ff4e 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/style/TextStyleImpl.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/style/TextStyleImpl.java @@ -32,34 +32,34 @@ record TextStyleImpl( @Override public @Nullable ComponentColor getTextColor() { - return textColor; + return this.textColor; } @Override public TextStyle setTextColor(final @Nullable ComponentColor textColor) { - return new TextStyleImpl(textColor, backColor, decorations); + return new TextStyleImpl(textColor, this.backColor, this.decorations); } @Override public @Nullable ComponentColor getBackColor() { - return backColor; + return this.backColor; } @Override public TextStyle setBackColor(final @Nullable ComponentColor backColor) { - return new TextStyleImpl(textColor, backColor, decorations); + return new TextStyleImpl(this.textColor, backColor, this.decorations); } @Override public Map getDecorations() { - return decorations; + return this.decorations; } @Override public TextStyle setDecorations(final Map decorations) { final var copy = new EnumMap(TextDecoration.class); copy.putAll(this.decorations); - return new TextStyleImpl(textColor, backColor, Collections.unmodifiableMap(copy)); + return new TextStyleImpl(this.textColor, this.backColor, Collections.unmodifiableMap(copy)); } @Override diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/Action.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/Action.java index 9952f51f..6d6cd5f1 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/Action.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/Action.java @@ -77,10 +77,8 @@ static Action compute(final Key key, final T def, final Function fu * @return the action */ static Action compute(final Key key, final Function function) { - return window -> { - window.getState().getOptional(key).ifPresent(value -> window.getState() - .set(key, function.apply(value))); - }; + return window -> window.getState().getOptional(key).ifPresent(value -> window.getState() + .set(key, function.apply(value))); } /** diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/DisplayUnit.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/DisplayUnit.java index f4ae6218..176ecca3 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/DisplayUnit.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/DisplayUnit.java @@ -70,7 +70,7 @@ static Pixel of(final int value) { @Override default int asPixels(final Player player, final Axis axis) { - return getPixels(); + return this.getPixels(); } } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/WindowManager.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/WindowManager.java index e3a4839e..d6b15b1f 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/WindowManager.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/WindowManager.java @@ -57,7 +57,7 @@ public interface WindowManager { */ default @Nullable Window getActiveWindow(final Player viewer) { final var target = MUUID.from(viewer); - return getActiveWindows().stream() + return this.getActiveWindows().stream() .filter(window -> MUUID.from(window.getViewer()).equals(target)) .findFirst() .orElse(null); diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/input/TextInputManagerImpl.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/input/TextInputManagerImpl.java index 826c66df..0ae74fab 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/input/TextInputManagerImpl.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/input/TextInputManagerImpl.java @@ -47,10 +47,10 @@ protected void onWindowOpen(final SimpleWindow window) { Call.textInput( window.getViewer().con(), this.id, - render(window, window.getPane().getTitle()), - render(window, window.getPane().getDescription()), + this.render(window, window.getPane().getTitle()), + this.render(window, window.getPane().getDescription()), window.getPane().getMaxLength(), - render(window, window.getPane().getPlaceholder()), + this.render(window, window.getPane().getPlaceholder()), false); } } @@ -61,7 +61,7 @@ protected TextInputPane createPane() { } private void handle(final Player player, final @Nullable String input) { - if (isDisposed()) { + if (this.isDisposed()) { this.getPlugin() .getLogger() .debug( @@ -70,7 +70,7 @@ private void handle(final Player player, final @Nullable String input) { player.uuid()); return; } - final var window = getWindows().get(MUUID.from(player)); + final var window = this.getWindows().get(MUUID.from(player)); if (window == null) { this.getPlugin() .getLogger() @@ -82,7 +82,7 @@ private void handle(final Player player, final @Nullable String input) { } // Simple trick to not reopen an interface when an action already does it. - visible.remove(MUUID.from(player)); + this.visible.remove(MUUID.from(player)); if (input == null) { window.getPane().getExitAction().act(window); } else if (input.length() > window.getPane().getMaxLength()) { @@ -100,7 +100,7 @@ private void handle(final Player player, final @Nullable String input) { } // The text input closes automatically when the player presses enter, // so reopen if it was not explicitly closed by the server. - if (window.isActive() && !visible.contains(MUUID.from(player))) { + if (window.isActive() && !this.visible.contains(MUUID.from(player))) { window.show(); } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/input/TextInputPane.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/input/TextInputPane.java index 708d6b3f..c7d3b977 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/input/TextInputPane.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/input/TextInputPane.java @@ -38,7 +38,7 @@ static TextInputPane create() { TextInputPane setTitle(final Component title); default TextInputPane setTitle(final String title) { - return setTitle(Distributor.get().getMindustryComponentDecoder().decode(title)); + return this.setTitle(Distributor.get().getMindustryComponentDecoder().decode(title)); } Component getDescription(); @@ -46,7 +46,8 @@ default TextInputPane setTitle(final String title) { TextInputPane setDescription(final Component description); default TextInputPane setDescription(final String description) { - return setDescription(Distributor.get().getMindustryComponentDecoder().decode(description)); + return this.setDescription( + Distributor.get().getMindustryComponentDecoder().decode(description)); } Component getPlaceholder(); @@ -54,7 +55,8 @@ default TextInputPane setDescription(final String description) { TextInputPane setPlaceholder(final Component placeholder); default TextInputPane setPlaceholder(final String placeholder) { - return setPlaceholder(Distributor.get().getMindustryComponentDecoder().decode(placeholder)); + return this.setPlaceholder( + Distributor.get().getMindustryComponentDecoder().decode(placeholder)); } int getMaxLength(); diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/input/TextInputPaneImpl.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/input/TextInputPaneImpl.java index 2bc2276a..3fa2e91c 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/input/TextInputPaneImpl.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/input/TextInputPaneImpl.java @@ -104,28 +104,29 @@ public TextInputPane setExitAction(final Action exitAction) { public boolean equals(final Object o) { return (this == o) || (o instanceof TextInputPaneImpl other - && maxLength == other.maxLength - && Objects.equals(title, other.title) - && Objects.equals(description, other.description) - && Objects.equals(placeholder, other.placeholder) - && Objects.equals(inputAction, other.inputAction) - && Objects.equals(exitAction, other.exitAction)); + && this.maxLength == other.maxLength + && Objects.equals(this.title, other.title) + && Objects.equals(this.description, other.description) + && Objects.equals(this.placeholder, other.placeholder) + && Objects.equals(this.inputAction, other.inputAction) + && Objects.equals(this.exitAction, other.exitAction)); } @Override public int hashCode() { - return Objects.hash(title, description, placeholder, maxLength, inputAction, exitAction); + return Objects.hash( + this.title, this.description, this.placeholder, this.maxLength, this.inputAction, this.exitAction); } @Override public String toString() { return new StringJoiner(", ", TextInputPaneImpl.class.getSimpleName() + "{", "}") - .add("title='" + title + "'") - .add("description='" + description + "'") - .add("placeholder='" + placeholder + "'") - .add("maxLength=" + maxLength) - .add("inputAction=" + inputAction) - .add("exitAction=" + exitAction) + .add("title='" + this.title + "'") + .add("description='" + this.description + "'") + .add("placeholder='" + this.placeholder + "'") + .add("maxLength=" + this.maxLength) + .add("inputAction=" + this.inputAction) + .add("exitAction=" + this.exitAction) .toString(); } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/ListTransformer.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/ListTransformer.java index a1e656fe..c8e27862 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/ListTransformer.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/ListTransformer.java @@ -60,7 +60,7 @@ public final class ListTransformer implements Transformer { * Returns the provider of the elements. */ public Function, List> getProvider() { - return provider; + return this.provider; } /** @@ -78,7 +78,7 @@ public ListTransformer setProvider(final Function, List> * Returns the renderer of the elements. */ public BiFunction, E, Component> getRenderer() { - return renderer; + return this.renderer; } /** @@ -88,7 +88,7 @@ public BiFunction, E, Component> getRenderer() { * @return this transformer */ public ListTransformer setRenderer(final Function renderer) { - return setRenderer((ctx, e) -> renderer.apply(e)); + return this.setRenderer((ctx, e) -> renderer.apply(e)); } /** @@ -106,7 +106,7 @@ public ListTransformer setRenderer(final BiFunction, E, Com * Returns the action to perform when an element is chosen. */ public BiAction getChoiceAction() { - return choiceAction; + return this.choiceAction; } /** @@ -124,7 +124,7 @@ public ListTransformer setChoiceAction(final BiAction choiceAction) { * Returns the height of a page. */ public int getHeight() { - return height; + return this.height; } /** @@ -143,7 +143,7 @@ public ListTransformer setHeight(final int height) { * Returns the width of a page. */ public int getWidth() { - return width; + return this.width; } /** @@ -162,14 +162,14 @@ public ListTransformer setWidth(final int width) { * Returns the page size. */ public int getPageSize() { - return height * width; + return this.height * this.width; } /** * Returns whether the transformer fills empty spaces. */ public boolean isFillEmptySpace() { - return fillEmptySpace; + return this.fillEmptySpace; } /** @@ -190,7 +190,7 @@ public ListTransformer setFillEmptySpace(final boolean fillEmptySpace) { * Returns whether the navigation buttons are rendered. */ public boolean isRenderNavigation() { - return renderNavigation; + return this.renderNavigation; } /** @@ -210,7 +210,7 @@ public ListTransformer setRenderNavigation(final boolean renderNavigation) { * Returns the key used to store the current page. */ public Key getPageKey() { - return pageKey; + return this.pageKey; } /** @@ -226,19 +226,20 @@ public ListTransformer setPageKey(final Key pageKey) { @Override public void transform(final Context context) { - final var elements = provider.apply(context); - final int pages = - Math.floorDiv(elements.size(), getPageSize()) + (elements.size() % getPageSize() == 0 ? 0 : 1); - final int page = context.getState().getOptional(pageKey).orElse(0); + final var elements = this.provider.apply(context); + final int pages = Math.floorDiv(elements.size(), this.getPageSize()) + + (elements.size() % this.getPageSize() == 0 ? 0 : 1); + final int page = context.getState().getOptional(this.pageKey).orElse(0); int cursor = 0; - for (int i = 0; i < height; i++) { + for (int i = 0; i < this.height; i++) { final List options = new ArrayList<>(); - for (int j = 0; j < width; j++) { - cursor = (page * getPageSize()) + (i * width) + j; + for (int j = 0; j < this.width; j++) { + cursor = (page * this.getPageSize()) + (i * this.width) + j; if (cursor < elements.size()) { final var element = elements.get(cursor); - options.add(MenuOption.of(renderer.apply(context, element), ctx -> choiceAction.act(ctx, element))); + options.add(MenuOption.of( + this.renderer.apply(context, element), ctx -> this.choiceAction.act(ctx, element))); } else if (this.fillEmptySpace) { options.add(MenuOption.of(empty(), Action.none())); } else { @@ -248,24 +249,24 @@ public void transform(final Context context) { if (!options.isEmpty()) { context.getPane().getGrid().addRow(options); } - if (cursor >= elements.size() && !fillEmptySpace) { + if (cursor >= elements.size() && !this.fillEmptySpace) { break; } } - if (renderNavigation) { + if (this.renderNavigation) { context.getPane() .getGrid() .addRow( - createConditionalOption( + this.createConditionalOption( page > 0, Iconc.left, - Action.with(pageKey, page - 1).then(Window::show)), + Action.with(this.pageKey, page - 1).then(Window::show)), MenuOption.of(Mathf.clamp(page + 1, 0, pages) + " / " + pages, Action.none()), - createConditionalOption( + this.createConditionalOption( cursor + 1 < elements.size(), Iconc.right, - Action.with(pageKey, page + 1).then(Window::show))); + Action.with(this.pageKey, page + 1).then(Window::show))); } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/MenuGrid.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/MenuGrid.java index 3edf318e..04bd39cf 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/MenuGrid.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/MenuGrid.java @@ -38,13 +38,13 @@ static MenuGrid create() { MenuGrid setRow(final int index, final List options); default MenuGrid addRow(final MenuOption... options) { - return addRow(Arrays.asList(options)); + return this.addRow(Arrays.asList(options)); } MenuGrid addRow(final List options); default MenuGrid addRow(final int index, final MenuOption... options) { - return addRow(index, Arrays.asList(options)); + return this.addRow(index, Arrays.asList(options)); } MenuGrid addRow(final int index, final List options); diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/MenuGridImpl.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/MenuGridImpl.java index 45786563..91492f88 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/MenuGridImpl.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/MenuGridImpl.java @@ -31,12 +31,12 @@ final class MenuGridImpl implements MenuGrid { @Override public List> getOptions() { - return options.stream().map(Collections::unmodifiableList).toList(); + return this.options.stream().map(Collections::unmodifiableList).toList(); } @Override public List getRow(int index) { - return Collections.unmodifiableList(options.get(index)); + return Collections.unmodifiableList(this.options.get(index)); } @Override @@ -59,14 +59,14 @@ public MenuGrid addRow(int index, List options) { @Override public MenuGrid removeRow(int index) { - options.remove(index); + this.options.remove(index); return this; } @Override public @Nullable MenuOption getOption(final int id) { var i = 0; - for (var row : options) { + for (var row : this.options) { i += row.size(); if (i > id) { return row.get(id - i + row.size()); @@ -77,15 +77,15 @@ public MenuGrid removeRow(int index) { @Override public MenuOption getOption(final int x, final int y) { - return options.get(y).get(x); + return this.options.get(y).get(x); } @Override public MenuGrid addOption(final MenuOption option) { - if (options.isEmpty()) { - addRow(List.of(option)); + if (this.options.isEmpty()) { + this.addRow(List.of(option)); } else { - final var row = options.get(options.size() - 1); + final var row = this.options.get(this.options.size() - 1); row.add(option); } return this; @@ -93,40 +93,40 @@ public MenuGrid addOption(final MenuOption option) { @Override public MenuOption addOption(final int y, final MenuOption option) { - options.get(y).add(option); + this.options.get(y).add(option); return option; } @Override public MenuOption addOption(final int x, final int y, MenuOption option) { - options.get(y).add(x, option); + this.options.get(y).add(x, option); return option; } @Override public MenuGrid removeOption(final int x, final int y) { - final var row = options.get(y); + final var row = this.options.get(y); row.remove(x); if (row.isEmpty()) { - options.remove(y); + this.options.remove(y); } return this; } @Override public int hashCode() { - return Objects.hashCode(options); + return Objects.hashCode(this.options); } @Override public boolean equals(final Object o) { - return (this == o) || (o instanceof MenuGridImpl other && Objects.equals(options, other.options)); + return (this == o) || (o instanceof MenuGridImpl other && Objects.equals(this.options, other.options)); } @Override public String toString() { return new StringJoiner(", ", MenuGridImpl.class.getSimpleName() + "{", "}") - .add("options=" + options) + .add("options=" + this.options) .toString(); } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/MenuManagerImpl.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/MenuManagerImpl.java index f02f069f..bd79de64 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/MenuManagerImpl.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/MenuManagerImpl.java @@ -42,7 +42,7 @@ protected void onWindowOpen(final SimpleWindow window) { final var options = window.getPane().getGrid().getOptions().stream() .map(row -> row.stream() .map(MenuOption::getContent) - .map(content -> render(window, content)) + .map(content -> this.render(window, content)) .toArray(String[]::new)) .toArray(String[][]::new); for (int i = 0; i < options.length; i++) { @@ -52,15 +52,15 @@ protected void onWindowOpen(final SimpleWindow window) { } Call.followUpMenu( window.getViewer().con(), - id, - render(window, window.getPane().getTitle()), - render(window, window.getPane().getContent()), + this.id, + this.render(window, window.getPane().getTitle()), + this.render(window, window.getPane().getContent()), options); } @Override protected void onWindowClose(final SimpleWindow window) { - Call.hideFollowUpMenu(window.getViewer().con(), id); + Call.hideFollowUpMenu(window.getViewer().con(), this.id); } @Override @@ -69,7 +69,7 @@ protected MenuPane createPane() { } private void handle(final Player player, final int option) { - if (isDisposed()) { + if (this.isDisposed()) { this.getPlugin() .getLogger() .debug( @@ -78,7 +78,7 @@ private void handle(final Player player, final int option) { player.uuid()); return; } - final var window = getWindows().get(MUUID.from(player)); + final var window = this.getWindows().get(MUUID.from(player)); if (window == null) { this.getPlugin() .getLogger() @@ -91,7 +91,7 @@ private void handle(final Player player, final int option) { } else { final var choice = window.getPane().getGrid().getOption(option); if (choice == null) { - getPlugin() + this.getPlugin() .getLogger() .debug( "Received invalid menu option {} from player {} (uuid: {})", diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/MenuPane.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/MenuPane.java index 3db67bda..28b85b27 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/MenuPane.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/MenuPane.java @@ -37,7 +37,7 @@ static MenuPane create() { MenuPane setTitle(final Component title); default MenuPane setTitle(final String title) { - return setTitle(Distributor.get().getMindustryComponentDecoder().decode(title)); + return this.setTitle(Distributor.get().getMindustryComponentDecoder().decode(title)); } Component getContent(); @@ -45,7 +45,7 @@ default MenuPane setTitle(final String title) { MenuPane setContent(final Component content); default MenuPane setContent(final String content) { - return setContent(Distributor.get().getMindustryComponentDecoder().decode(content)); + return this.setContent(Distributor.get().getMindustryComponentDecoder().decode(content)); } Action getExitAction(); diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/MenuPaneImpl.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/MenuPaneImpl.java index ef2efae3..64a53b86 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/MenuPaneImpl.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/MenuPaneImpl.java @@ -33,7 +33,7 @@ final class MenuPaneImpl implements MenuPane { @Override public Component getTitle() { - return title; + return this.title; } @Override @@ -44,7 +44,7 @@ public MenuPane setTitle(final Component title) { @Override public Component getContent() { - return content; + return this.content; } @Override @@ -55,7 +55,7 @@ public MenuPane setContent(final Component content) { @Override public Action getExitAction() { - return exitAction; + return this.exitAction; } @Override @@ -66,7 +66,7 @@ public MenuPane setExitAction(final Action exitAction) { @Override public MenuGrid getGrid() { - return grid; + return this.grid; } @Override @@ -79,24 +79,24 @@ public MenuPane setGrid(final MenuGrid grid) { public boolean equals(final Object o) { return (this == o) || (o instanceof MenuPaneImpl other - && Objects.equals(title, other.title) - && Objects.equals(content, other.content) - && Objects.equals(exitAction, other.exitAction) - && Objects.equals(grid, other.grid)); + && Objects.equals(this.title, other.title) + && Objects.equals(this.content, other.content) + && Objects.equals(this.exitAction, other.exitAction) + && Objects.equals(this.grid, other.grid)); } @Override public int hashCode() { - return Objects.hash(title, content, exitAction, grid); + return Objects.hash(this.title, this.content, this.exitAction, this.grid); } @Override public String toString() { return new StringJoiner(", ", MenuPaneImpl.class.getSimpleName() + "{", "}") - .add("title='" + title + "'") - .add("content='" + content + "'") - .add("exitAction=" + exitAction) - .add("grid=" + grid) + .add("title='" + this.title + "'") + .add("content='" + this.content + "'") + .add("exitAction=" + this.exitAction) + .add("grid=" + this.grid) .toString(); } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/popup/PopupManagerImpl.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/popup/PopupManagerImpl.java index 13a7b3c1..bc407d50 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/popup/PopupManagerImpl.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/popup/PopupManagerImpl.java @@ -42,11 +42,11 @@ final class PopupManagerImpl extends AbstractTransformerWindowManager PopupManagerImpl(final MindustryPlugin plugin) { super(plugin); - interval.reset(0, Float.MAX_VALUE); - setUpdateInterval(Duration.ofSeconds(1L)); - updater = Distributor.get().getEventBus().subscribe(EventType.Trigger.update, plugin, () -> { - if (interval.get(tickUpdateInterval)) { - getWindows().values().forEach(Window::show); + this.interval.reset(0, Float.MAX_VALUE); + this.setUpdateInterval(Duration.ofSeconds(1L)); + this.updater = Distributor.get().getEventBus().subscribe(EventType.Trigger.update, plugin, () -> { + if (this.interval.get(this.tickUpdateInterval)) { + this.getWindows().values().forEach(Window::show); } }); } @@ -72,7 +72,7 @@ protected void onWindowOpen(final SimpleWindow window) { .getMetadata()) .append(window.getPane().getContent()) .toString(), - (Time.delta / 60F) * tickUpdateInterval, + (Time.delta / 60F) * this.tickUpdateInterval, align, window.getPane().getShiftY().asPixels(window.getViewer(), DisplayUnit.Axis.Y), window.getPane().getShiftX().asPixels(window.getViewer(), DisplayUnit.Axis.X), @@ -88,7 +88,7 @@ protected PopupPane createPane() { @Override protected void onDispose() { super.onDispose(); - updater.unsubscribe(); + this.updater.unsubscribe(); } @Override diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/popup/PopupPane.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/popup/PopupPane.java index e6dd163f..5e5e1163 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/popup/PopupPane.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/popup/PopupPane.java @@ -37,7 +37,7 @@ static PopupPane create() { PopupPane setContent(final Component content); default PopupPane setContent(final String content) { - return setContent(Distributor.get().getMindustryComponentDecoder().decode(content)); + return this.setContent(Distributor.get().getMindustryComponentDecoder().decode(content)); } DisplayUnit getShiftX(); diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/popup/PopupPaneImpl.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/popup/PopupPaneImpl.java index 4cbbb785..914502bc 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/popup/PopupPaneImpl.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/popup/PopupPaneImpl.java @@ -106,11 +106,11 @@ public int hashCode() { @Override public String toString() { return new StringJoiner(", ", PopupPaneImpl.class.getSimpleName() + "{", "}") - .add("content='" + content + "'") - .add("shiftX=" + shiftX) - .add("shiftY=" + shiftY) - .add("alignementX=" + alignementX) - .add("alignementY=" + alignementY) + .add("content='" + this.content + "'") + .add("shiftX=" + this.shiftX) + .add("shiftY=" + this.shiftY) + .add("alignementX=" + this.alignementX) + .add("alignementY=" + this.alignementY) .toString(); } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/transform/AbstractTransformerWindowManager.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/transform/AbstractTransformerWindowManager.java index 95ea247b..cc38b674 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/transform/AbstractTransformerWindowManager.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/transform/AbstractTransformerWindowManager.java @@ -57,7 +57,7 @@ protected AbstractTransformerWindowManager(final MindustryPlugin plugin) { this.playerLeaveListener = Distributor.get() .getEventBus() .subscribe(EventType.PlayerLeave.class, plugin, event -> { - final var window = windows.get(MUUID.from(event.player)); + final var window = this.windows.get(MUUID.from(event.player)); if (window != null) window.hide(); }); } @@ -67,7 +67,7 @@ protected AbstractTransformerWindowManager(final MindustryPlugin plugin) { protected void onWindowClose(final SimpleWindow window) {} protected void onDispose() { - playerLeaveListener.unsubscribe(); + this.playerLeaveListener.unsubscribe(); } protected abstract P createPane(); @@ -89,34 +89,34 @@ public final Collection getActiveWindows() { @Override public @Nullable Window getActiveWindow(final Player viewer) { - return windows.get(MUUID.from(viewer)); + return this.windows.get(MUUID.from(viewer)); } @Override public final void addTransformer(final Transformer

transformer) { - transformers.add(Objects.requireNonNull(transformer)); + this.transformers.add(Objects.requireNonNull(transformer)); } @Override public final MindustryPlugin getPlugin() { - return plugin; + return this.plugin; } @Override public final void dispose() { - if (!disposed) { - disposed = true; - getActiveWindows().forEach(Window::hide); - onDispose(); + if (!this.disposed) { + this.disposed = true; + this.getActiveWindows().forEach(Window::hide); + this.onDispose(); } } protected final Map getWindows() { - return Collections.unmodifiableMap(windows); + return Collections.unmodifiableMap(this.windows); } protected final boolean isDisposed() { - return disposed; + return this.disposed; } protected final class SimpleWindow implements Window { @@ -139,8 +139,8 @@ public void show() { return; } - checkNotTransforming(); - final var previous = AbstractTransformerWindowManager.this.windows.put(MUUID.from(viewer), this); + this.checkNotTransforming(); + final var previous = AbstractTransformerWindowManager.this.windows.put(MUUID.from(this.viewer), this); if (previous != null && previous != this) { previous.hide(); } @@ -149,7 +149,7 @@ public void show() { this.transforming = true; this.pane = AbstractTransformerWindowManager.this.createPane(); final var context = Transformer.Context.of(this.pane, this.state, this.viewer); - for (final var transform : transformers) { + for (final var transform : AbstractTransformerWindowManager.this.transformers) { transform.transform(context); } } finally { @@ -161,30 +161,30 @@ public void show() { @Override public void hide() { - checkNotTransforming(); - if (AbstractTransformerWindowManager.this.windows.remove(MUUID.from(viewer), this)) { + this.checkNotTransforming(); + if (AbstractTransformerWindowManager.this.windows.remove(MUUID.from(this.viewer), this)) { AbstractTransformerWindowManager.this.onWindowClose(this); } } @Override public boolean isActive() { - return AbstractTransformerWindowManager.this.windows.containsKey(MUUID.from(viewer)); + return AbstractTransformerWindowManager.this.windows.containsKey(MUUID.from(this.viewer)); } @Override public Player getViewer() { - return viewer; + return this.viewer; } @Override public MutableKeyContainer getState() { - return state; + return this.state; } @Override public @Nullable Window getParent() { - return parent; + return this.parent; } public P getPane() { @@ -192,7 +192,7 @@ public P getPane() { } private void checkNotTransforming() { - if (transforming) { + if (this.transforming) { throw new IllegalStateException("Cannot open or close a window while transforming"); } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/key/DynamicKeyContainerImpl.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/key/DynamicKeyContainerImpl.java index 93591f49..9275143b 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/key/DynamicKeyContainerImpl.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/key/DynamicKeyContainerImpl.java @@ -36,7 +36,7 @@ final class DynamicKeyContainerImpl implements DynamicKeyContainer { @SuppressWarnings("unchecked") @Override public Optional getOptional(final Key key) { - final var supplier = metas.get(key); + final var supplier = this.metas.get(key); if (supplier == null) { return Optional.empty(); } else { @@ -46,12 +46,12 @@ public Optional getOptional(final Key key) { @Override public boolean contains(final Key key) { - return metas.containsKey(key); + return this.metas.containsKey(key); } @Override public Set> getKeys() { - return Collections.unmodifiableSet(metas.keySet()); + return Collections.unmodifiableSet(this.metas.keySet()); } @Override @@ -88,14 +88,14 @@ public Builder putSupplied(final Key key, final Supplier value) { @Override public DynamicKeyContainer build() { - return new DynamicKeyContainerImpl(metas); + return new DynamicKeyContainerImpl(this.metas); } } private record StaticSupplier(V value) implements Supplier { @Override public V get() { - return value; + return this.value; } } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/key/ImmutableKeyContainer.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/key/ImmutableKeyContainer.java index db9c3237..a5744d09 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/key/ImmutableKeyContainer.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/key/ImmutableKeyContainer.java @@ -32,7 +32,7 @@ final class ImmutableKeyContainer implements KeyContainer { @Override public Optional getOptional(final Key key) { - return delegate.getOptional(key); + return this.delegate.getOptional(key); } @Override diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/key/MutableKeyContainerImpl.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/key/MutableKeyContainerImpl.java index d0649601..dc156f6a 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/key/MutableKeyContainerImpl.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/key/MutableKeyContainerImpl.java @@ -32,29 +32,29 @@ final class MutableKeyContainerImpl implements MutableKeyContainer { @SuppressWarnings("unchecked") @Override public Optional getOptional(final Key key) { - return Optional.ofNullable((V) key.getToken().getRawType().cast(data.get(key))); + return Optional.ofNullable((V) key.getToken().getRawType().cast(this.data.get(key))); } @Override public boolean contains(final Key key) { - return data.containsKey(key); + return this.data.containsKey(key); } @SuppressWarnings("unchecked") @Override public @Nullable V set(final Key key, final V value) { - final var previous = data.put(key, value); + final var previous = this.data.put(key, value); return (V) key.getToken().getRawType().cast(previous); } @SuppressWarnings("unchecked") @Override public @Nullable V remove(final Key key) { - return (V) key.getToken().getRawType().cast(data.remove(key)); + return (V) key.getToken().getRawType().cast(this.data.remove(key)); } @Override public Set> getKeys() { - return Collections.unmodifiableSet(data.keySet()); + return Collections.unmodifiableSet(this.data.keySet()); } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/key/SettingsKeyContainer.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/key/SettingsKeyContainer.java index bc8c6b16..2f46e6c7 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/key/SettingsKeyContainer.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/key/SettingsKeyContainer.java @@ -32,35 +32,35 @@ enum SettingsKeyContainer implements MutableKeyContainer { INSTANCE; { - setSerializerIfAbsent(Instant.class, new InstantSerializer()); + this.setSerializerIfAbsent(Instant.class, new InstantSerializer()); } @SuppressWarnings("unchecked") @Override public Optional getOptional(final Key key) { - final var name = toInternalKey(key); + final var name = this.toInternalKey(key); return Optional.ofNullable((V) Core.settings.get(name, Core.settings.getDefault(name))); } @Override public boolean contains(final Key key) { - return Core.settings.has(toInternalKey(key)); + return Core.settings.has(this.toInternalKey(key)); } @Override public Set> getKeys() { final var keys = new HashSet>(); - for (final var key : Core.settings.keys()) keys.add(fromInternalKey(key)); + for (final var key : Core.settings.keys()) keys.add(this.fromInternalKey(key)); return keys; } @SuppressWarnings("unchecked") @Override public @Nullable V set(final Key key, final V value) { - if (!isSupportedType(value.getClass())) { + if (!this.isSupportedType(value.getClass())) { throw new IllegalArgumentException("Unsupported type: " + value.getClass()); } - final var name = toInternalKey(key); + final var name = this.toInternalKey(key); final var previous = Core.settings.get(name, null); Core.settings.put(name, value); return (V) previous; @@ -69,7 +69,7 @@ public Set> getKeys() { @SuppressWarnings("unchecked") @Override public @Nullable V remove(final Key key) { - final var name = toInternalKey(key); + final var name = this.toInternalKey(key); final var previous = Core.settings.get(name, null); Core.settings.remove(name); return (V) previous; diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/permission/ImmutablePermissionTree.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/permission/ImmutablePermissionTree.java index 0f21fbf5..0eedcc5c 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/permission/ImmutablePermissionTree.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/permission/ImmutablePermissionTree.java @@ -27,11 +27,11 @@ record ImmutablePermissionTree(PermissionTree inner) implements PermissionTree { @Override public TriState getPermission(final String permission) { - return inner.getPermission(permission); + return this.inner.getPermission(permission); } @Override public Map getPermissions() { - return inner.getPermissions(); + return this.inner.getPermissions(); } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/permission/MutablePermissionTree.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/permission/MutablePermissionTree.java index 4f647e20..eb6ef55d 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/permission/MutablePermissionTree.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/permission/MutablePermissionTree.java @@ -39,7 +39,7 @@ static MutablePermissionTree create() { * @param state the state */ default void setPermission(final String permission, final boolean state) { - setPermission(permission, state, false); + this.setPermission(permission, state, false); } /** @@ -49,7 +49,7 @@ default void setPermission(final String permission, final boolean state) { * @param state the state */ default void setPermission(final String permission, final TriState state) { - setPermission(permission, state, false); + this.setPermission(permission, state, false); } /** @@ -60,7 +60,7 @@ default void setPermission(final String permission, final TriState state) { * @param override whether to override the child permissions with the new state */ default void setPermission(final String permission, final boolean state, final boolean override) { - setPermission(permission, TriState.of(state), override); + this.setPermission(permission, TriState.of(state), override); } /** @@ -78,7 +78,7 @@ default void setPermission(final String permission, final boolean state, final b * @param tree the permission tree */ default void setPermissions(final PermissionTree tree) { - setPermissions(tree, false); + this.setPermissions(tree, false); } /** @@ -89,7 +89,7 @@ default void setPermissions(final PermissionTree tree) { */ default void setPermissions(final PermissionTree tree, final boolean override) { for (final var entry : tree.getPermissions().entrySet()) { - setPermission(entry.getKey(), entry.getValue(), override); + this.setPermission(entry.getKey(), entry.getValue(), override); } } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/permission/MutablePermissionTreeImpl.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/permission/MutablePermissionTreeImpl.java index 2f16677a..2dc2486f 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/permission/MutablePermissionTreeImpl.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/permission/MutablePermissionTreeImpl.java @@ -43,7 +43,7 @@ private MutablePermissionTreeImpl(final @Nullable MutablePermissionTreeImpl pare @Override public TriState getPermission(String permission) { permission = permission.toLowerCase(Locale.ROOT); - checkPermission(permission); + this.checkPermission(permission); var state = TriState.UNDEFINED; var node = this; for (final var part : permission.split("\\.", -1)) { @@ -78,7 +78,7 @@ public Map getPermissions() { @Override public void setPermission(String permission, final TriState state, boolean override) { permission = permission.toLowerCase(Locale.ROOT); - checkPermission(permission); + this.checkPermission(permission); final var parts = permission.split("\\.", -1); var node = this; if (state != TriState.UNDEFINED) { diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/player/MUUID.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/player/MUUID.java index 221074cf..4cdcf290 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/player/MUUID.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/player/MUUID.java @@ -159,7 +159,7 @@ default byte[] getUuidAsBytes() { * Returns the UUID as a long. Beware the long does not include the crc32 checksum. */ default long getUuidAsLong() { - return ByteBuffer.wrap(getUuidAsBytes()).getLong(); + return ByteBuffer.wrap(this.getUuidAsBytes()).getLong(); } /** @@ -178,7 +178,7 @@ default byte[] getUsidAsBytes() { * Returns the USID as a long. */ default long getUsidAsLong() { - return ByteBuffer.wrap(getUsidAsBytes()).getLong(); + return ByteBuffer.wrap(this.getUsidAsBytes()).getLong(); } /** @@ -188,7 +188,7 @@ default long getUsidAsLong() { */ default UUID toRealUUID() { final var buffer = ByteBuffer.allocate(16); - final var uuid = getUuidAsBytes(); + final var uuid = this.getUuidAsBytes(); buffer.put(uuid, 0, 4); // First 4 bytes buffer.putShort((short) 0); // Next 2 bytes buffer.putShort((short) 0x8000); // Version is 4 bits, put set to v8 diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/player/PlayerLookup.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/player/PlayerLookup.java index e10b8c41..8a1a0d37 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/player/PlayerLookup.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/player/PlayerLookup.java @@ -50,7 +50,7 @@ static PlayerLookup create() { * @return the matching players */ default List findOnlinePlayers(final Query query) { - return findOnlinePlayers(MindustryCollections.immutableList(Groups.player), query); + return this.findOnlinePlayers(MindustryCollections.immutableList(Groups.player), query); } /** @@ -101,7 +101,7 @@ default Set getFields() { } /** - * Whether to return a singular result if a exact match is found. + * Whether to return a singular result if an exact match is found. * Defaults to {@code true}. */ @Value.Default @@ -117,7 +117,7 @@ interface Builder { Builder setInput(final String queryInput); default Builder setFields(final Field... fields) { - return setFields(Set.of(fields)); + return this.setFields(Set.of(fields)); } Builder setFields(final Iterable fields); diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/plugin/AbstractMindustryPlugin.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/plugin/AbstractMindustryPlugin.java index d27a791c..04c6ed58 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/plugin/AbstractMindustryPlugin.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/plugin/AbstractMindustryPlugin.java @@ -117,7 +117,7 @@ public Fi getConfig() { } private void forEachListener(final Consumer consumer) { - forEachListener(consumer, true); + this.forEachListener(consumer, true); } @SuppressWarnings("ForLoopReplaceableByForEach") @@ -149,7 +149,8 @@ public void update() { @Override public String toString() { - return "PluginApplicationListener{plugin=" + plugin.getMetadata().getName() + "}"; + return "PluginApplicationListener{plugin=" + + this.plugin.getMetadata().getName() + "}"; } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/plugin/WrappingMindustryPlugin.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/plugin/WrappingMindustryPlugin.java index be75e92e..3bbe35cc 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/plugin/WrappingMindustryPlugin.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/plugin/WrappingMindustryPlugin.java @@ -43,7 +43,7 @@ public void onServerCommandsRegistration(final CommandHandler handler) { @Override public Logger getLogger() { - return LoggerFactory.getLogger(plugin.getClass()); + return LoggerFactory.getLogger(this.plugin.getClass()); } @Override diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/scheduler/PluginTask.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/scheduler/PluginTask.java index 8ebda06d..9258ef05 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/scheduler/PluginTask.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/scheduler/PluginTask.java @@ -42,7 +42,7 @@ public interface PluginTask extends Future, Cancellable, PluginAware { */ @Override default void cancel() { - cancel(false); + this.cancel(false); } /** @@ -84,7 +84,7 @@ interface Builder { */ default Builder delay(final TemporalAmount delay) { final var duration = Duration.from(delay); - return delay(duration.toMillis(), MindustryTimeUnit.MILLISECONDS); + return this.delay(duration.toMillis(), MindustryTimeUnit.MILLISECONDS); } /** @@ -106,7 +106,7 @@ default Builder delay(final TemporalAmount delay) { */ default Builder repeat(final TemporalAmount interval) { final var duration = Duration.from(interval); - return repeat(duration.toMillis(), MindustryTimeUnit.MILLISECONDS); + return this.repeat(duration.toMillis(), MindustryTimeUnit.MILLISECONDS); } /** diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/MessageFormatTranslationImpl.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/MessageFormatTranslationImpl.java index 54778c05..08c16d4c 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/MessageFormatTranslationImpl.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/MessageFormatTranslationImpl.java @@ -46,24 +46,24 @@ record MessageFormatTranslationImpl(String pattern, Locale locale) implements Me @Override public String getPattern() { - return pattern; + return this.pattern; } @Override public Locale getLocale() { - return locale; + return this.locale; } @Override public String format(final TranslationArguments parameters) { - return createFormat().format(getArguments(parameters).toArray()); + return this.createFormat().format(this.getArguments(parameters).toArray()); } @SuppressWarnings({"JdkObsolete", "removal"}) @Override public void formatTo(final TranslationArguments parameters, final ComponentStringBuilder builder) { - final var format = createFormat(); - final var arguments = getArguments(parameters); + final var format = this.createFormat(); + final var arguments = this.getArguments(parameters); if (arguments.isEmpty()) { builder.append(format.format(null)); return; @@ -79,7 +79,7 @@ public void formatTo(final TranslationArguments parameters, final ComponentStrin builder.append(unformatted, iterator.getIndex(), end); } else { if (index >= arguments.size()) { - throw new IllegalArgumentException("Argument index out of bounds for '" + pattern + throw new IllegalArgumentException("Argument index out of bounds for '" + this.pattern + "': Maximum index is " + Math.max(0, arguments.size() - 1) + ", got " + index); } var argument = arguments.get(index); @@ -149,6 +149,6 @@ private List getArguments(final TranslationArguments arguments) { } private MessageFormat createFormat() { - return new MessageFormat(pattern, locale); + return new MessageFormat(this.pattern, this.locale); } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/ResourceBundles.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/ResourceBundles.java index e8f2fcee..918af305 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/ResourceBundles.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/ResourceBundles.java @@ -160,7 +160,7 @@ private PropertyResourceBundleWithLocale(final Reader reader, final Locale local @Override public Locale getLocale() { - return locale; + return this.locale; } } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/RouterTranslationSource.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/RouterTranslationSource.java index 20a69f80..48016e82 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/RouterTranslationSource.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/RouterTranslationSource.java @@ -34,6 +34,6 @@ enum RouterTranslationSource implements TranslationSource { @Override public String toString() { - return getClass().getSimpleName(); + return this.getClass().getSimpleName(); } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/TranslationSource.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/TranslationSource.java index 0d7dd234..24b73564 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/TranslationSource.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/TranslationSource.java @@ -52,7 +52,7 @@ static TranslationSource router() { */ default Translation getTranslationOrDefault( final String key, final Locale locale, final Function fallback) { - final var translation = getTranslation(key, locale); + final var translation = this.getTranslation(key, locale); return translation != null ? translation : fallback.apply(key); } @@ -64,6 +64,6 @@ default Translation getTranslationOrDefault( * @return the translation */ default Translation getTranslationOrMissing(final String key, final Locale locale) { - return getTranslationOrDefault(key, locale, k -> TextTranslation.of("???" + k + "???")); + return this.getTranslationOrDefault(key, locale, k -> TextTranslation.of("???" + k + "???")); } } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/util/TypeToken.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/util/TypeToken.java index 4e55150a..6770c1c1 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/util/TypeToken.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/util/TypeToken.java @@ -49,12 +49,12 @@ public static TypeToken of(final Type type) { protected TypeToken() { // Taken from guava TypeToken - final var superclass = getClass().getGenericSuperclass(); + final var superclass = this.getClass().getGenericSuperclass(); if (!(superclass instanceof ParameterizedType parameterized)) { throw new IllegalStateException(String.format("%s isn't parameterized", superclass)); } this.type = parameterized.getActualTypeArguments()[0]; - this.rawType = GenericTypeReflector.erase(type); + this.rawType = GenericTypeReflector.erase(this.type); } protected TypeToken(final Type type) { @@ -82,6 +82,6 @@ public boolean equals(final Object obj) { @Override public String toString() { - return "TypeToken{type=" + type + '}'; + return "TypeToken{type=" + this.type + '}'; } } diff --git a/distributor-common-api/src/test/java/com/xpdustry/distributor/api/annotation/EventHandlerProcessorTest.java b/distributor-common-api/src/test/java/com/xpdustry/distributor/api/annotation/EventHandlerProcessorTest.java index 8a7a1abb..0e1475b6 100644 --- a/distributor-common-api/src/test/java/com/xpdustry/distributor/api/annotation/EventHandlerProcessorTest.java +++ b/distributor-common-api/src/test/java/com/xpdustry/distributor/api/annotation/EventHandlerProcessorTest.java @@ -52,7 +52,7 @@ void setup() { this.processor = new EventHandlerProcessor(new TestPlugin("test")); this.events = new EventBusImpl(); final var distributor = Mockito.mock(Distributor.class); - Mockito.when(distributor.getPluginScheduler()).thenReturn(scheduler); + Mockito.when(distributor.getPluginScheduler()).thenReturn(this.scheduler); Mockito.when(distributor.getEventBus()).thenReturn(this.events); Distributor.set(distributor); } diff --git a/distributor-common-api/src/test/java/com/xpdustry/distributor/api/annotation/TaskHandlerProcessorTest.java b/distributor-common-api/src/test/java/com/xpdustry/distributor/api/annotation/TaskHandlerProcessorTest.java index 86e584b4..5c1d405b 100644 --- a/distributor-common-api/src/test/java/com/xpdustry/distributor/api/annotation/TaskHandlerProcessorTest.java +++ b/distributor-common-api/src/test/java/com/xpdustry/distributor/api/annotation/TaskHandlerProcessorTest.java @@ -52,7 +52,7 @@ public final class TaskHandlerProcessorTest { @BeforeEach void setup() { final var distributor = Mockito.mock(Distributor.class); - Mockito.when(distributor.getPluginScheduler()).thenReturn(scheduler); + Mockito.when(distributor.getPluginScheduler()).thenReturn(this.scheduler); Distributor.set(distributor); } @@ -64,34 +64,34 @@ void clear() { @Test void test_simple() { final var instance = new TestSimple(); - new TaskHandlerProcessor(plugin).process(instance); + new TaskHandlerProcessor(this.plugin).process(instance); assertThat(instance.future).succeedsWithin(Duration.ofSeconds(1L).plus(PRECISION)); } @Test void test_cancellable_parameter() throws InterruptedException { final var instance = new TestCancellableParameter(); - new TaskHandlerProcessor(plugin).process(instance); + new TaskHandlerProcessor(this.plugin).process(instance); Thread.sleep(500L); assertThat(instance.counter).hasValue(3); } @Test void test_invalid_parameter() { - assertThatThrownBy(() -> new TaskHandlerProcessor(plugin).process(new TestInvalidParameter())) + assertThatThrownBy(() -> new TaskHandlerProcessor(this.plugin).process(new TestInvalidParameter())) .isInstanceOf(IllegalArgumentException.class); } @Test void test_too_many_parameters() { - assertThatThrownBy(() -> new TaskHandlerProcessor(plugin).process(new TestTooManyParameters())) + assertThatThrownBy(() -> new TaskHandlerProcessor(this.plugin).process(new TestTooManyParameters())) .isInstanceOf(IllegalArgumentException.class); } @Test void test_async() { final var instance = new TestAsync(); - new TaskHandlerProcessor(plugin).process(instance); + new TaskHandlerProcessor(this.plugin).process(instance); assertThat(instance.future) .succeedsWithin(Duration.ofSeconds(1L).plus(PRECISION), InstanceOfAssertFactories.STRING) .startsWith(PluginSchedulerImpl.DISTRIBUTOR_WORKER_BASE_NAME); @@ -103,7 +103,7 @@ private static final class TestSimple { @TaskHandler(delay = 1, unit = MindustryTimeUnit.SECONDS) public void task() { - future.complete(true); + this.future.complete(true); } } @@ -113,7 +113,7 @@ private static final class TestCancellableParameter { @TaskHandler(interval = 100, unit = MindustryTimeUnit.MILLISECONDS) public void task(final Cancellable cancellable) { - if (counter.incrementAndGet() == 3) { + if (this.counter.incrementAndGet() == 3) { cancellable.cancel(); } } @@ -137,7 +137,7 @@ private static final class TestAsync { @TaskHandler(async = true) public void task() { - future.complete(Thread.currentThread().getName()); + this.future.complete(Thread.currentThread().getName()); } } } diff --git a/distributor-common-api/src/test/java/com/xpdustry/distributor/api/annotation/TriggerHandlerProcessorTest.java b/distributor-common-api/src/test/java/com/xpdustry/distributor/api/annotation/TriggerHandlerProcessorTest.java index 96147ea3..e6b13950 100644 --- a/distributor-common-api/src/test/java/com/xpdustry/distributor/api/annotation/TriggerHandlerProcessorTest.java +++ b/distributor-common-api/src/test/java/com/xpdustry/distributor/api/annotation/TriggerHandlerProcessorTest.java @@ -52,7 +52,7 @@ void setup() { this.processor = new TriggerHandlerProcessor(new TestPlugin("test")); this.events = new EventBusImpl(); final var distributor = Mockito.mock(Distributor.class); - Mockito.when(distributor.getPluginScheduler()).thenReturn(scheduler); + Mockito.when(distributor.getPluginScheduler()).thenReturn(this.scheduler); Mockito.when(distributor.getEventBus()).thenReturn(this.events); Distributor.set(distributor); } diff --git a/distributor-common-api/src/test/java/com/xpdustry/distributor/api/component/TranslatableComponentTest.java b/distributor-common-api/src/test/java/com/xpdustry/distributor/api/component/TranslatableComponentTest.java index 9408f4d3..6ecb7f28 100644 --- a/distributor-common-api/src/test/java/com/xpdustry/distributor/api/component/TranslatableComponentTest.java +++ b/distributor-common-api/src/test/java/com/xpdustry/distributor/api/component/TranslatableComponentTest.java @@ -34,7 +34,7 @@ public final class TranslatableComponentTest { @Test void test_content() { for (final var category : CTypeKey.ALL) { - test_content(category); + this.test_content(category); } } diff --git a/distributor-common-api/src/test/java/com/xpdustry/distributor/api/component/render/MindustryComponentStringBuilderTest.java b/distributor-common-api/src/test/java/com/xpdustry/distributor/api/component/render/MindustryComponentStringBuilderTest.java index 6d6fce88..ed639cc7 100644 --- a/distributor-common-api/src/test/java/com/xpdustry/distributor/api/component/render/MindustryComponentStringBuilderTest.java +++ b/distributor-common-api/src/test/java/com/xpdustry/distributor/api/component/render/MindustryComponentStringBuilderTest.java @@ -65,35 +65,35 @@ static void cleanup() { @Test void test_append_text_simple() { - final var builder = createBuilder(); + final var builder = this.createBuilder(); builder.append("Hello, World!"); assertEquals("Hello, World!", builder.toString()); } @Test void test_append_escaped_text() { - final var builder = createBuilder(); + final var builder = this.createBuilder(); builder.append("Hello, [World]!"); assertEquals("Hello, [[World]!", builder.toString()); } @Test void test_append_component_simple() { - final var builder = createBuilder(); + final var builder = this.createBuilder(); builder.append(text("Hello, World!")); assertEquals("Hello, World!", builder.toString()); } @Test void test_append_component_colored() { - final var builder = createBuilder(); + final var builder = this.createBuilder(); builder.append(text("Hello, World!", ComponentColor.RED)); assertEquals("[#FF0000]Hello, World![]", builder.toString()); } @Test void test_append_nested_components() { - final var builder = createBuilder(); + final var builder = this.createBuilder(); builder.append(ListComponent.components( ComponentColor.RED, text("Hello, "), text("World", ComponentColor.GREEN), text("!"))); assertEquals("[#FF0000]Hello, [#00FF00]World[]![]", builder.toString()); @@ -101,7 +101,7 @@ void test_append_nested_components() { @Test void test_append_component_duplicate_colors() { - final var builder = createBuilder(); + final var builder = this.createBuilder(); builder.append(ListComponent.components( ComponentColor.RED, text("Hello, ", ComponentColor.RED), @@ -115,10 +115,10 @@ void test_append_translatable_simple() { final var component = translatable("greeting", ComponentColor.RED); assertEquals( "[#FF0000]Bonjour[]", - createBuilder(Locale.FRENCH).append(component).toString()); + this.createBuilder(Locale.FRENCH).append(component).toString()); assertEquals( "[#FF0000]Hello[]", - createBuilder(Locale.ENGLISH).append(component).toString()); + this.createBuilder(Locale.ENGLISH).append(component).toString()); } @Test @@ -127,17 +127,17 @@ void test_translatable_arguments() { "describe-number", TranslationArguments.array(number(0, ComponentColor.YELLOW)), ComponentColor.RED); assertEquals( "[#FF0000]The [[number] is [#FFFF00]zero[][]", - createBuilder().append(component1).toString()); + this.createBuilder().append(component1).toString()); final var component2 = translatable("describe-number", TranslationArguments.array(0), ComponentColor.RED); assertEquals( "[#FF0000]The [[number] is zero[]", - createBuilder().append(component2).toString()); + this.createBuilder().append(component2).toString()); final var component3 = translatable("describe-number", TranslationArguments.array("0"), ComponentColor.RED); assertEquals( "[#FF0000]The [[number] is 0[]", - createBuilder().append(component3).toString()); + this.createBuilder().append(component3).toString()); } private MindustryComponentStringBuilder createBuilder(final Locale locale) { @@ -149,6 +149,6 @@ private MindustryComponentStringBuilder createBuilder(final Locale locale) { } private MindustryComponentStringBuilder createBuilder() { - return createBuilder(Locale.ENGLISH); + return this.createBuilder(Locale.ENGLISH); } } diff --git a/distributor-common-api/src/test/java/com/xpdustry/distributor/api/player/SimplePlayerLookupTest.java b/distributor-common-api/src/test/java/com/xpdustry/distributor/api/player/SimplePlayerLookupTest.java index bd82a145..cea8eae0 100644 --- a/distributor-common-api/src/test/java/com/xpdustry/distributor/api/player/SimplePlayerLookupTest.java +++ b/distributor-common-api/src/test/java/com/xpdustry/distributor/api/player/SimplePlayerLookupTest.java @@ -43,27 +43,27 @@ public final class SimplePlayerLookupTest { @Test void find_by_name_simple() { - assertQueryResult(PlayerLookup.Query.of("phinner"), PLAYER_3); + this.assertQueryResult(PlayerLookup.Query.of("phinner"), PLAYER_3); } @Test void find_by_name_colored() { - assertQueryResult(PlayerLookup.Query.of("[green]phinner"), PLAYER_3); + this.assertQueryResult(PlayerLookup.Query.of("[green]phinner"), PLAYER_3); } @Test void find_by_name_partial() { - assertQueryResult(PlayerLookup.Query.of("de"), PLAYER_1, PLAYER_2); + this.assertQueryResult(PlayerLookup.Query.of("de"), PLAYER_1, PLAYER_2); } @Test void find_by_name_exact() { - assertQueryResult(PlayerLookup.Query.of("deez"), PLAYER_1); + this.assertQueryResult(PlayerLookup.Query.of("deez"), PLAYER_1); } @Test void find_by_name_exact_with_all() { - assertQueryResult( + this.assertQueryResult( PlayerLookup.Query.builder() .setInput("deez") .setMatchExact(false) @@ -74,29 +74,29 @@ void find_by_name_exact_with_all() { @Test void find_by_name_accents() { - assertQueryResult(PlayerLookup.Query.of("phînnér"), PLAYER_3); + this.assertQueryResult(PlayerLookup.Query.of("phînnér"), PLAYER_3); } @Test void find_by_names_multiple_exact() { - assertQueryResult(PlayerLookup.Query.of("zeta"), PLAYER_4, PLAYER_5); + this.assertQueryResult(PlayerLookup.Query.of("zeta"), PLAYER_4, PLAYER_5); } @Test void find_by_entity_id_exact() { - assertQueryResult(PlayerLookup.Query.of("#4"), PLAYER_4); + this.assertQueryResult(PlayerLookup.Query.of("#4"), PLAYER_4); } @Test void find_by_entity_id_with_all() { - assertQueryResult( + this.assertQueryResult( PlayerLookup.Query.builder().setInput("#4").setMatchExact(false).build(), PLAYER_4, PLAYER_7); } @Test void find_by_uuid() { - assertQueryResult(PlayerLookup.Query.of(PLAYER_3.uuid())); - assertQueryResult( + this.assertQueryResult(PlayerLookup.Query.of(PLAYER_3.uuid())); + this.assertQueryResult( PlayerLookup.Query.builder() .setInput(PLAYER_3.uuid()) .addField(PlayerLookup.Field.UUID) @@ -106,7 +106,7 @@ void find_by_uuid() { @Test void find_by_uuid_with_all() { - assertQueryResult( + this.assertQueryResult( PlayerLookup.Query.builder() .setInput(PLAYER_1.uuid()) .setFields(PlayerLookup.Field.values()) diff --git a/distributor-common-api/src/test/java/com/xpdustry/distributor/api/test/ManageScheduler.java b/distributor-common-api/src/test/java/com/xpdustry/distributor/api/test/ManageScheduler.java index be1809e1..1760945c 100644 --- a/distributor-common-api/src/test/java/com/xpdustry/distributor/api/test/ManageScheduler.java +++ b/distributor-common-api/src/test/java/com/xpdustry/distributor/api/test/ManageScheduler.java @@ -47,8 +47,8 @@ public final class ManageScheduler @Override public void beforeAll(final ExtensionContext context) { - updater.scheduleAtFixedRate( - () -> schedulers.values().forEach(PluginSchedulerImpl::onPluginUpdate), + this.updater.scheduleAtFixedRate( + () -> this.schedulers.values().forEach(PluginSchedulerImpl::onPluginUpdate), 16L, 16L, TimeUnit.MILLISECONDS); @@ -67,7 +67,7 @@ public void beforeEach(final ExtensionContext context) { try { final var scheduler = new PluginSchedulerImpl(PluginTimeSource.standard(), Runnable::run, 4); ReflectionUtils.makeAccessible(field).set(context.getRequiredTestInstance(), scheduler); - schedulers.put(field, scheduler); + this.schedulers.put(field, scheduler); } catch (final Throwable t) { ExceptionUtils.throwAsUncheckedException(t); } @@ -78,8 +78,8 @@ public void beforeEach(final ExtensionContext context) { public void afterEach(final ExtensionContext context) { findAnnotatedFields(context.getRequiredTestClass(), TestScheduler.class, ReflectionUtils::isNotStatic) .forEach(field -> { - final var scheduler = - Objects.requireNonNull(schedulers.remove(field), "Scheduler not found for field: " + field); + final var scheduler = Objects.requireNonNull( + this.schedulers.remove(field), "Scheduler not found for field: " + field); try { if (scheduler != ReflectionUtils.makeAccessible(field).get(context.getRequiredTestInstance())) { throw new ExtensionConfigurationException( @@ -95,7 +95,7 @@ public void afterEach(final ExtensionContext context) { @SuppressWarnings("ResultOfMethodCallIgnored") @Override public void afterAll(final ExtensionContext context) throws Exception { - updater.shutdown(); - updater.awaitTermination(1, TimeUnit.SECONDS); + this.updater.shutdown(); + this.updater.awaitTermination(1, TimeUnit.SECONDS); } } diff --git a/distributor-common-api/src/test/java/com/xpdustry/distributor/api/translation/BundleTranslationSourceImplTest.java b/distributor-common-api/src/test/java/com/xpdustry/distributor/api/translation/BundleTranslationSourceImplTest.java index b9a8e051..8a536800 100644 --- a/distributor-common-api/src/test/java/com/xpdustry/distributor/api/translation/BundleTranslationSourceImplTest.java +++ b/distributor-common-api/src/test/java/com/xpdustry/distributor/api/translation/BundleTranslationSourceImplTest.java @@ -28,7 +28,7 @@ public final class BundleTranslationSourceImplTest { @Test void test_get_translation() { - final var registry = createSource(Locale.ENGLISH); + final var registry = this.createSource(Locale.ENGLISH); registry.register("greeting", Locale.FRENCH, TextTranslation.of("Bonjour")); registry.register("greeting", Locale.ENGLISH, TextTranslation.of("Hello")); @@ -55,7 +55,7 @@ void test_get_translation() { @Test void test_unregister() { - final var registry = createSource(Locale.ENGLISH); + final var registry = this.createSource(Locale.ENGLISH); registry.register("greeting", Locale.FRENCH, TextTranslation.of("Bonjour")); registry.register("greeting", Locale.ENGLISH, TextTranslation.of("Hello")); @@ -90,7 +90,7 @@ void test_unregister() { @Test void test_illegal_register() { - final var registry = createSource(Locale.ENGLISH); + final var registry = this.createSource(Locale.ENGLISH); registry.register("greeting", Locale.FRENCH, TextTranslation.of("Bonjour")); assertThatThrownBy(() -> registry.register("greeting", Locale.FRENCH, TextTranslation.of("Bonjour"))) .isInstanceOf(IllegalArgumentException.class); diff --git a/distributor-common/src/main/java/com/xpdustry/distributor/common/DistributorCommonPlugin.java b/distributor-common/src/main/java/com/xpdustry/distributor/common/DistributorCommonPlugin.java index 6bb222ee..d9852d96 100644 --- a/distributor-common/src/main/java/com/xpdustry/distributor/common/DistributorCommonPlugin.java +++ b/distributor-common/src/main/java/com/xpdustry/distributor/common/DistributorCommonPlugin.java @@ -49,14 +49,14 @@ public final class DistributorCommonPlugin extends AbstractMindustryPlugin implements Distributor { private final ServiceManager services = new ServiceManagerImpl(); - private final TranslationSource source = new ServiceTranslationSource(services); + private final TranslationSource source = new ServiceTranslationSource(this.services); private final EventBus events = new EventBusImpl(); private final PluginScheduler scheduler = new PluginSchedulerImpl( PluginTimeSource.mindustry(), Core.app::post, Runtime.getRuntime().availableProcessors()); private final ComponentRendererProvider componentRendererProvider = new ServiceComponentRendererProvider(this.services); private final ComponentDecoder mindustryComponentDecoder = MindustryDecoderImpl.INSTANCE; - private final AudienceProvider audienceProvider = new AudienceProviderImpl(this, events); + private final AudienceProvider audienceProvider = new AudienceProviderImpl(this, this.events); private @Nullable PlayerLookup lookup = null; private @Nullable PlayerPermissionProvider permissions = null; @@ -72,7 +72,7 @@ public EventBus getEventBus() { @Override public PlayerPermissionProvider getPlayerPermissionProvider() { - return ensureInitialized(this.permissions, "player-permission-provider"); + return this.ensureInitialized(this.permissions, "player-permission-provider"); } @Override @@ -82,7 +82,7 @@ public TranslationSource getGlobalTranslationSource() { @Override public PlayerLookup getPlayerLookup() { - return ensureInitialized(this.lookup, "player-lookup"); + return this.ensureInitialized(this.lookup, "player-lookup"); } @Override @@ -92,12 +92,12 @@ public PluginScheduler getPluginScheduler() { @Override public ComponentRendererProvider getComponentRendererProvider() { - return componentRendererProvider; + return this.componentRendererProvider; } @Override public ComponentDecoder getMindustryComponentDecoder() { - return mindustryComponentDecoder; + return this.mindustryComponentDecoder; } @Override @@ -114,15 +114,15 @@ public void onInit() { this.services.register(this, TranslationSource.class, TranslationSource.router(), Priority.HIGH); final var mindustry = BundleTranslationSource.create(Locale.ENGLISH); mindustry.registerAll(ResourceBundles.fromClasspathDirectory( - getClass(), "com/xpdustry/distributor/common/bundles/", "mindustry_bundle")); + this.getClass(), "com/xpdustry/distributor/common/bundles/", "mindustry_bundle")); this.services.register(this, TranslationSource.class, mindustry); } @Override public void onLoad() { - this.lookup = services.provide(PlayerLookup.class).orElseGet(PlayerLookup::create); + this.lookup = this.services.provide(PlayerLookup.class).orElseGet(PlayerLookup::create); this.permissions = - services.provide(PlayerPermissionProvider.class).orElseGet(PlayerPermissionProvider::mindustry); + this.services.provide(PlayerPermissionProvider.class).orElseGet(PlayerPermissionProvider::mindustry); this.getLogger().info("Loaded distributor common api"); } diff --git a/distributor-common/src/main/java/com/xpdustry/distributor/common/audience/AudienceProviderImpl.java b/distributor-common/src/main/java/com/xpdustry/distributor/common/audience/AudienceProviderImpl.java index 35f191b7..e89675b5 100644 --- a/distributor-common/src/main/java/com/xpdustry/distributor/common/audience/AudienceProviderImpl.java +++ b/distributor-common/src/main/java/com/xpdustry/distributor/common/audience/AudienceProviderImpl.java @@ -50,38 +50,38 @@ public final class AudienceProviderImpl implements AudienceProvider { public AudienceProviderImpl(final MindustryPlugin plugin, final EventBus bus) { for (int i = 0; i < Team.all.length; i++) { - teams.put(i, new TeamAudience(i)); + this.teams.put(i, new TeamAudience(i)); } bus.subscribe( EventType.PlayerJoin.class, Priority.HIGHEST, plugin, - event -> players.put(MUUID.from(event.player), new PlayerAudienceImpl(event.player))); + event -> this.players.put(MUUID.from(event.player), new PlayerAudienceImpl(event.player))); bus.subscribe( EventType.PlayerLeave.class, Priority.LOWEST, plugin, - event -> players.remove(MUUID.from(event.player))); + event -> this.players.remove(MUUID.from(event.player))); bus.subscribe( EventType.ConnectPacketEvent.class, Priority.HIGHEST, plugin, - event -> connections.putIfAbsent(event.connection, NetConnectionMetadata.from(event.packet))); + event -> this.connections.putIfAbsent(event.connection, NetConnectionMetadata.from(event.packet))); } @Override public Audience getEveryone() { - return Audience.of(getPlayers(), getServer()); + return Audience.of(this.getPlayers(), this.getServer()); } @Override public Audience getPlayer(final MUUID muuid) { - return players.getOrDefault(muuid, Audience.empty()); + return this.players.getOrDefault(muuid, Audience.empty()); } @Override public Audience getPlayer(final String uuid) { - return players.entrySet().stream() + return this.players.entrySet().stream() .filter(e -> e.getKey().getUuid().equals(uuid)) .map(Map.Entry::getValue) .collect(Audience.collectToAudience()); @@ -89,15 +89,15 @@ public Audience getPlayer(final String uuid) { @Override public PlayerAudience getPlayer(final Player player) { - final var audience = (PlayerAudience) players.get(MUUID.from(player)); + final var audience = (PlayerAudience) this.players.get(MUUID.from(player)); return audience != null ? audience : new PlayerAudienceImpl(player); } @Override public Audience getConnection(final NetConnection connection) { final var player = connection.player; - if (player != null) return getPlayer(player); - return new NetConnectionAudienceImpl(connection, connections::get); + if (player != null) return this.getPlayer(player); + return new NetConnectionAudienceImpl(connection, this.connections::get); } @Override @@ -107,12 +107,12 @@ public Audience getServer() { @Override public Audience getPlayers() { - return Audience.of(Collections.unmodifiableCollection(players.values())); + return Audience.of(Collections.unmodifiableCollection(this.players.values())); } @Override public Audience getTeam(final Team team) { - final var audience = teams.get(team.id); + final var audience = this.teams.get(team.id); if (audience == null) throw new IllegalArgumentException("Unknown team: " + team); return audience; } @@ -132,15 +132,16 @@ private TeamAudience(final int id) { @Override public KeyContainer getMetadata() { - return metadata; + return this.metadata; } @Override public Iterable getAudiences() { - return getPlayers() + return AudienceProviderImpl.this + .getPlayers() .toStream() .filter(a -> Objects.equals( - a.getMetadata().getOptional(StandardKeys.TEAM).orElse(null), Team.get(id))) + a.getMetadata().getOptional(StandardKeys.TEAM).orElse(null), Team.get(this.id))) .toList(); } } diff --git a/distributor-common/src/main/java/com/xpdustry/distributor/common/audience/BaseNetConnectionAudience.java b/distributor-common/src/main/java/com/xpdustry/distributor/common/audience/BaseNetConnectionAudience.java index 9372cc2a..a7653dba 100644 --- a/distributor-common/src/main/java/com/xpdustry/distributor/common/audience/BaseNetConnectionAudience.java +++ b/distributor-common/src/main/java/com/xpdustry/distributor/common/audience/BaseNetConnectionAudience.java @@ -46,26 +46,26 @@ public BaseNetConnectionAudience(final NetConnection connection) { @Override public void sendMessage(final Component component) { - Call.sendMessage(this.connection, render(component), null, null); + Call.sendMessage(this.connection, this.render(component), null, null); } @Override public void sendMessage(final Component component, final Component unformatted, final Audience sender) { if (sender instanceof PlayerAudience other) { - Call.sendMessage(this.connection, render(component), render(unformatted), other.getPlayer()); + Call.sendMessage(this.connection, this.render(component), this.render(unformatted), other.getPlayer()); } else { - Call.sendMessage(this.connection, render(component), render(unformatted), null); + Call.sendMessage(this.connection, this.render(component), this.render(unformatted), null); } } @Override public void sendWarning(final Component component) { - Call.announce(this.connection, render(component)); + Call.announce(this.connection, this.render(component)); } @Override public void showHUDText(final Component component) { - Call.setHudText(this.connection, render(component)); + Call.setHudText(this.connection, this.render(component)); } @Override @@ -75,12 +75,12 @@ public void hideHUDText() { @Override public void sendNotification(final Component component, final char icon) { - Call.warningToast(this.connection, icon, render(component)); + Call.warningToast(this.connection, icon, this.render(component)); } @Override public void sendAnnouncement(final Component component) { - Call.infoMessage(this.connection, render(component)); + Call.infoMessage(this.connection, this.render(component)); } @Override @@ -90,12 +90,12 @@ public void openURI(final URI uri) { @Override public void showLabel(final Component label, final float x, final float y, final Duration duration) { - Call.label(this.connection, render(label), duration.toMillis() / 1000F, x, y); + Call.label(this.connection, this.render(label), duration.toMillis() / 1000F, x, y); } @Override public void kick(final Component reason, final Duration duration, final boolean log) { - this.kick(null, render(reason).replace('\n', ' '), duration.toMillis(), log); + this.kick(null, this.render(reason).replace('\n', ' '), duration.toMillis(), log); } @Override @@ -136,6 +136,8 @@ private void kick( } protected String render(final Component component) { - return ComponentStringBuilder.mindustry(getMetadata()).append(component).toString(); + return ComponentStringBuilder.mindustry(this.getMetadata()) + .append(component) + .toString(); } } diff --git a/distributor-common/src/main/java/com/xpdustry/distributor/common/audience/PlayerAudienceImpl.java b/distributor-common/src/main/java/com/xpdustry/distributor/common/audience/PlayerAudienceImpl.java index f7b94928..9fb1706f 100644 --- a/distributor-common/src/main/java/com/xpdustry/distributor/common/audience/PlayerAudienceImpl.java +++ b/distributor-common/src/main/java/com/xpdustry/distributor/common/audience/PlayerAudienceImpl.java @@ -54,7 +54,7 @@ public final class PlayerAudienceImpl extends BaseNetConnectionAudience implemen @Override public KeyContainer getMetadata() { - return metadata; + return this.metadata; } @Override @@ -64,6 +64,6 @@ public PermissionContainer getPermissions() { @Override public Player getPlayer() { - return player; + return this.player; } } diff --git a/distributor-common/src/main/java/com/xpdustry/distributor/common/audience/ServerAudience.java b/distributor-common/src/main/java/com/xpdustry/distributor/common/audience/ServerAudience.java index ccb9f63b..66b91a61 100644 --- a/distributor-common/src/main/java/com/xpdustry/distributor/common/audience/ServerAudience.java +++ b/distributor-common/src/main/java/com/xpdustry/distributor/common/audience/ServerAudience.java @@ -41,22 +41,22 @@ public enum ServerAudience implements Audience { @Override public void sendMessage(final Component component) { - Log.info(render(component)); + Log.info(this.render(component)); } @Override public void sendMessage(final Component component, final Component unformatted, final Audience sender) { - Log.info(render(component)); + Log.info(this.render(component)); } @Override public void sendWarning(final Component component) { - Log.warn(render(component)); + Log.warn(this.render(component)); } @Override public KeyContainer getMetadata() { - return metadata; + return this.metadata; } @Override @@ -65,6 +65,6 @@ public PermissionContainer getPermissions() { } private String render(final Component component) { - return ComponentStringBuilder.ansi(getMetadata()).append(component).toString(); + return ComponentStringBuilder.ansi(this.getMetadata()).append(component).toString(); } } diff --git a/distributor-common/src/main/java/com/xpdustry/distributor/common/component/codec/MindustryDecoderImpl.java b/distributor-common/src/main/java/com/xpdustry/distributor/common/component/codec/MindustryDecoderImpl.java index 023faf3c..954b8554 100644 --- a/distributor-common/src/main/java/com/xpdustry/distributor/common/component/codec/MindustryDecoderImpl.java +++ b/distributor-common/src/main/java/com/xpdustry/distributor/common/component/codec/MindustryDecoderImpl.java @@ -76,7 +76,7 @@ public Component decode(final String input) { var color = Colors.get(value); if (color == null && value.charAt(0) == '#') { - color = tryParseHex(tcolor, value.substring(1)); + color = this.tryParseHex(tcolor, value.substring(1)); } if (color != null) { diff --git a/distributor-common/src/main/java/com/xpdustry/distributor/common/component/render/ServiceComponentRendererProvider.java b/distributor-common/src/main/java/com/xpdustry/distributor/common/component/render/ServiceComponentRendererProvider.java index 0f33c9f1..507ac06a 100644 --- a/distributor-common/src/main/java/com/xpdustry/distributor/common/component/render/ServiceComponentRendererProvider.java +++ b/distributor-common/src/main/java/com/xpdustry/distributor/common/component/render/ServiceComponentRendererProvider.java @@ -34,7 +34,7 @@ public ServiceComponentRendererProvider(final ServiceManager services) { @Override public @Nullable ComponentRenderer getRenderer(final T component) { - for (final var provider : services.getProviders(ComponentRendererProvider.class)) { + for (final var provider : this.services.getProviders(ComponentRendererProvider.class)) { final var renderer = provider.getInstance().getRenderer(component); if (renderer != null) return renderer; } diff --git a/distributor-common/src/test/java/com/xpdustry/distributor/common/component/codec/MindustryDecoderImplTest.java b/distributor-common/src/test/java/com/xpdustry/distributor/common/component/codec/MindustryDecoderImplTest.java index d77e1d8a..018f6bac 100644 --- a/distributor-common/src/test/java/com/xpdustry/distributor/common/component/codec/MindustryDecoderImplTest.java +++ b/distributor-common/src/test/java/com/xpdustry/distributor/common/component/codec/MindustryDecoderImplTest.java @@ -30,36 +30,36 @@ public final class MindustryDecoderImplTest { @Test void test_decode_plain() { - assertStringDecodesTo("Hello, World!", text("Hello, World!")); + this.assertStringDecodesTo("Hello, World!", text("Hello, World!")); } @Test void test_decode_color() { - assertStringDecodesTo("[#FF0000]Hello, World!", text("Hello, World!", ComponentColor.RED)); + this.assertStringDecodesTo("[#FF0000]Hello, World!", text("Hello, World!", ComponentColor.RED)); } @Test void test_escape_color() { - assertStringDecodesTo("[[#FF0000]Hello, World!", text("[#FF0000]Hello, World!")); + this.assertStringDecodesTo("[[#FF0000]Hello, World!", text("[#FF0000]Hello, World!")); } @Test void test_escape_left_brackets() { - assertStringDecodesTo("A[[[[[[[[Hello, World![[[[[", text("A[[[[Hello, World![[[")); - assertStringDecodesTo("[[[[[[[[Hello, World![[[[[", text("[[[[Hello, World![[[")); - assertStringDecodesTo("[[[[[[[[Hello, World![[[[[A", text("[[[[Hello, World![[[A")); + this.assertStringDecodesTo("A[[[[[[[[Hello, World![[[[[", text("A[[[[Hello, World![[[")); + this.assertStringDecodesTo("[[[[[[[[Hello, World![[[[[", text("[[[[Hello, World![[[")); + this.assertStringDecodesTo("[[[[[[[[Hello, World![[[[[A", text("[[[[Hello, World![[[A")); } @Test void test_escape_right_brackets() { - assertStringDecodesTo("A]]]]]]]]Hello, World!]]]]]", text("A]]]]]]]]Hello, World!]]]]]")); - assertStringDecodesTo("]]]]]]]]Hello, World!]]]]]", text("]]]]]]]]Hello, World!]]]]]")); - assertStringDecodesTo("]]]]]]]]Hello, World!]]]]]A", text("]]]]]]]]Hello, World!]]]]]A")); + this.assertStringDecodesTo("A]]]]]]]]Hello, World!]]]]]", text("A]]]]]]]]Hello, World!]]]]]")); + this.assertStringDecodesTo("]]]]]]]]Hello, World!]]]]]", text("]]]]]]]]Hello, World!]]]]]")); + this.assertStringDecodesTo("]]]]]]]]Hello, World!]]]]]A", text("]]]]]]]]Hello, World!]]]]]A")); } @Test void test_decode_nested_simple() { - assertStringDecodesTo( + this.assertStringDecodesTo( "[#ff0000]Hello, [#00FF00]World[]![]", ListComponent.components( text("Hello, ", ComponentColor.RED), @@ -69,7 +69,7 @@ void test_decode_nested_simple() { @Test void test_decode_nested_complex() { - assertStringDecodesTo( + this.assertStringDecodesTo( "[#ff0000]A[#00FF00][[B][]C[][][D][][#0000FF]E", ListComponent.components( text("A", ComponentColor.RED), @@ -81,7 +81,7 @@ void test_decode_nested_complex() { @Test void test_decode_color_with_alpha() { - assertStringDecodesTo("[#11223344]Hello, World!", text("Hello, World!", ComponentColor.rgb(0x112233))); + this.assertStringDecodesTo("[#11223344]Hello, World!", text("Hello, World!", ComponentColor.rgb(0x112233))); } private void assertStringDecodesTo(final String input, final Component expected) { diff --git a/distributor-permission-rank/src/main/java/com/xpdustry/distributor/api/permission/rank/LinearEnumRankNode.java b/distributor-permission-rank/src/main/java/com/xpdustry/distributor/api/permission/rank/LinearEnumRankNode.java index 76db24c7..8d460f00 100644 --- a/distributor-permission-rank/src/main/java/com/xpdustry/distributor/api/permission/rank/LinearEnumRankNode.java +++ b/distributor-permission-rank/src/main/java/com/xpdustry/distributor/api/permission/rank/LinearEnumRankNode.java @@ -39,11 +39,11 @@ public E getValue() { final var constants = this.value.getDeclaringClass().getEnumConstants(); if (this.ascending) { return (this.value.ordinal() > 0) - ? new LinearEnumRankNode<>(constants[this.value.ordinal() - 1], namespace, true) + ? new LinearEnumRankNode<>(constants[this.value.ordinal() - 1], this.namespace, true) : null; } else { return (this.value.ordinal() + 1 < constants.length) - ? new LinearEnumRankNode<>(constants[this.value.ordinal() + 1], namespace, false) + ? new LinearEnumRankNode<>(constants[this.value.ordinal() + 1], this.namespace, false) : null; } } diff --git a/distributor-permission-rank/src/main/java/com/xpdustry/distributor/api/permission/rank/YamlRankPermissionSource.java b/distributor-permission-rank/src/main/java/com/xpdustry/distributor/api/permission/rank/YamlRankPermissionSource.java index b033f515..cb2d6db7 100644 --- a/distributor-permission-rank/src/main/java/com/xpdustry/distributor/api/permission/rank/YamlRankPermissionSource.java +++ b/distributor-permission-rank/src/main/java/com/xpdustry/distributor/api/permission/rank/YamlRankPermissionSource.java @@ -55,7 +55,7 @@ final class YamlRankPermissionSource implements RankPermissionSource, PluginList @Override public void onPluginLoad() { try { - reload(); + this.reload(); } catch (final IOException error) { throw new RuntimeException("Failed to load permission file.", error); } @@ -65,7 +65,7 @@ public void onPluginLoad() { public void onPluginServerCommandsRegistration(final CommandHandler handler) { handler.register("rank-permission-reload", "Reload the permissions", $ -> { try { - reload(); + this.reload(); LOGGER.info("Reloaded rank permissions file"); } catch (final IOException e) { LOGGER.error("Failed to reload rank permission file", e); @@ -76,7 +76,7 @@ public void onPluginServerCommandsRegistration(final CommandHandler handler) { @Override public PermissionContainer getRankPermissions(final RankNode node) { synchronized (this.lock) { - return getRankPermissions0(node, new HashSet<>()); + return this.getRankPermissions0(node, new HashSet<>()); } } @@ -95,7 +95,7 @@ private PermissionTree getRankPermissions0(final RankNode node, final Set { assertThatThrownBy(() -> source.getRankPermissions(CircularRankNode.of(0))) @@ -83,7 +83,7 @@ void test_circular_detection() throws IOException { @Test void test_invalid_rank() { - final var source = createSource(TEST_CONFIG_INVALID_RANK); + final var source = this.createSource(TEST_CONFIG_INVALID_RANK); assertThatThrownBy(source::reload).isInstanceOf(IOException.class); } From 048bcf4d820320387dc433936dc5878b80964409 Mon Sep 17 00:00:00 2001 From: phinner <62483793+phinner@users.noreply.github.com> Date: Sat, 28 Dec 2024 23:11:05 +0100 Subject: [PATCH 08/11] chore: Annotate flawed methods in MenuGrid --- .../java/com/xpdustry/distributor/api/gui/menu/MenuGrid.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/MenuGrid.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/MenuGrid.java index 04bd39cf..33c2887d 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/MenuGrid.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/gui/menu/MenuGrid.java @@ -57,8 +57,10 @@ default MenuGrid addRow(final int index, final MenuOption... options) { MenuGrid addOption(final MenuOption option); + // TODO Flawed, it returns the input option instead of the grid MenuOption addOption(final int y, final MenuOption option); + // TODO Flawed, it returns the input option instead of the grid MenuOption addOption(final int x, final int y, final MenuOption option); MenuGrid removeOption(final int x, final int y); From e6737fbfbabd1790eb69c0f7c72102659f3032d8 Mon Sep 17 00:00:00 2001 From: phinner <62483793+phinner@users.noreply.github.com> Date: Mon, 30 Dec 2024 23:12:34 +0100 Subject: [PATCH 09/11] fix: Fix "GetClassOnEnum" warning --- .../distributor/api/translation/RouterTranslationSource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/RouterTranslationSource.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/RouterTranslationSource.java index 48016e82..d66a38bd 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/RouterTranslationSource.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/RouterTranslationSource.java @@ -34,6 +34,6 @@ enum RouterTranslationSource implements TranslationSource { @Override public String toString() { - return this.getClass().getSimpleName(); + return this.getDeclaringClass().getSimpleName(); } } From ea8b35f20b2f2c253b7d3227d536bbefbd1ee69e Mon Sep 17 00:00:00 2001 From: phinner <62483793+phinner@users.noreply.github.com> Date: Mon, 30 Dec 2024 23:14:04 +0100 Subject: [PATCH 10/11] fix: Fix crash caused by ResourceBundles#fromClasspathDirectory if the path contains invalid URL character --- .../api/translation/ResourceBundles.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/ResourceBundles.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/ResourceBundles.java index 918af305..3c0219b3 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/ResourceBundles.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/translation/ResourceBundles.java @@ -63,15 +63,20 @@ public static ResourceBundle fromFile(final Locale locale, final Path file) { */ public static List fromClasspathDirectory( final Class caller, final String directory, final String name) { - final var path = new File(caller.getProtectionDomain() - .getCodeSource() - .getLocation() - .getPath()) - .toPath(); - if (path.getFileName().toString().endsWith(".jar")) { - return fromZipDirectory(path, directory, name); - } else { - return fromDirectory(path.resolve(directory), name); + try { + final var path = new File(caller.getProtectionDomain() + .getCodeSource() + .getLocation() + .toURI()) + .toPath(); + if (path.getFileName().toString().endsWith(".jar")) { + return fromZipDirectory(path, directory, name); + } else { + return fromDirectory(path.resolve(directory), name); + } + } catch (final Exception e) { + throw new IllegalArgumentException( + "Failed to load resource bundles from classpath directory: " + directory, e); } } From e753737104debc3bb7f6b93b5ec81949fcd77940 Mon Sep 17 00:00:00 2001 From: phinner <62483793+phinner@users.noreply.github.com> Date: Mon, 30 Dec 2024 23:19:27 +0100 Subject: [PATCH 11/11] chore(deps): Update dependencies --- gradle/libs.versions.toml | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 22fb003c..0b063f69 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -18,7 +18,7 @@ geantyref = "2.0.0" # testing junit = "5.11.4" -assertj = "3.26.3" +assertj = "3.27.0" guava-testlib = "33.4.0-jre" mockito = "5.14.2" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e2847c82..cea7a793 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index f5feea6d..f3b75f3b 100755 --- a/gradlew +++ b/gradlew @@ -86,8 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s -' "$PWD" ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum