Skip to content

Commit

Permalink
Update to 1.21.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Wesley1808 committed Oct 22, 2024
1 parent 4952cbc commit c4c3f88
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 63 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'fabric-loom' version '1.8-SNAPSHOT'
id 'maven-publish'
}

Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
org.gradle.jvmargs=-Xmx2G

# Fabric Properties
minecraft_version=1.21
loader_version=0.15.11
minecraft_version=1.21.2
loader_version=0.16.7

# Mod Properties
mod_version=1.6
mod_version=1.7
maven_group=me.wesley1808
archives_base_name=advancedchat

# API dependencies
fabric_version=0.100.1+1.21
placeholder_api_version=2.4.0-pre.2+1.21
fabric_version=0.106.1+1.21.2
placeholder_api_version=2.5.0+1.21.2
playerdata_api_version=0.6.0+1.21
predicate_api_version=0.5.1+1.21
predicate_api_version=0.6.0+1.21.2
permission_api_version=0.3.1

# Other dependencies
styledchat_version=2.6.0+1.21
vanish_version=1.5.5+1.21
styledchat_version=2.7.0+1.21.2
vanish_version=1.5.7+1.21.2-rc2
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
5 changes: 3 additions & 2 deletions src/main/java/me/wesley1808/advancedchat/impl/data/Json.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import me.wesley1808.advancedchat.impl.channels.Channels;
import me.wesley1808.advancedchat.impl.channels.ChatChannel;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
Expand All @@ -22,7 +23,7 @@ public class Json {

public static final Gson CONFIG = new GsonBuilder()
.registerTypeHierarchyAdapter(Pattern.class, new PatternSerializer())
.registerTypeHierarchyAdapter(MinecraftPredicate.class, GsonPredicateSerializer.INSTANCE)
.registerTypeHierarchyAdapter(MinecraftPredicate.class, GsonPredicateSerializer.create(RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY)))
.registerTypeHierarchyAdapter(SoundEvent.class, new RegistrySerializer<>(BuiltInRegistries.SOUND_EVENT))
.disableHtmlEscaping()
.setPrettyPrinting()
Expand Down Expand Up @@ -66,7 +67,7 @@ public T deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext
if (json.isJsonPrimitive()) {
ResourceLocation location = ResourceLocation.tryParse(json.getAsString());
if (location != null) {
return this.registry.get(location);
return this.registry.getValue(location);
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,41 @@

public interface IServerPlayer {

ClientboundSetActionBarTextPacket getActionBarPacket();
ClientboundSetActionBarTextPacket advancedchat$getActionBarPacket();

@Nullable
PlayerChatMessage getLastChatMessage();
PlayerChatMessage advancedchat$getLastChatMessage();

void setLastChatMessage(PlayerChatMessage message);
void advancedchat$setLastChatMessage(PlayerChatMessage message);

@Nullable
UUID getReplyTarget();
UUID advancedchat$getReplyTarget();

void setReplyTarget(UUID uuid);
void advancedchat$setReplyTarget(UUID uuid);

void delayNextPacket();
void advancedchat$delayNextPacket();

void updateActionBarPacket();
void advancedchat$updateActionBarPacket();

@Nullable
static PlayerChatMessage getLastChatMessage(ServerPlayer player) {
return ((IServerPlayer) player).getLastChatMessage();
return ((IServerPlayer) player).advancedchat$getLastChatMessage();
}

static void setLastChatMessage(ServerPlayer player, PlayerChatMessage message) {
((IServerPlayer) player).setLastChatMessage(message);
((IServerPlayer) player).advancedchat$setLastChatMessage(message);
}

@Nullable
static UUID getReplyTarget(ServerPlayer player) {
return ((IServerPlayer) player).getReplyTarget();
return ((IServerPlayer) player).advancedchat$getReplyTarget();
}

static void setReplyTarget(ServerPlayer player, UUID uuid) {
((IServerPlayer) player).setReplyTarget(uuid);
((IServerPlayer) player).advancedchat$setReplyTarget(uuid);
}

static void updateActionBarPacket(ServerPlayer player) {
((IServerPlayer) player).updateActionBarPacket();
((IServerPlayer) player).advancedchat$updateActionBarPacket();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static boolean check(SharedSuggestionProvider source, String perm, int le
}

public static boolean check(ServerPlayer source, String perm, int level) {
return Permissions.check(source, perm, level);
return Permissions.check(source.createCommandSourceStack(), perm, level);
}

public static Predicate<CommandSourceStack> require(String perm, int level) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

import java.util.Collection;

Expand All @@ -25,13 +24,12 @@ public class MsgCommandMixin {

@Inject(
method = "method_13463",
locals = LocalCapture.CAPTURE_FAILHARD,
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/commands/arguments/MessageArgument;resolveChatMessage(Lcom/mojang/brigadier/context/CommandContext;Ljava/lang/String;Ljava/util/function/Consumer;)V"
)
)
private static void advancedchat$verifyNotIgnored(CommandContext<CommandSourceStack> context, CallbackInfoReturnable<Integer> cir, Collection<ServerPlayer> targets) throws CommandSyntaxException {
private static void advancedchat$verifyNotIgnored(CommandContext<CommandSourceStack> context, CallbackInfoReturnable<Integer> cir, @Local(ordinal = 0) Collection<ServerPlayer> targets) throws CommandSyntaxException {
Util.throwIfIgnored(context.getSource(), targets);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@
import me.wesley1808.advancedchat.impl.utils.Util;
import net.minecraft.network.chat.ChatType;
import net.minecraft.network.chat.PlayerChatMessage;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.players.PlayerList;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
Expand All @@ -21,9 +18,6 @@

@Mixin(PlayerList.class)
public class PlayerListMixin {
@Shadow
@Final
private MinecraftServer server;

@Inject(method = "broadcastChatMessage(Lnet/minecraft/network/chat/PlayerChatMessage;Ljava/util/function/Predicate;Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/network/chat/ChatType$Bound;)V", at = @At("HEAD"), cancellable = true)
private void advancedchat$hideChatMessage(PlayerChatMessage message, Predicate<ServerPlayer> predicate, ServerPlayer sender, ChatType.Bound bound, CallbackInfo ci) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ public void send(Packet<?> packet, @Nullable PacketSendListener packetSendListen
super.send(packet, packetSendListener);

if (Config.instance().actionbar && this.player instanceof IServerPlayer player) {
Packet<?> current = player.getActionBarPacket();
Packet<?> current = player.advancedchat$getActionBarPacket();
if (current != null && current != packet && Util.isOverlayPacket(packet)) {
// Prevents the channel overlay packets from overriding other overlays from the server.
player.delayNextPacket();
player.advancedchat$delayNextPacket();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,30 @@ public abstract class ServerPlayerMixin extends Player implements IServerPlayer
public ServerGamePacketListenerImpl connection;
@Unique
@Nullable
private ClientboundSetActionBarTextPacket actionBarPacket;
private ClientboundSetActionBarTextPacket advancedchat$actionBarPacket;
@Unique
@Nullable
private PlayerChatMessage lastChatMessage;
private PlayerChatMessage advancedchat$lastChatMessage;
@Unique
@Nullable
private UUID replyTarget;
private UUID advancedchat$replyTarget;
@Unique
private long nextPacketTime;
private long advancedchat$nextPacketTime;

public ServerPlayerMixin(Level level, BlockPos blockPos, float f, GameProfile gameProfile) {
super(level, blockPos, f, gameProfile);
}

@Inject(method = "<init>", at = @At(value = "TAIL"))
private void advancedchat$onInit(MinecraftServer minecraftServer, ServerLevel serverLevel, GameProfile gameProfile, ClientInformation clientInformation, CallbackInfo ci) {
this.updateActionBarPacket();
this.advancedchat$updateActionBarPacket();
}

@Override
public boolean startRiding(Entity entity, boolean bl) {
if (super.startRiding(entity, bl)) {
// Prevents the channel overlay packets from overriding the vehicle mount overlay.
this.delayNextPacket();
this.advancedchat$delayNextPacket();
return true;
}
return false;
Expand All @@ -66,61 +66,61 @@ public boolean startRiding(Entity entity, boolean bl) {
Config config = Config.instance();
if (config.actionbar) {
if (this.tickCount % config.actionbarUpdateInterval == 0) {
this.updateActionBarPacket();
this.advancedchat$updateActionBarPacket();
}

if (this.actionBarPacket != null) {
if (this.advancedchat$actionBarPacket != null) {
long time = System.currentTimeMillis();
if (this.nextPacketTime <= time) {
this.connection.send(this.actionBarPacket);
this.nextPacketTime = time + 1000;
if (this.advancedchat$nextPacketTime <= time) {
this.connection.send(this.advancedchat$actionBarPacket);
this.advancedchat$nextPacketTime = time + 1000;
}
}
}
}

@Nullable
@Override
public ClientboundSetActionBarTextPacket getActionBarPacket() {
return this.actionBarPacket;
public ClientboundSetActionBarTextPacket advancedchat$getActionBarPacket() {
return this.advancedchat$actionBarPacket;
}

@Nullable
@Override
public PlayerChatMessage getLastChatMessage() {
return this.lastChatMessage;
public PlayerChatMessage advancedchat$getLastChatMessage() {
return this.advancedchat$lastChatMessage;
}

@Override
public void setLastChatMessage(PlayerChatMessage lastChatMessage) {
this.lastChatMessage = lastChatMessage;
public void advancedchat$setLastChatMessage(PlayerChatMessage lastChatMessage) {
this.advancedchat$lastChatMessage = lastChatMessage;
}

@Nullable
@Override
public UUID getReplyTarget() {
return this.replyTarget;
public UUID advancedchat$getReplyTarget() {
return this.advancedchat$replyTarget;
}

@Override
public void setReplyTarget(@Nullable UUID uuid) {
this.replyTarget = uuid;
public void advancedchat$setReplyTarget(@Nullable UUID uuid) {
this.advancedchat$replyTarget = uuid;
}

@Override
public void delayNextPacket() {
this.nextPacketTime = System.currentTimeMillis() + 3000;
public void advancedchat$delayNextPacket() {
this.advancedchat$nextPacketTime = System.currentTimeMillis() + 3000;
}

@Override
public void updateActionBarPacket() {
public void advancedchat$updateActionBarPacket() {
ServerPlayer player = (ServerPlayer) (Object) this;
AdvancedChatData data = DataManager.get(player);
if (data.channel == null) {
this.actionBarPacket = null;
this.advancedchat$actionBarPacket = null;
return;
}

this.actionBarPacket = new ClientboundSetActionBarTextPacket(data.channel.getActionBarText(player));
this.advancedchat$actionBarPacket = new ClientboundSetActionBarTextPacket(data.channel.getActionBarText(player));
}
}
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
],
"depends": {
"fabricloader": ">=0.15.0",
"minecraft": ">=1.21-"
"minecraft": ">=1.21.2-"
},
"suggests": {
"styledchat": "*"
Expand Down

0 comments on commit c4c3f88

Please sign in to comment.