-
Notifications
You must be signed in to change notification settings - Fork 1
Developing
Cris edited this page Mar 16, 2025
·
4 revisions
You want create and add your custom tags? You can make it with my Register System Tag!
If you have the jar from Spigot, skip this step.
Open the project in IntellIJ, VSCode or your favorite code editor.
Compile the project with ./gradle build or use the jar on spigot
Choose MyMessage-REALEASE-all.jar
Open your project and setup the jar.
Reload your project.
You have 2 options of a Tag, NormalTags (replace a text) and PlayerTags (involves a player)
For example, a tag to use legacy colors with the MiniMessage format
public class LegacyTag implements NormalTags {
public static final LegacyTag LEGACY_TAG = new LegacyTag();
private static final Map<Character, String> MAP = new HashMap<>();
static {
MAP.put('a', "yellow");
MAP.put('b', "bold");
// More legacy - minimessage format
}
@Override
public @NotNull BiFunction<ArgumentQueue, Context, Tag> getFunction(TagImpl tag) {
return ((argumentQueue, context) -> {
final String value = argumentQueue.popOr("Put an argument").value();
final String result = MAP.getOrDefault(value.charAt(0), "white");
final String legacy = "<" + result + ">";
return Tag.preProcessParsed(legacy);
});
}
@Override
public @NotNull Component process(@NotNull Component component) {
return component;
}
@Override
public @NotNull Set<String> getNames() {
return Set.of("l", "legacy");
}
}
public final class MyTags extends JavaPlugin {
@Override
public void onEnable(){
BaseTag.addNormal(LegacyTag.LEGACY_TAG);
}
}For example, a tag to send a message to the player.
public class SendMessageTag implements PlayerTags {
public static final SendMessageTag MESSAGE_TAG = new SendMessageTag();
@Override
public @NotNull TagResolver getTagResolver(OfflinePlayer offlinePlayer) {
return TagResolver.resolver(
getNames(),
((argumentQueue, context) -> {
final String value = argumentQueue.popOr("Put the message").value();
final var component = ComponentProcessor.asMiniMessage(value, offlinePlayer);
offlinePlayer.sendMessage(component);
return Tag.preProcessParsed("");
})
);
}
@Override
public @NotNull Component process(@NotNull Component component) {
return component;
}
@Override
public @NotNull Set<String> getNames() {
return Set.of("send", "message");
}
}
public final class MyTags extends JavaPlugin {
@Override
public void onEnable(){
BaseTag.addPlayer(SendMessageTag.MESSAGE_TAG);
}
}