2024-09-21 20:08:00 -05:00
|
|
|
package one.oth3r.sit.mixin;
|
|
|
|
|
|
|
|
import com.mojang.brigadier.CommandDispatcher;
|
2024-09-30 14:28:12 -05:00
|
|
|
import net.minecraft.server.MinecraftServer;
|
2024-09-21 20:08:00 -05:00
|
|
|
import net.minecraft.server.command.ReloadCommand;
|
|
|
|
import net.minecraft.server.command.ServerCommandSource;
|
2024-09-30 14:28:12 -05:00
|
|
|
import net.minecraft.server.network.ServerPlayerEntity;
|
|
|
|
import net.minecraft.util.Formatting;
|
|
|
|
import one.oth3r.sit.utl.Data;
|
2025-05-03 13:17:40 -05:00
|
|
|
import one.oth3r.sit.utl.Logic;
|
2024-09-30 14:28:12 -05:00
|
|
|
import one.oth3r.sit.utl.Utl;
|
2024-09-21 20:08:00 -05:00
|
|
|
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;
|
|
|
|
|
2025-05-03 15:41:16 -05:00
|
|
|
import java.awt.*;
|
|
|
|
|
2024-09-21 20:08:00 -05:00
|
|
|
@Mixin(ReloadCommand.class)
|
|
|
|
public class ReloadCommandMixin {
|
|
|
|
@Inject(at = @At("TAIL"), method = "register")
|
|
|
|
private static void register(CommandDispatcher<ServerCommandSource> dispatcher, CallbackInfo ci) {
|
2025-05-03 13:17:40 -05:00
|
|
|
Logic.reload();
|
2024-09-30 14:28:12 -05:00
|
|
|
|
|
|
|
// make sure the server isn't null
|
|
|
|
MinecraftServer server = Data.getServer();
|
|
|
|
if (server == null || server.getPlayerManager() == null) return;
|
|
|
|
|
|
|
|
// send a reloaded message to all players with permissions
|
|
|
|
for (ServerPlayerEntity player : server.getPlayerManager().getPlayerList()) {
|
|
|
|
if (player.isCreativeLevelTwoOp()) {
|
2025-05-03 15:41:16 -05:00
|
|
|
player.sendMessage(Utl.messageTag().append(Utl.lang("sit!.chat.reloaded").color(Color.GREEN)).b());
|
2024-09-30 14:28:12 -05:00
|
|
|
}
|
|
|
|
}
|
2024-09-21 20:08:00 -05:00
|
|
|
}
|
|
|
|
}
|