Skip to content

Commit

Permalink
Update to 1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueZeeKing committed Sep 21, 2023
1 parent ad7bca0 commit 7eb5c1f
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 44 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
org.gradle.jvmargs=-Xmx2G

# Fabric Properties
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.1
loader_version=0.14.22

# Mod Properties
mod_version = 2.5.1
mod_version = 2.5.2
maven_group = io.icker
archives_base_name = factions

# Dependencies
fabric_version=0.89.0+1.20.1
fabric_version=0.89.0+1.20.2
lucko_permissions_version=0.3-SNAPSHOT
dynmap_api_version=3.7-SNAPSHOT
papi_version=2.1.3+1.20.1
Expand Down
27 changes: 18 additions & 9 deletions src/main/java/io/icker/factions/api/persistents/User.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package io.icker.factions.api.persistents;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import io.icker.factions.api.events.FactionEvents;
import io.icker.factions.database.Database;
import io.icker.factions.database.Field;
import io.icker.factions.database.Name;
import io.icker.factions.util.WorldUtils;
import net.minecraft.server.network.ServerPlayerEntity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.*;
import java.util.stream.Collectors;

@Name("User")
public class User {
Expand Down Expand Up @@ -49,7 +48,6 @@ public enum SoundMode {

public boolean autoclaim = false;
public boolean bypass = false;
public String language = "en_us";

private User spoof;

Expand Down Expand Up @@ -150,6 +148,17 @@ public static void audit() {
});
}

@Nullable
public String getLanguage() {
ServerPlayerEntity player = WorldUtils.server.getPlayerManager().getPlayer(this.id);

if (player == null) {
return null;
}

return player.getClientOptions().language();
}

public static void save() {
Database.save(User.class, STORE.values().stream().toList());
}
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/io/icker/factions/core/ChatManager.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package io.icker.factions.core;

import java.util.UUID;
import java.util.concurrent.CompletableFuture;

import io.icker.factions.FactionsMod;
import io.icker.factions.api.persistents.Faction;
import io.icker.factions.api.persistents.User;
Expand All @@ -12,13 +9,15 @@
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;

import java.util.UUID;

public class ChatManager {
public static void register() {
ServerMessageDecoratorEvent.EVENT.register(ServerMessageDecoratorEvent.CONTENT_PHASE, (sender, message) -> {
if (sender != null && FactionsMod.CONFIG.DISPLAY.MODIFY_CHAT) {
return CompletableFuture.completedFuture(ChatManager.handleMessage(sender, message.getString()));
return ChatManager.handleMessage(sender, message.getString());
}
return CompletableFuture.completedFuture(message);
return message;
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,31 @@
package io.icker.factions.mixin;

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;

import io.icker.factions.api.events.PlayerEvents;
import io.icker.factions.api.persistents.User;
import io.icker.factions.util.Message;
import io.icker.factions.util.WorldUtils;
import net.minecraft.entity.Entity;
import net.minecraft.network.message.SignedMessage;
import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
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;

@Mixin(ServerPlayNetworkHandler.class)
public class ServerPlayNetworkHandlerMixin {
@Shadow
public ServerPlayerEntity player;

@Final
@Shadow
private MinecraftServer server;

@Inject(method = "onPlayerMove", at = @At("HEAD"))
public void onPlayerMove(PlayerMoveC2SPacket packet, CallbackInfo ci) {
PlayerEvents.ON_MOVE.invoker().onMove(player);
Expand All @@ -48,7 +42,7 @@ public void handleDecoratedMessage(SignedMessage signedMessage, CallbackInfo ci)
new Message("You can't send a message to faction chat if you aren't in a faction.")
.fail().hover("Click to switch to global chat")
.click("/factions settings chat global")
.send(server.getPlayerManager().getPlayer(signedMessage.link().sender()),
.send(WorldUtils.server.getPlayerManager().getPlayer(signedMessage.link().sender()),
false);

ci.cancel();
Expand Down
17 changes: 5 additions & 12 deletions src/main/java/io/icker/factions/mixin/ServerPlayerEntityMixin.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
package io.icker.factions.mixin;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import io.icker.factions.FactionsMod;
import io.icker.factions.api.events.PlayerEvents;
import io.icker.factions.api.persistents.Faction;
Expand All @@ -14,12 +9,16 @@
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.network.packet.c2s.play.ClientSettingsC2SPacket;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Formatting;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(ServerPlayerEntity.class)
public abstract class ServerPlayerEntityMixin extends LivingEntity {
Expand All @@ -28,12 +27,6 @@ protected ServerPlayerEntityMixin(EntityType<? extends LivingEntity> entityType,
super(entityType, world);
}

@Inject(at = @At("HEAD"), method = "setClientSettings")
public void setClientSettings(ClientSettingsC2SPacket packet, CallbackInfo info) {
User member = User.get(((ServerPlayerEntity) (Object) this).getUuid());
member.language = packet.language();
}

@Inject(at = @At("HEAD"), method = "onDeath")
public void onDeath(DamageSource source, CallbackInfo info) {
Entity entity = source.getSource();
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

"depends": {
"fabricloader": ">=0.13.3",
"minecraft": "1.20.X",
"minecraft": ">=1.20.2",
"java": ">=17",
"fabric-api": "*"
},
Expand Down

0 comments on commit 7eb5c1f

Please sign in to comment.