Skip to content

Commit

Permalink
Update to 1.21-pre2
Browse files Browse the repository at this point in the history
  • Loading branch information
sakura-ryoko committed May 31, 2024
1 parent 515b47c commit 1926e45
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 74 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ plugins {
id "com.modrinth.minotaur" version "2.+"
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

archivesBaseName = project.archives_base_name
version = project.mod_version
Expand Down Expand Up @@ -81,7 +81,7 @@ tasks.withType(JavaCompile).configureEach {
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
// We'll use that if it's available, but otherwise we'll use the older option.
it.options.release = 17
it.options.release = 21
}

java {
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.20.5-rc1
yarn_mappings=1.20.5-rc1+build.1
loader_version=0.15.10
minecraft_version=1.21-pre2
yarn_mappings=1.21-pre2+build.2
loader_version=0.15.11

#Fabric api
fabric_version=0.97.3+1.20.5
fabric_version=0.99.4+1.21

# Mod Properties
mod_version = 2.4.0-pre.1+1.20.5
mod_version = 2.5.0-pre.2+1.21
maven_group = eu.pb4
archives_base_name = placeholder-api

Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public static PlaceholderContext of(Entity entity, ViewObject view) {


public interface ViewObject {
ViewObject DEFAULT = of(new Identifier("placeholder_api", "default"));
ViewObject DEFAULT = of(Identifier.of("placeholder_api", "default"));

static ViewObject of(Identifier identifier) {
return new ViewObjectImpl(identifier);
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/eu/pb4/placeholders/impl/GeneralUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@
import eu.pb4.placeholders.api.node.*;
import eu.pb4.placeholders.api.node.parent.*;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.Version;
import net.fabricmc.loader.api.VersionParsingException;
import net.minecraft.component.DataComponentType;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.item.ItemStack;
import net.minecraft.text.*;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.ColorHelper;
import org.jetbrains.annotations.ApiStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

public class PlayerPlaceholders {
public static void register() {
Placeholders.register(new Identifier("player", "name"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "name"), (ctx, arg) -> {
if (ctx.hasPlayer()) {
return PlaceholderResult.value(ctx.player().getName());
} else if (ctx.hasGameProfile()) {
Expand All @@ -29,7 +29,7 @@ public static void register() {
}
});

Placeholders.register(new Identifier("player", "name_visual"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "name_visual"), (ctx, arg) -> {
if (ctx.hasPlayer()) {
return PlaceholderResult.value(GeneralUtils.removeHoverAndClick(ctx.player().getName()));
} else if (ctx.hasGameProfile()) {
Expand All @@ -39,7 +39,7 @@ public static void register() {
}
});

Placeholders.register(new Identifier("player", "name_unformatted"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "name_unformatted"), (ctx, arg) -> {
if (ctx.hasPlayer()) {
return PlaceholderResult.value(ctx.player().getName().getString());
} else if (ctx.hasGameProfile()) {
Expand All @@ -49,15 +49,15 @@ public static void register() {
}
});

Placeholders.register(new Identifier("player", "ping"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "ping"), (ctx, arg) -> {
if (ctx.hasPlayer()) {
return PlaceholderResult.value(String.valueOf(ctx.player().networkHandler.getLatency()));
} else {
return PlaceholderResult.invalid("No player!");
}
});

Placeholders.register(new Identifier("player", "ping_colored"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "ping_colored"), (ctx, arg) -> {
if (ctx.hasPlayer()) {
int x = ctx.player().networkHandler.getLatency();
return PlaceholderResult.value(Text.literal(String.valueOf(x)).formatted(x < 100 ? Formatting.GREEN : x < 200 ? Formatting.GOLD : Formatting.RED));
Expand All @@ -66,7 +66,7 @@ public static void register() {
}
});

Placeholders.register(new Identifier("player", "displayname"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "displayname"), (ctx, arg) -> {
if (ctx.hasPlayer()) {
return PlaceholderResult.value(ctx.player().getDisplayName());
} else if (ctx.hasGameProfile()) {
Expand All @@ -76,9 +76,9 @@ public static void register() {
}
});

Placeholders.register(new Identifier("player", "display_name"), Placeholders.getPlaceholders().get(new Identifier("player", "displayname")));
Placeholders.register(Identifier.of("player", "display_name"), Placeholders.getPlaceholders().get(Identifier.of("player", "displayname")));

Placeholders.register(new Identifier("player", "displayname_visual"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "displayname_visual"), (ctx, arg) -> {
if (ctx.hasPlayer()) {
return PlaceholderResult.value(GeneralUtils.removeHoverAndClick(ctx.player().getDisplayName()));
} else if (ctx.hasGameProfile()) {
Expand All @@ -88,9 +88,9 @@ public static void register() {
}
});

Placeholders.register(new Identifier("player", "display_name_visual"), Placeholders.getPlaceholders().get(new Identifier("player", "displayname_visual")));
Placeholders.register(Identifier.of("player", "display_name_visual"), Placeholders.getPlaceholders().get(Identifier.of("player", "displayname_visual")));

Placeholders.register(new Identifier("player", "displayname_unformatted"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "displayname_unformatted"), (ctx, arg) -> {
if (ctx.hasPlayer()) {
return PlaceholderResult.value(Text.literal(ctx.player().getDisplayName().getString()));
} else if (ctx.hasGameProfile()) {
Expand All @@ -99,9 +99,9 @@ public static void register() {
return PlaceholderResult.invalid("No player!");
}
});
Placeholders.register(new Identifier("player", "display_name_unformatted"), Placeholders.getPlaceholders().get(new Identifier("player", "displayname_unformatted")));
Placeholders.register(Identifier.of("player", "display_name_unformatted"), Placeholders.getPlaceholders().get(Identifier.of("player", "displayname_unformatted")));

Placeholders.register(new Identifier("player", "inventory_slot"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "inventory_slot"), (ctx, arg) -> {
if (ctx.hasPlayer() && arg != null) {
try {
int slot = Integer.parseInt(arg);
Expand All @@ -123,7 +123,7 @@ public static void register() {
}
});

Placeholders.register(new Identifier("player", "inventory_slot_no_rarity"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "inventory_slot_no_rarity"), (ctx, arg) -> {
if (ctx.hasPlayer() && arg != null) {
try {
int slot = Integer.parseInt(arg);
Expand All @@ -145,7 +145,7 @@ public static void register() {
}
});

Placeholders.register(new Identifier("player", "equipment_slot"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "equipment_slot"), (ctx, arg) -> {
if (ctx.hasPlayer() && arg != null) {
try {
var slot = EquipmentSlot.byName(arg);
Expand All @@ -161,7 +161,7 @@ public static void register() {
}
});

Placeholders.register(new Identifier("player", "equipment_slot_no_rarity"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "equipment_slot_no_rarity"), (ctx, arg) -> {
if (ctx.hasPlayer() && arg != null) {
try {
var slot = EquipmentSlot.byName(arg);
Expand All @@ -177,7 +177,7 @@ public static void register() {
}
});

Placeholders.register(new Identifier("player", "playtime"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "playtime"), (ctx, arg) -> {
if (ctx.hasPlayer()) {
int x = ctx.player().getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(Stats.PLAY_TIME));
return PlaceholderResult.value(arg != null
Expand All @@ -189,7 +189,7 @@ public static void register() {
}
});

Placeholders.register(new Identifier("player", "statistic"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "statistic"), (ctx, arg) -> {
if (ctx.hasPlayer() && arg != null) {
try {
var args = arg.split(" ");
Expand Down Expand Up @@ -226,7 +226,7 @@ public static void register() {
}
});

Placeholders.register(new Identifier("player", "statistic_raw"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "statistic_raw"), (ctx, arg) -> {
if (ctx.hasPlayer() && arg != null) {
try {
var args = arg.split(" ");
Expand Down Expand Up @@ -263,7 +263,7 @@ public static void register() {
}
});

Placeholders.register(new Identifier("player", "objective"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "objective"), (ctx, arg) -> {
if (ctx.hasPlayer() && arg != null) {
try {
ServerScoreboard scoreboard = ctx.server().getScoreboard();
Expand All @@ -282,7 +282,7 @@ public static void register() {
}
});

Placeholders.register(new Identifier("player", "pos_x"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "pos_x"), (ctx, arg) -> {
if (ctx.hasPlayer()) {
double value = ctx.player().getX();
String format = "%.2f";
Expand All @@ -302,7 +302,7 @@ public static void register() {
}
});

Placeholders.register(new Identifier("player", "pos_y"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "pos_y"), (ctx, arg) -> {
if (ctx.hasPlayer()) {
double value = ctx.player().getY();
String format = "%.2f";
Expand All @@ -322,7 +322,7 @@ public static void register() {
}
});

Placeholders.register(new Identifier("player", "pos_z"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "pos_z"), (ctx, arg) -> {
if (ctx.hasPlayer()) {
double value = ctx.player().getZ();
String format = "%.2f";
Expand All @@ -342,7 +342,7 @@ public static void register() {
}
});

Placeholders.register(new Identifier("player", "uuid"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "uuid"), (ctx, arg) -> {
if (ctx.hasPlayer()) {
return PlaceholderResult.value(ctx.player().getUuidAsString());
} else if (ctx.hasGameProfile()) {
Expand All @@ -352,39 +352,39 @@ public static void register() {
}
});

Placeholders.register(new Identifier("player", "health"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "health"), (ctx, arg) -> {
if (ctx.hasPlayer()) {
return PlaceholderResult.value(String.format("%.0f", ctx.player().getHealth()));
} else {
return PlaceholderResult.invalid("No player!");
}
});

Placeholders.register(new Identifier("player", "max_health"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "max_health"), (ctx, arg) -> {
if (ctx.hasPlayer()) {
return PlaceholderResult.value(String.format("%.0f", ctx.player().getMaxHealth()));
} else {
return PlaceholderResult.invalid("No player!");
}
});

Placeholders.register(new Identifier("player", "hunger"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "hunger"), (ctx, arg) -> {
if (ctx.hasPlayer()) {
return PlaceholderResult.value(String.valueOf(ctx.player().getHungerManager().getFoodLevel()));
} else {
return PlaceholderResult.invalid("No player!");
}
});

Placeholders.register(new Identifier("player", "saturation"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "saturation"), (ctx, arg) -> {
if (ctx.hasPlayer()) {
return PlaceholderResult.value(String.format("%.0f", ctx.player().getHungerManager().getSaturationLevel()));
} else {
return PlaceholderResult.invalid("No player!");
}
});

Placeholders.register(new Identifier("player", "team_name"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "team_name"), (ctx, arg) -> {
if (ctx.hasPlayer()) {
var team = ctx.player().getScoreboardTeam();
return PlaceholderResult.value(team==null ? Text.empty() : Text.of(team.getName()));
Expand All @@ -393,7 +393,7 @@ public static void register() {
}
});

Placeholders.register(new Identifier("player", "team_displayname"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "team_displayname"), (ctx, arg) -> {
if (ctx.hasPlayer()) {
var team = (Team) ctx.player().getScoreboardTeam();
return PlaceholderResult.value(team==null ? Text.empty() : team.getDisplayName());
Expand All @@ -402,7 +402,7 @@ public static void register() {
}
});

Placeholders.register(new Identifier("player", "team_displayname_formatted"), (ctx, arg) -> {
Placeholders.register(Identifier.of("player", "team_displayname_formatted"), (ctx, arg) -> {
if (ctx.hasPlayer()) {
var team = (Team) ctx.player().getScoreboardTeam();
return PlaceholderResult.value(team==null ? Text.empty() : team.getFormattedName());
Expand Down
Loading

0 comments on commit 1926e45

Please sign in to comment.