Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CubBossa committed Aug 14, 2024
1 parent 072e472 commit 6a39f3d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions TinyTranslations-bukkit-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>TinyTranslations-bukkit-example</artifactId>
<version>1.0.0</version>
<version>4.5.2</version>

<parent>
<groupId>de.cubbossa</groupId>
Expand Down Expand Up @@ -74,7 +74,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.4-R0.1-SNAPSHOT</version>
<version>1.21-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
package de.cubbossa.example;

import de.cubbossa.tinytranslations.BukkitTinyTranslations;
import de.cubbossa.tinytranslations.Message;
import de.cubbossa.tinytranslations.MessageTranslator;
import de.cubbossa.tinytranslations.storage.properties.PropertiesMessageStorage;
import de.cubbossa.tinytranslations.storage.properties.PropertiesStyleStorage;
import de.cubbossa.tinytranslations.tinyobject.TinyObjectMapping;
import de.cubbossa.tinytranslations.util.ComponentSplit;
import de.cubbossa.tinytranslations.util.ListSection;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.tag.Tag;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
Expand Down Expand Up @@ -43,10 +36,7 @@ public void onEnable() {
// {plugin.version} -> v5.0.0
// {plugin.author} -> CubBossa
translator.insertObject("plugin", getDescription());
translator.formatted(TagResolver.resolver("alphabeth", (argumentQueue, context) -> {
return Tag.inserting(Component.text("abcdefghijklmnopqrstuvwxyz"));
}));
translator.formatted(Placeholder.parsed("smile", ":D"));
translator.insertString("smile", ":D");

// We create all messages for this plugin at once
Messages.init(translator);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: TinyTranslations-bukkit-example
author: CubBossa
version: 1.0.0
version: 4.5.2

api-version: 1.16
prefix: PathFinder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,17 @@ default ReturnT insertTag(final @NotNull String key, Tag tag) {
return formatted(TagResolver.resolver(key, tag));
}

/**
* Short form of {@link TagResolver#resolver(String, Tag)}
*
* @param key The tag key
* @param handler A tag implementation to insert
* @return this object or a new object if the implementation is pure
*/
default ReturnT insertTag(final @NotNull String key, final @NotNull BiFunction<ArgumentQueue, Context, Tag> handler) {
return formatted(TagResolver.resolver(key, handler));
}

Map<String, InsertedObject> insertedObjects();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@ public MessageBuilder withPlaceholder(String tag, String description, @NotNull T
}

public Message build(MessageTranslator owner) {
return build().owner(owner);
var msg = build();
return msg instanceof UnownedMessage unowned ? unowned.owner(owner) : msg;
}

public UnownedMessage build() {
return (UnownedMessage) new UnownedMessageImpl(key)
public Message build() {
return new UnownedMessageImpl(key)
.comment(comments.isEmpty() ? null : String.join("\n", comments))
.dictionary(translations)
.placeholderDescriptions(placeholderDescriptions)
Expand Down

0 comments on commit 6a39f3d

Please sign in to comment.