[FEAT] Added Compat API for Advanced Chat
This commit is contained in:
@@ -2,6 +2,7 @@ package com.hypherionmc.craterlib.core.platform;
|
||||
|
||||
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
|
||||
import com.hypherionmc.craterlib.utils.InternalServiceUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public interface CompatUtils {
|
||||
|
||||
@@ -12,5 +13,7 @@ public interface CompatUtils {
|
||||
boolean isPlayerBleeding(BridgedPlayer player);
|
||||
boolean playerBledOut(BridgedPlayer player);
|
||||
boolean playerRevived(BridgedPlayer player);
|
||||
boolean isPrivateMessage(BridgedPlayer player);
|
||||
Component getChannelPrefix(BridgedPlayer player);
|
||||
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@ dependencies {
|
||||
modImplementation("me.shedaniel.cloth:cloth-config-fabric:${cloth_config}")
|
||||
modImplementation "maven.modrinth:fabrictailor:${fabrictailor}"
|
||||
modImplementation "maven.modrinth:vanish:${vanish}"
|
||||
modImplementation("unimaven.modrinth:advanced-chat:${advanced_chat}")
|
||||
|
||||
// Do not edit or remove
|
||||
implementation project(":Common")
|
||||
|
@@ -5,6 +5,8 @@ import com.hypherionmc.craterlib.compat.Vanish;
|
||||
import com.hypherionmc.craterlib.core.platform.CompatUtils;
|
||||
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
|
||||
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
|
||||
import me.wesley1808.advancedchat.api.AdvancedChatAPI;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public class FabricCompatHelper implements CompatUtils {
|
||||
|
||||
@@ -35,4 +37,15 @@ public class FabricCompatHelper implements CompatUtils {
|
||||
public boolean playerRevived(BridgedPlayer player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrivateMessage(BridgedPlayer player) {
|
||||
return !AdvancedChatAPI.isPublicChat(player.toMojangServerPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getChannelPrefix(BridgedPlayer player) {
|
||||
net.minecraft.network.chat.Component c = AdvancedChatAPI.getChannelPrefix(player.toMojangServerPlayer());
|
||||
return c.getString().isBlank() ? Component.empty() : Component.text(c.getString());
|
||||
}
|
||||
}
|
||||
|
@@ -42,4 +42,14 @@ public class ForgeCompatHelper implements CompatUtils {
|
||||
IBleeding bleeding = PlayerReviveServer.getBleeding(player.toMojangServerPlayer());
|
||||
return bleeding != null && bleeding.revived();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrivateMessage(BridgedPlayer player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getChannelPrefix(BridgedPlayer player) {
|
||||
return Component.empty();
|
||||
}
|
||||
}
|
||||
|
@@ -47,4 +47,14 @@ public class NeoForgeCompatHelper implements CompatUtils {
|
||||
IBleeding bleeding = PlayerReviveServer.getBleeding(player.toMojangServerPlayer());
|
||||
return bleeding != null && bleeding.revived();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrivateMessage(BridgedPlayer player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getChannelPrefix(BridgedPlayer player) {
|
||||
return Component.empty();
|
||||
}
|
||||
}
|
||||
|
@@ -89,4 +89,14 @@ public class PaperCompatHelper implements CompatUtils {
|
||||
public boolean playerRevived(BridgedPlayer player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrivateMessage(BridgedPlayer player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getChannelPrefix(BridgedPlayer player) {
|
||||
return Component.empty();
|
||||
}
|
||||
}
|
||||
|
@@ -4,4 +4,5 @@
|
||||
|
||||
**New Features**:
|
||||
|
||||
- Allow commands to send feedback as chat messages, if command feedback is disabled
|
||||
- Allow commands to send feedback as chat messages, if command feedback is disabled
|
||||
- Added Compat API for Advanced Chat
|
@@ -41,6 +41,7 @@ ftb_essentials=2101.1.0
|
||||
ftb_ranks=2101.1.1
|
||||
player_revive=6119534
|
||||
creative_core=6113754
|
||||
advanced_chat=SNA4dye5
|
||||
|
||||
# Publishing
|
||||
curse_id=867099
|
||||
|
Reference in New Issue
Block a user