mirror of
https://github.com/ashhhleyyy/player-pronouns.git
synced 2024-11-01 07:07:38 +00:00
feat: update to mc 1.19
This commit is contained in:
parent
bd0f788075
commit
f3a2a51591
8 changed files with 39 additions and 42 deletions
|
@ -1,10 +1,10 @@
|
||||||
plugins {
|
plugins {
|
||||||
id("fabric-loom") version "0.10.+"
|
id("fabric-loom") version "0.12.+"
|
||||||
id("io.github.juuxel.loom-quiltflower-mini") version "1.2.1"
|
id("io.github.juuxel.loom-quiltflower") version "1.7.+"
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
}
|
}
|
||||||
|
|
||||||
version = "1.4.0+1.18"
|
version = "1.4.0+1.19"
|
||||||
group = "io.github.ashhhleyyy"
|
group = "io.github.ashhhleyyy"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
@ -51,15 +51,15 @@ tasks.processResources {
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
sourceCompatibility = JavaVersion.VERSION_16
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
targetCompatibility = JavaVersion.VERSION_16
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
|
|
||||||
withSourcesJar()
|
withSourcesJar()
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<JavaCompile> {
|
tasks.withType<JavaCompile> {
|
||||||
options.encoding = "UTF-8"
|
options.encoding = "UTF-8"
|
||||||
options.release.set(16)
|
options.release.set(17)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.jar {
|
tasks.jar {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
[versions]
|
[versions]
|
||||||
minecraft = "1.18.1"
|
minecraft = "1.19"
|
||||||
yarn = "1.18.1+build.2"
|
yarn = "1.19+build.4"
|
||||||
|
|
||||||
fabric-loader = "0.12.11"
|
fabric-loader = "0.14.8"
|
||||||
fabric-api = "0.44.0+1.18"
|
fabric-api = "0.56.0+1.19"
|
||||||
|
|
||||||
placeholder-api = "1.1.3+1.17.1"
|
placeholder-api = "2.0.0-beta.4+1.19"
|
||||||
more-codecs = "0.2.1+1.18"
|
more-codecs = "0.2.2+1.18"
|
||||||
|
|
||||||
fabric-permissions = "0.1-SNAPSHOT"
|
fabric-permissions = "0.1-SNAPSHOT"
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package io.github.ashisbored.playerpronouns;
|
package io.github.ashisbored.playerpronouns;
|
||||||
|
|
||||||
import eu.pb4.placeholders.PlaceholderAPI;
|
import eu.pb4.placeholders.api.PlaceholderContext;
|
||||||
import eu.pb4.placeholders.PlaceholderContext;
|
import eu.pb4.placeholders.api.PlaceholderResult;
|
||||||
import eu.pb4.placeholders.PlaceholderResult;
|
import eu.pb4.placeholders.api.Placeholders;
|
||||||
import io.github.ashisbored.playerpronouns.command.PronounsCommand;
|
import io.github.ashisbored.playerpronouns.command.PronounsCommand;
|
||||||
import io.github.ashisbored.playerpronouns.data.PronounDatabase;
|
import io.github.ashisbored.playerpronouns.data.PronounDatabase;
|
||||||
import io.github.ashisbored.playerpronouns.data.PronounList;
|
import io.github.ashisbored.playerpronouns.data.PronounList;
|
||||||
import io.github.ashisbored.playerpronouns.data.Pronouns;
|
import io.github.ashisbored.playerpronouns.data.Pronouns;
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
@ -60,23 +60,23 @@ public class PlayerPronouns implements ModInitializer {
|
||||||
});
|
});
|
||||||
|
|
||||||
//noinspection CodeBlock2Expr
|
//noinspection CodeBlock2Expr
|
||||||
CommandRegistrationCallback.EVENT.register((dispatcher, __) -> {
|
CommandRegistrationCallback.EVENT.register((dispatcher, registry, env) -> {
|
||||||
PronounsCommand.register(dispatcher);
|
PronounsCommand.register(dispatcher);
|
||||||
});
|
});
|
||||||
|
|
||||||
PlaceholderAPI.register(new Identifier(MOD_ID, "pronouns"), ctx ->
|
Placeholders.register(new Identifier(MOD_ID, "pronouns"), (ctx, argument)->
|
||||||
PlayerPronouns.fromContext(ctx, true));
|
PlayerPronouns.fromContext(ctx, argument, true));
|
||||||
|
|
||||||
PlaceholderAPI.register(new Identifier(MOD_ID, "raw_pronouns"), ctx ->
|
Placeholders.register(new Identifier(MOD_ID, "raw_pronouns"), (ctx, argument)->
|
||||||
PlayerPronouns.fromContext(ctx, false));
|
PlayerPronouns.fromContext(ctx, argument, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PlaceholderResult fromContext(PlaceholderContext ctx, boolean formatted) {
|
private static PlaceholderResult fromContext(PlaceholderContext ctx, @Nullable String argument, boolean formatted) {
|
||||||
if (!ctx.hasPlayer()) {
|
if (!ctx.hasPlayer()) {
|
||||||
return PlaceholderResult.invalid("missing player");
|
return PlaceholderResult.invalid("missing player");
|
||||||
}
|
}
|
||||||
String defaultMessage = ctx.hasArgument() ? ctx.getArgument() : config.getDefaultPlaceholder();
|
String defaultMessage = argument != null ? argument : config.getDefaultPlaceholder();
|
||||||
ServerPlayerEntity player = ctx.getPlayer();
|
ServerPlayerEntity player = ctx.player();
|
||||||
if (pronounDatabase == null) {
|
if (pronounDatabase == null) {
|
||||||
return PlaceholderResult.value(defaultMessage);
|
return PlaceholderResult.value(defaultMessage);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ import io.github.ashisbored.playerpronouns.data.Pronouns;
|
||||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.text.LiteralText;
|
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Formatting;
|
import net.minecraft.util.Formatting;
|
||||||
|
|
||||||
|
@ -28,7 +27,7 @@ public class PronounsCommand {
|
||||||
|
|
||||||
Map<String, Text> pronounTexts = PronounList.get().getCalculatedPronounStrings();
|
Map<String, Text> pronounTexts = PronounList.get().getCalculatedPronounStrings();
|
||||||
if (!PlayerPronouns.config.allowCustom() && !pronounTexts.containsKey(pronounsString)) {
|
if (!PlayerPronouns.config.allowCustom() && !pronounTexts.containsKey(pronounsString)) {
|
||||||
ctx.getSource().sendError(new LiteralText("Custom pronouns have been disabled by the server administrator."));
|
ctx.getSource().sendError(Text.literal("Custom pronouns have been disabled by the server administrator."));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,13 +35,13 @@ public class PronounsCommand {
|
||||||
if (pronounTexts.containsKey(pronounsString)) {
|
if (pronounTexts.containsKey(pronounsString)) {
|
||||||
pronouns = new Pronouns(pronounsString, pronounTexts.get(pronounsString));
|
pronouns = new Pronouns(pronounsString, pronounTexts.get(pronounsString));
|
||||||
} else {
|
} else {
|
||||||
pronouns = new Pronouns(pronounsString, new LiteralText(pronounsString));
|
pronouns = new Pronouns(pronounsString, Text.literal(pronounsString));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PlayerPronouns.setPronouns(player, pronouns)) {
|
if (!PlayerPronouns.setPronouns(player, pronouns)) {
|
||||||
ctx.getSource().sendError(new LiteralText("Failed to update pronouns, sorry"));
|
ctx.getSource().sendError(Text.literal("Failed to update pronouns, sorry"));
|
||||||
} else {
|
} else {
|
||||||
ctx.getSource().sendFeedback(new LiteralText("Updated your pronouns to ")
|
ctx.getSource().sendFeedback(Text.literal("Updated your pronouns to ")
|
||||||
.append(pronouns.formatted())
|
.append(pronouns.formatted())
|
||||||
.formatted(Formatting.GREEN), false);
|
.formatted(Formatting.GREEN), false);
|
||||||
}
|
}
|
||||||
|
@ -53,16 +52,16 @@ public class PronounsCommand {
|
||||||
.requires(ctx -> Permissions.check(ctx, "playerpronouns.reload_config", 4))
|
.requires(ctx -> Permissions.check(ctx, "playerpronouns.reload_config", 4))
|
||||||
.executes(ctx -> {
|
.executes(ctx -> {
|
||||||
PlayerPronouns.reloadConfig();
|
PlayerPronouns.reloadConfig();
|
||||||
ctx.getSource().sendFeedback(new LiteralText("Reloaded the config!").formatted(Formatting.GREEN), true);
|
ctx.getSource().sendFeedback(Text.literal("Reloaded the config!").formatted(Formatting.GREEN), true);
|
||||||
return Command.SINGLE_SUCCESS;
|
return Command.SINGLE_SUCCESS;
|
||||||
})
|
})
|
||||||
).then(literal("unset")
|
).then(literal("unset")
|
||||||
.executes(ctx -> {
|
.executes(ctx -> {
|
||||||
ServerPlayerEntity player = ctx.getSource().getPlayer();
|
ServerPlayerEntity player = ctx.getSource().getPlayer();
|
||||||
if (!PlayerPronouns.setPronouns(player, null)) {
|
if (!PlayerPronouns.setPronouns(player, null)) {
|
||||||
ctx.getSource().sendError(new LiteralText("Failed to update pronouns, sorry"));
|
ctx.getSource().sendError(Text.literal("Failed to update pronouns, sorry"));
|
||||||
} else {
|
} else {
|
||||||
ctx.getSource().sendFeedback(new LiteralText("Cleared your pronouns!")
|
ctx.getSource().sendFeedback(Text.literal("Cleared your pronouns!")
|
||||||
.formatted(Formatting.GREEN), false);
|
.formatted(Formatting.GREEN), false);
|
||||||
}
|
}
|
||||||
return Command.SINGLE_SUCCESS;
|
return Command.SINGLE_SUCCESS;
|
||||||
|
|
|
@ -2,7 +2,6 @@ package io.github.ashisbored.playerpronouns.data;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
import net.minecraft.text.LiteralText;
|
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
@ -55,7 +54,7 @@ public class BinaryPronounDatabase {
|
||||||
Object2ObjectMap<UUID, Pronouns> pronouns = new Object2ObjectOpenHashMap<>();
|
Object2ObjectMap<UUID, Pronouns> pronouns = new Object2ObjectOpenHashMap<>();
|
||||||
Map<String, Text> pronounStrings = PronounList.get().getCalculatedPronounStrings();
|
Map<String, Text> pronounStrings = PronounList.get().getCalculatedPronounStrings();
|
||||||
for (var entry : BinaryPronounDatabase.load(path).data.entrySet()) {
|
for (var entry : BinaryPronounDatabase.load(path).data.entrySet()) {
|
||||||
Text formatted = new LiteralText(entry.getValue());
|
Text formatted = Text.literal(entry.getValue());
|
||||||
if (pronounStrings.containsKey(entry.getValue())) {
|
if (pronounStrings.containsKey(entry.getValue())) {
|
||||||
formatted = pronounStrings.get(entry.getValue());
|
formatted = pronounStrings.get(entry.getValue());
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ public record Pronoun(
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableText toText() {
|
public MutableText toText() {
|
||||||
return new LiteralText(this.pronoun).setStyle(this.style);
|
return Text.literal(this.pronoun).setStyle(this.style);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,7 +5,6 @@ import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import io.github.ashisbored.playerpronouns.Config;
|
import io.github.ashisbored.playerpronouns.Config;
|
||||||
import io.github.ashisbored.playerpronouns.PlayerPronouns;
|
import io.github.ashisbored.playerpronouns.PlayerPronouns;
|
||||||
import net.minecraft.text.LiteralText;
|
|
||||||
import net.minecraft.text.MutableText;
|
import net.minecraft.text.MutableText;
|
||||||
import net.minecraft.text.Style;
|
import net.minecraft.text.Style;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
@ -53,9 +52,9 @@ public class PronounList {
|
||||||
if (i == j) continue;
|
if (i == j) continue;
|
||||||
Pronoun a = combinedPairs.get(i);
|
Pronoun a = combinedPairs.get(i);
|
||||||
Pronoun b = combinedPairs.get(j);
|
Pronoun b = combinedPairs.get(j);
|
||||||
MutableText combined = new LiteralText("");
|
MutableText combined = Text.literal("");
|
||||||
combined.append(a.toText());
|
combined.append(a.toText());
|
||||||
combined.append(new LiteralText("/"));
|
combined.append(Text.literal("/"));
|
||||||
combined.append(b.toText());
|
combined.append(b.toText());
|
||||||
ret.put(a.pronoun() + "/" + b.pronoun(), combined);
|
ret.put(a.pronoun() + "/" + b.pronoun(), combined);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,11 +19,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.12.11",
|
"fabricloader": ">=0.14.8",
|
||||||
"fabric": "*",
|
"fabric": "*",
|
||||||
"minecraft": ">=1.18.1",
|
"minecraft": ">=1.19",
|
||||||
"more_codecs": ">=0.2.1",
|
"more_codecs": ">=0.2.2",
|
||||||
"placeholder-api": ">=1.0.1",
|
"placeholder-api": ">=2.0.0-beta",
|
||||||
"fabric-permissions-api-v0": "*"
|
"fabric-permissions-api-v0": "*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue