[FEAT/BUG] Adventure parser backport and added Compat API for Advanced Chat

This commit is contained in:
2025-04-28 15:10:18 +02:00
parent 799a0fecc7
commit 7abf86dced
182 changed files with 1716 additions and 905 deletions

View File

@@ -7,16 +7,29 @@
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
import com.hypherionmc.craterlib.utils.ChatUtils;
import lombok.RequiredArgsConstructor;
@@ -14,7 +15,7 @@
private final CommandSourceStack internal;
@@ -17,14 +18,18 @@
public void sendSuccess(Supplier<Component> supplier, boolean bl) {
- internal.sendSuccess(() -> ChatUtils.adventureToMojang(supplier.get()), bl);
+ internal.sendSuccess(ChatUtils.adventureToMojang(supplier.get()), bl);
if (!internal.getServer().getGameRules().getBoolean(RULE_SENDCOMMANDFEEDBACK)) {
- internal.sendSystemMessage(ChatUtils.adventureToMojang(supplier.get()));
+ try {
+ internal.getPlayerOrException().displayClientMessage(ChatUtils.adventureToMojang(supplier.get()), false);
+ } catch (Exception ignored) {}
} else {
- internal.sendSuccess(() -> ChatUtils.adventureToMojang(supplier.get()), bl);
+ internal.sendSuccess(ChatUtils.adventureToMojang(supplier.get()), bl);
}
}
public void sendMessage(Component text) {
- internal.sendSystemMessage(ChatUtils.adventureToMojang(text));
+ try {
+ internal.getPlayerOrException().displayClientMessage(ChatUtils.adventureToMojang(text), false);
+ } catch (Exception ignored) {}
}
public void sendFailure(Component text) {
@@ -22,11 +23,22 @@
@@ -32,11 +37,22 @@
}
public boolean isPlayer() {

View File

@@ -8,7 +8,7 @@
import com.hypherionmc.craterlib.nojang.resources.ResourceIdentifier;
import lombok.Getter;
import me.hypherionmc.mcdiscordformatter.discord.DiscordSerializer;
@@ -13,51 +11,36 @@
@@ -13,55 +11,40 @@
import net.minecraft.ChatFormatting;
import net.minecraft.SharedConstants;
import net.minecraft.Util;
@@ -39,9 +39,13 @@
}
public static net.kyori.adventure.text.Component mojangToAdventure(Component inComponent) {
- final String serialised = Component.Serializer.toJson(inComponent, getRegistryLookup());
+ final String serialised = Component.Serializer.toJson(inComponent);
return adventureSerializer.deserialize(serialised);
try {
- final String serialised = Component.Serializer.toJson(inComponent, getRegistryLookup());
+ final String serialised = Component.Serializer.toJson(inComponent);
return adventureSerializer.deserialize(serialised);
} catch (Exception e) {
return net.kyori.adventure.text.Component.text(inComponent.getString());
}
}
- private static HolderLookup.Provider getRegistryLookup() {
@@ -66,7 +70,7 @@
}
public static String strip(String inString, String... toStrip) {
@@ -86,7 +69,7 @@
@@ -90,7 +73,7 @@
}
public static net.kyori.adventure.text.Component resolve(String component, boolean formatted) {
@@ -75,7 +79,7 @@
if (formatted) {
returnVal = MinecraftSerializer.INSTANCE.serialize(component);
}
@@ -114,7 +97,7 @@
@@ -118,7 +101,7 @@
if (identifier == null)
return net.kyori.adventure.text.Component.text("Unknown");

View File

@@ -1,6 +1,6 @@
--- a/Fabric/build.gradle
+++ b/Fabric/build.gradle
@@ -9,9 +9,6 @@
@@ -9,13 +9,9 @@
exclude(group: "net.fabricmc.fabric-api")
}
@@ -10,7 +10,11 @@
modImplementation("me.shedaniel.cloth:cloth-config-fabric:${cloth_config}")
modImplementation "maven.modrinth:fabrictailor:${fabrictailor}"
modImplementation "maven.modrinth:vanish:${vanish}"
@@ -117,8 +114,8 @@
- modImplementation("unimaven.modrinth:advanced-chat:${advanced_chat}")
// Do not edit or remove
implementation project(":Common")
@@ -118,8 +114,8 @@
setVersionType("release")
setChangelog(rootProject.file("changelog.md"))
setProjectVersion("${minecraft_version}-${project.version}")

View File

@@ -0,0 +1,25 @@
--- a/Fabric/src/main/java/com/hypherionmc/craterlib/common/FabricCompatHelper.java
+++ b/Fabric/src/main/java/com/hypherionmc/craterlib/common/FabricCompatHelper.java
@@ -5,7 +5,6 @@
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 {
@@ -40,12 +39,11 @@
@Override
public boolean isPrivateMessage(BridgedPlayer player) {
- return !AdvancedChatAPI.isPublicChat(player.toMojangServerPlayer());
+ return false;
}
@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());
+ return Component.empty();
}
}

View File

@@ -1,11 +1,12 @@
--- a/Forge/src/main/java/com/hypherionmc/craterlib/common/ForgeCompatHelper.java
+++ b/Forge/src/main/java/com/hypherionmc/craterlib/common/ForgeCompatHelper.java
@@ -1,15 +1,20 @@
@@ -1,15 +1,21 @@
package com.hypherionmc.craterlib.common;
import com.hypherionmc.craterlib.core.platform.CompatUtils;
+import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
+import net.kyori.adventure.text.Component;
import team.creative.playerrevive.api.IBleeding;
import team.creative.playerrevive.server.PlayerReviveServer;
+import redstonedubstep.mods.vanishmod.VanishUtil;

View File

@@ -1,6 +1,6 @@
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/common/NeoForgeCompatHelper.java
+++ /dev/null
@@ -1,50 +1,0 @@
@@ -1,60 +1,0 @@
-package com.hypherionmc.craterlib.common;
-
-import com.hypherionmc.craterlib.core.platform.CompatUtils;
@@ -50,4 +50,14 @@
- 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();
- }
-}

View File

@@ -1,6 +1,6 @@
--- a/Paper/src/main/java/com/hypherionmc/craterlib/common/PaperCompatHelper.java
+++ /dev/null
@@ -1,92 +1,0 @@
@@ -1,102 +1,0 @@
-package com.hypherionmc.craterlib.common;
-
-import com.hypherionmc.craterlib.core.platform.CompatUtils;
@@ -92,4 +92,14 @@
- public boolean playerRevived(BridgedPlayer player) {
- return false;
- }
-
- @Override
- public boolean isPrivateMessage(BridgedPlayer player) {
- return false;
- }
-
- @Override
- public Component getChannelPrefix(BridgedPlayer player) {
- return Component.empty();
- }
-}

View File

@@ -23,7 +23,7 @@
# Dependencies
moon_config=1.0.12
@@ -29,23 +26,22 @@
@@ -29,24 +26,23 @@
adventure=4.17.0
rpc_sdk=1.0
discord_formatter=2.0.0
@@ -40,6 +40,7 @@
-ftb_ranks=2101.1.1
-player_revive=6119534
-creative_core=6113754
advanced_chat=SNA4dye5
+player_revive=5335413
+creative_core=5335387
+ftb_ranks=1802.1.11-build.71

View File

@@ -1,11 +1,11 @@
--- a/Common/src/main/java/com/hypherionmc/craterlib/nojang/commands/BridgedCommandSourceStack.java
+++ b/Common/src/main/java/com/hypherionmc/craterlib/nojang/commands/BridgedCommandSourceStack.java
@@ -14,7 +14,7 @@
private final CommandSourceStack internal;
public void sendSuccess(Supplier<Component> supplier, boolean bl) {
- internal.sendSuccess(() -> ChatUtils.adventureToMojang(supplier.get()), bl);
+ internal.sendSuccess(ChatUtils.adventureToMojang(supplier.get()), bl);
@@ -19,7 +19,7 @@
if (!internal.getServer().getGameRules().getBoolean(RULE_SENDCOMMANDFEEDBACK)) {
internal.sendSystemMessage(ChatUtils.adventureToMojang(supplier.get()));
} else {
- internal.sendSuccess(() -> ChatUtils.adventureToMojang(supplier.get()), bl);
+ internal.sendSuccess(ChatUtils.adventureToMojang(supplier.get()), bl);
}
}
public void sendFailure(Component text) {

View File

@@ -20,7 +20,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
@@ -25,31 +18,19 @@
@@ -25,35 +18,23 @@
@Getter
private static final GsonComponentSerializer adventureSerializer = GsonComponentSerializer.builder().options(
@@ -37,9 +37,13 @@
}
public static net.kyori.adventure.text.Component mojangToAdventure(Component inComponent) {
- final String serialised = Component.Serializer.toJson(inComponent, getRegistryLookup());
try {
- final String serialised = Component.Serializer.toJson(inComponent, getRegistryLookup());
+ final String serialised = Component.Serializer.toJson(inComponent);
return adventureSerializer.deserialize(serialised);
return adventureSerializer.deserialize(serialised);
} catch (Exception e) {
return net.kyori.adventure.text.Component.text(inComponent.getString());
}
- }
-
- private static HolderLookup.Provider getRegistryLookup() {

View File

@@ -1,6 +1,6 @@
--- a/Fabric/build.gradle
+++ b/Fabric/build.gradle
@@ -11,7 +11,6 @@
@@ -11,11 +11,9 @@
stupidRemapArch("dev.ftb.mods:ftb-essentials:${ftb_essentials}")
stupidRemapArch("dev.ftb.mods:ftb-ranks:${ftb_ranks}")
@@ -8,7 +8,11 @@
modImplementation("me.shedaniel.cloth:cloth-config-fabric:${cloth_config}")
modImplementation "maven.modrinth:fabrictailor:${fabrictailor}"
modImplementation "maven.modrinth:vanish:${vanish}"
@@ -117,8 +116,8 @@
- modImplementation("unimaven.modrinth:advanced-chat:${advanced_chat}")
// Do not edit or remove
implementation project(":Common")
@@ -118,8 +116,8 @@
setVersionType("release")
setChangelog(rootProject.file("changelog.md"))
setProjectVersion("${minecraft_version}-${project.version}")

View File

@@ -0,0 +1,25 @@
--- a/Fabric/src/main/java/com/hypherionmc/craterlib/common/FabricCompatHelper.java
+++ b/Fabric/src/main/java/com/hypherionmc/craterlib/common/FabricCompatHelper.java
@@ -5,7 +5,6 @@
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 {
@@ -40,12 +39,11 @@
@Override
public boolean isPrivateMessage(BridgedPlayer player) {
- return !AdvancedChatAPI.isPublicChat(player.toMojangServerPlayer());
+ return false;
}
@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());
+ return Component.empty();
}
}

View File

@@ -1,11 +1,12 @@
--- a/Forge/src/main/java/com/hypherionmc/craterlib/common/ForgeCompatHelper.java
+++ b/Forge/src/main/java/com/hypherionmc/craterlib/common/ForgeCompatHelper.java
@@ -1,15 +1,20 @@
@@ -1,15 +1,21 @@
package com.hypherionmc.craterlib.common;
import com.hypherionmc.craterlib.core.platform.CompatUtils;
+import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
+import net.kyori.adventure.text.Component;
import team.creative.playerrevive.api.IBleeding;
import team.creative.playerrevive.server.PlayerReviveServer;
+import redstonedubstep.mods.vanishmod.VanishUtil;

View File

@@ -1,6 +1,6 @@
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/common/NeoForgeCompatHelper.java
+++ /dev/null
@@ -1,50 +1,0 @@
@@ -1,60 +1,0 @@
-package com.hypherionmc.craterlib.common;
-
-import com.hypherionmc.craterlib.core.platform.CompatUtils;
@@ -50,4 +50,14 @@
- 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();
- }
-}

View File

@@ -1,6 +1,6 @@
--- a/Paper/src/main/java/com/hypherionmc/craterlib/common/PaperCompatHelper.java
+++ /dev/null
@@ -1,92 +1,0 @@
@@ -1,102 +1,0 @@
-package com.hypherionmc.craterlib.common;
-
-import com.hypherionmc.craterlib.core.platform.CompatUtils;
@@ -92,4 +92,14 @@
- public boolean playerRevived(BridgedPlayer player) {
- return false;
- }
-
- @Override
- public boolean isPrivateMessage(BridgedPlayer player) {
- return false;
- }
-
- @Override
- public Component getChannelPrefix(BridgedPlayer player) {
- return Component.empty();
- }
-}

View File

@@ -23,7 +23,7 @@
# Dependencies
moon_config=1.0.12
@@ -29,23 +26,22 @@
@@ -29,24 +26,23 @@
adventure=4.17.0
rpc_sdk=1.0
discord_formatter=2.0.0
@@ -40,6 +40,7 @@
-ftb_ranks=2101.1.1
-player_revive=6119534
-creative_core=6113754
advanced_chat=SNA4dye5
+player_revive=5491953
+creative_core=5491926
+ftb_ranks=1902.1.16-build.114

View File

@@ -1,11 +1,11 @@
--- a/Common/src/main/java/com/hypherionmc/craterlib/nojang/commands/BridgedCommandSourceStack.java
+++ b/Common/src/main/java/com/hypherionmc/craterlib/nojang/commands/BridgedCommandSourceStack.java
@@ -14,7 +14,7 @@
private final CommandSourceStack internal;
public void sendSuccess(Supplier<Component> supplier, boolean bl) {
- internal.sendSuccess(() -> ChatUtils.adventureToMojang(supplier.get()), bl);
+ internal.sendSuccess(ChatUtils.adventureToMojang(supplier.get()), bl);
@@ -19,7 +19,7 @@
if (!internal.getServer().getGameRules().getBoolean(RULE_SENDCOMMANDFEEDBACK)) {
internal.sendSystemMessage(ChatUtils.adventureToMojang(supplier.get()));
} else {
- internal.sendSuccess(() -> ChatUtils.adventureToMojang(supplier.get()), bl);
+ internal.sendSuccess(ChatUtils.adventureToMojang(supplier.get()), bl);
}
}
public void sendFailure(Component text) {

View File

@@ -8,7 +8,7 @@
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.nojang.resources.ResourceIdentifier;
import lombok.Getter;
@@ -10,46 +10,29 @@
@@ -10,50 +10,33 @@
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.kyori.adventure.text.serializer.json.JSONOptions;
@@ -42,9 +42,13 @@
}
public static net.kyori.adventure.text.Component mojangToAdventure(Component inComponent) {
- final String serialised = Component.Serializer.toJson(inComponent, getRegistryLookup());
try {
- final String serialised = Component.Serializer.toJson(inComponent, getRegistryLookup());
+ final String serialised = Component.Serializer.toJson(inComponent);
return adventureSerializer.deserialize(serialised);
return adventureSerializer.deserialize(serialised);
} catch (Exception e) {
return net.kyori.adventure.text.Component.text(inComponent.getString());
}
- }
-
- private static HolderLookup.Provider getRegistryLookup() {

View File

@@ -8,7 +8,7 @@
modImplementation("me.shedaniel.cloth:cloth-config-fabric:${cloth_config}")
modImplementation "maven.modrinth:fabrictailor:${fabrictailor}"
modImplementation "maven.modrinth:vanish:${vanish}"
@@ -117,8 +116,8 @@
@@ -118,8 +117,8 @@
setVersionType("release")
setChangelog(rootProject.file("changelog.md"))
setProjectVersion("${minecraft_version}-${project.version}")

View File

@@ -1,11 +1,12 @@
--- a/Forge/src/main/java/com/hypherionmc/craterlib/common/ForgeCompatHelper.java
+++ b/Forge/src/main/java/com/hypherionmc/craterlib/common/ForgeCompatHelper.java
@@ -1,15 +1,20 @@
@@ -1,15 +1,21 @@
package com.hypherionmc.craterlib.common;
import com.hypherionmc.craterlib.core.platform.CompatUtils;
+import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
+import net.kyori.adventure.text.Component;
import team.creative.playerrevive.api.IBleeding;
import team.creative.playerrevive.server.PlayerReviveServer;
+import redstonedubstep.mods.vanishmod.VanishUtil;

View File

@@ -1,6 +1,6 @@
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/common/NeoForgeCompatHelper.java
+++ /dev/null
@@ -1,50 +1,0 @@
@@ -1,60 +1,0 @@
-package com.hypherionmc.craterlib.common;
-
-import com.hypherionmc.craterlib.core.platform.CompatUtils;
@@ -50,4 +50,14 @@
- 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();
- }
-}

View File

@@ -0,0 +1,10 @@
--- a/Paper/src/main/java/com/hypherionmc/craterlib/common/PaperCompatHelper.java
+++ b/Paper/src/main/java/com/hypherionmc/craterlib/common/PaperCompatHelper.java
@@ -4,6 +4,7 @@
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
import com.hypherionmc.craterlib.utils.ChatUtils;
+import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.metadata.MetadataValue;

View File

@@ -23,7 +23,7 @@
# Dependencies
moon_config=1.0.12
@@ -29,23 +26,22 @@
@@ -29,24 +26,23 @@
adventure=4.17.0
rpc_sdk=1.0
discord_formatter=2.0.0
@@ -40,6 +40,8 @@
-ftb_ranks=2101.1.1
-player_revive=6119534
-creative_core=6113754
-advanced_chat=SNA4dye5
+advanced_chat=RN7kRIrY
+player_revive=4353422
+creative_core=4407520
+ftb_ranks=1904.1.1-build.82

View File

@@ -8,7 +8,7 @@
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.nojang.resources.ResourceIdentifier;
import lombok.Getter;
@@ -10,46 +10,29 @@
@@ -10,50 +10,33 @@
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.kyori.adventure.text.serializer.json.JSONOptions;
@@ -42,9 +42,13 @@
}
public static net.kyori.adventure.text.Component mojangToAdventure(Component inComponent) {
- final String serialised = Component.Serializer.toJson(inComponent, getRegistryLookup());
try {
- final String serialised = Component.Serializer.toJson(inComponent, getRegistryLookup());
+ final String serialised = Component.Serializer.toJson(inComponent);
return adventureSerializer.deserialize(serialised);
return adventureSerializer.deserialize(serialised);
} catch (Exception e) {
return net.kyori.adventure.text.Component.text(inComponent.getString());
}
- }
-
- private static HolderLookup.Provider getRegistryLookup() {

View File

@@ -8,7 +8,7 @@
modImplementation("me.shedaniel.cloth:cloth-config-fabric:${cloth_config}")
modImplementation "maven.modrinth:fabrictailor:${fabrictailor}"
modImplementation "maven.modrinth:vanish:${vanish}"
@@ -117,8 +116,8 @@
@@ -118,8 +117,8 @@
setVersionType("release")
setChangelog(rootProject.file("changelog.md"))
setProjectVersion("${minecraft_version}-${project.version}")

View File

@@ -1,11 +1,12 @@
--- a/Forge/src/main/java/com/hypherionmc/craterlib/common/ForgeCompatHelper.java
+++ b/Forge/src/main/java/com/hypherionmc/craterlib/common/ForgeCompatHelper.java
@@ -1,15 +1,20 @@
@@ -1,15 +1,21 @@
package com.hypherionmc.craterlib.common;
import com.hypherionmc.craterlib.core.platform.CompatUtils;
+import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
+import net.kyori.adventure.text.Component;
import team.creative.playerrevive.api.IBleeding;
import team.creative.playerrevive.server.PlayerReviveServer;
+import redstonedubstep.mods.vanishmod.VanishUtil;

View File

@@ -1,6 +1,6 @@
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/common/NeoForgeCompatHelper.java
+++ /dev/null
@@ -1,50 +1,0 @@
@@ -1,60 +1,0 @@
-package com.hypherionmc.craterlib.common;
-
-import com.hypherionmc.craterlib.core.platform.CompatUtils;
@@ -50,4 +50,14 @@
- 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();
- }
-}

View File

@@ -0,0 +1,10 @@
--- a/Paper/src/main/java/com/hypherionmc/craterlib/common/PaperCompatHelper.java
+++ b/Paper/src/main/java/com/hypherionmc/craterlib/common/PaperCompatHelper.java
@@ -4,6 +4,7 @@
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
import com.hypherionmc.craterlib.utils.ChatUtils;
+import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.metadata.MetadataValue;

View File

@@ -23,7 +23,7 @@
# Dependencies
moon_config=1.0.12
@@ -29,23 +26,22 @@
@@ -29,24 +26,23 @@
adventure=4.17.0
rpc_sdk=1.0
discord_formatter=2.0.0
@@ -40,6 +40,8 @@
-ftb_ranks=2101.1.1
-player_revive=6119534
-creative_core=6113754
-advanced_chat=SNA4dye5
+advanced_chat=bLHDrebO
+player_revive=4785938
+creative_core=4796447
+ftb_ranks=2001.1.3

View File

@@ -20,7 +20,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
@@ -25,31 +18,19 @@
@@ -25,35 +18,23 @@
@Getter
private static final GsonComponentSerializer adventureSerializer = GsonComponentSerializer.builder().options(
@@ -37,9 +37,13 @@
}
public static net.kyori.adventure.text.Component mojangToAdventure(Component inComponent) {
- final String serialised = Component.Serializer.toJson(inComponent, getRegistryLookup());
try {
- final String serialised = Component.Serializer.toJson(inComponent, getRegistryLookup());
+ final String serialised = Component.Serializer.toJson(inComponent);
return adventureSerializer.deserialize(serialised);
return adventureSerializer.deserialize(serialised);
} catch (Exception e) {
return net.kyori.adventure.text.Component.text(inComponent.getString());
}
- }
-
- private static HolderLookup.Provider getRegistryLookup() {

View File

@@ -1,6 +1,6 @@
--- a/Fabric/build.gradle
+++ b/Fabric/build.gradle
@@ -117,8 +117,8 @@
@@ -118,8 +118,8 @@
setVersionType("release")
setChangelog(rootProject.file("changelog.md"))
setProjectVersion("${minecraft_version}-${project.version}")

View File

@@ -1,6 +1,6 @@
--- a/Forge/src/main/java/com/hypherionmc/craterlib/common/ForgeCompatHelper.java
+++ b/Forge/src/main/java/com/hypherionmc/craterlib/common/ForgeCompatHelper.java
@@ -1,15 +1,18 @@
@@ -1,15 +1,19 @@
package com.hypherionmc.craterlib.common;
import com.hypherionmc.craterlib.core.platform.CompatUtils;
@@ -8,6 +8,7 @@
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
-import team.creative.playerrevive.api.IBleeding;
-import team.creative.playerrevive.server.PlayerReviveServer;
+import net.kyori.adventure.text.Component;
+import redstonedubstep.mods.vanishmod.VanishUtil;
public class ForgeCompatHelper implements CompatUtils {
@@ -22,7 +23,7 @@
}
@Override
@@ -19,27 +22,16 @@
@@ -19,28 +23,17 @@
@Override
public boolean isPlayerBleeding(BridgedPlayer player) {
@@ -52,4 +53,5 @@
- return bleeding != null && bleeding.revived();
+ return false;
}
}
@Override

View File

@@ -0,0 +1,10 @@
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/common/NeoForgeCompatHelper.java
+++ b/NeoForge/src/main/java/com/hypherionmc/craterlib/common/NeoForgeCompatHelper.java
@@ -3,6 +3,7 @@
import com.hypherionmc.craterlib.core.platform.CompatUtils;
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
+import net.kyori.adventure.text.Component;
import redstonedubstep.mods.vanishmod.VanishUtil;
import team.creative.playerrevive.api.IBleeding;
import team.creative.playerrevive.server.PlayerReviveServer;

View File

@@ -0,0 +1,10 @@
--- a/Paper/src/main/java/com/hypherionmc/craterlib/common/PaperCompatHelper.java
+++ b/Paper/src/main/java/com/hypherionmc/craterlib/common/PaperCompatHelper.java
@@ -4,6 +4,7 @@
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
import com.hypherionmc.craterlib.utils.ChatUtils;
+import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.metadata.MetadataValue;

View File

@@ -24,7 +24,7 @@
# Dependencies
moon_config=1.0.12
@@ -29,23 +29,23 @@
@@ -29,24 +29,24 @@
adventure=4.17.0
rpc_sdk=1.0
discord_formatter=2.0.0
@@ -44,6 +44,8 @@
-ftb_ranks=2101.1.1
-player_revive=6119534
-creative_core=6113754
-advanced_chat=SNA4dye5
+advanced_chat=tBkISdKZ
+player_revive=5019850
+creative_core=5140174
+ftb_ranks=2004.2.0

View File

@@ -8,7 +8,7 @@
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.nojang.resources.ResourceIdentifier;
import lombok.Getter;
@@ -10,46 +10,29 @@
@@ -10,50 +10,33 @@
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.kyori.adventure.text.serializer.json.JSONOptions;
@@ -42,9 +42,13 @@
}
public static net.kyori.adventure.text.Component mojangToAdventure(Component inComponent) {
- final String serialised = Component.Serializer.toJson(inComponent, getRegistryLookup());
try {
- final String serialised = Component.Serializer.toJson(inComponent, getRegistryLookup());
+ final String serialised = Component.Serializer.toJson(inComponent);
return adventureSerializer.deserialize(serialised);
return adventureSerializer.deserialize(serialised);
} catch (Exception e) {
return net.kyori.adventure.text.Component.text(inComponent.getString());
}
- }
-
- private static HolderLookup.Provider getRegistryLookup() {

View File

@@ -8,7 +8,7 @@
modImplementation("me.shedaniel.cloth:cloth-config-fabric:${cloth_config}")
modImplementation "maven.modrinth:fabrictailor:${fabrictailor}"
modImplementation "maven.modrinth:vanish:${vanish}"
@@ -117,8 +116,8 @@
@@ -118,8 +117,8 @@
setVersionType("release")
setChangelog(rootProject.file("changelog.md"))
setProjectVersion("${minecraft_version}-${project.version}")

View File

@@ -1,11 +1,12 @@
--- a/Forge/src/main/java/com/hypherionmc/craterlib/common/ForgeCompatHelper.java
+++ b/Forge/src/main/java/com/hypherionmc/craterlib/common/ForgeCompatHelper.java
@@ -1,15 +1,20 @@
@@ -1,15 +1,21 @@
package com.hypherionmc.craterlib.common;
import com.hypherionmc.craterlib.core.platform.CompatUtils;
+import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
+import net.kyori.adventure.text.Component;
import team.creative.playerrevive.api.IBleeding;
import team.creative.playerrevive.server.PlayerReviveServer;
+import redstonedubstep.mods.vanishmod.VanishUtil;

View File

@@ -1,6 +1,6 @@
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/common/NeoForgeCompatHelper.java
+++ /dev/null
@@ -1,50 +1,0 @@
@@ -1,60 +1,0 @@
-package com.hypherionmc.craterlib.common;
-
-import com.hypherionmc.craterlib.core.platform.CompatUtils;
@@ -50,4 +50,14 @@
- 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();
- }
-}

View File

@@ -0,0 +1,10 @@
--- a/Paper/src/main/java/com/hypherionmc/craterlib/common/PaperCompatHelper.java
+++ b/Paper/src/main/java/com/hypherionmc/craterlib/common/PaperCompatHelper.java
@@ -4,6 +4,7 @@
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
import com.hypherionmc.craterlib.utils.ChatUtils;
+import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.metadata.MetadataValue;

View File

@@ -1,9 +1,9 @@
--- a/changelog.md
+++ b/changelog.md
@@ -2,6 +2,7 @@
@@ -1,6 +1,7 @@
**Bug Fixes**:
- Fixed LuckPerms breaking commands on Paper
- Fix Config watcher using too many threads and not detecting changes on Linux systems
- Fix Adventure Serializer failing completely when serialization fails, causing game glitches
+- Fixed crash when trying to open config screens on NeoForge
**New Features**:

View File

@@ -23,7 +23,7 @@
# Dependencies
moon_config=1.0.12
@@ -29,23 +26,22 @@
@@ -29,24 +26,23 @@
adventure=4.17.0
rpc_sdk=1.0
discord_formatter=2.0.0
@@ -40,6 +40,8 @@
-ftb_ranks=2101.1.1
-player_revive=6119534
-creative_core=6113754
-advanced_chat=SNA4dye5
+advanced_chat=Unjr2LZL
+player_revive=4798215
+creative_core=4798202
+ftb_ranks=2001.1.3

View File

@@ -1,6 +1,6 @@
--- a/Fabric/build.gradle
+++ b/Fabric/build.gradle
@@ -117,8 +117,8 @@
@@ -118,8 +118,8 @@
setVersionType("release")
setChangelog(rootProject.file("changelog.md"))
setProjectVersion("${minecraft_version}-${project.version}")

View File

@@ -1,6 +1,6 @@
--- a/Forge/src/main/java/com/hypherionmc/craterlib/common/ForgeCompatHelper.java
+++ /dev/null
@@ -1,45 +1,0 @@
@@ -1,55 +1,0 @@
-package com.hypherionmc.craterlib.common;
-
-import com.hypherionmc.craterlib.core.platform.CompatUtils;
@@ -45,4 +45,14 @@
- 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();
- }
-}

View File

@@ -0,0 +1,10 @@
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/common/NeoForgeCompatHelper.java
+++ b/NeoForge/src/main/java/com/hypherionmc/craterlib/common/NeoForgeCompatHelper.java
@@ -3,6 +3,7 @@
import com.hypherionmc.craterlib.core.platform.CompatUtils;
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
+import net.kyori.adventure.text.Component;
import redstonedubstep.mods.vanishmod.VanishUtil;
import team.creative.playerrevive.api.IBleeding;
import team.creative.playerrevive.server.PlayerReviveServer;

View File

@@ -0,0 +1,10 @@
--- a/Paper/src/main/java/com/hypherionmc/craterlib/common/PaperCompatHelper.java
+++ b/Paper/src/main/java/com/hypherionmc/craterlib/common/PaperCompatHelper.java
@@ -4,6 +4,7 @@
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
import com.hypherionmc.craterlib.utils.ChatUtils;
+import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.metadata.MetadataValue;

View File

@@ -23,12 +23,13 @@
# Dependencies
moon_config=1.0.12
@@ -39,13 +39,13 @@
@@ -39,14 +39,14 @@
vanishmod_neo=puxrKAMr
ftb_essentials=2101.1.0
ftb_ranks=2101.1.1
-player_revive=6119534
-creative_core=6113754
advanced_chat=SNA4dye5
+player_revive=5886329
+creative_core=5886272

View File

@@ -1,6 +1,6 @@
--- a/Fabric/build.gradle
+++ b/Fabric/build.gradle
@@ -117,8 +117,8 @@
@@ -118,8 +118,8 @@
setVersionType("release")
setChangelog(rootProject.file("changelog.md"))
setProjectVersion("${minecraft_version}-${project.version}")

View File

@@ -0,0 +1,131 @@
--- a/Forge/build.gradle
+++ /dev/null
@@ -1,128 +1,0 @@
-// Adjust the output jar name here
-archivesBaseName = "${mod_name.replace(" ", "")}-Forge-${minecraft_version}"
-
-dependencies {
- // Compat
- // NOT AVAILABLE ON FORGE modImplementation("maven.modrinth:vanishmod:${vanishmod}")
-
- modImplementation("me.shedaniel.cloth:cloth-config-forge:${cloth_config}")
- modImplementation("unimaven.curseforge:playerrevive-266890:${player_revive}")
- modImplementation("unimaven.curseforge:creativecore-257814:${creative_core}")
-
- // Do not edit or remove
- implementation project(":Common")
-}
-
-shadowJar {
- from sourceSets.main.output
- configurations = [project.configurations.shade]
-
- dependencies {
- exclude(dependency('com.google.code.gson:.*'))
-
- relocate 'me.hypherionmc.moonconfig', 'shadow.hypherionmc.moonconfig'
- relocate 'me.hypherionmc.mcdiscordformatter', 'shadow.hypherionmc.mcdiscordformatter'
- relocate 'net.kyori', 'shadow.kyori'
- }
-
- setArchiveClassifier('dev-shadow')
- mergeServiceFiles()
-}
-
-/**
- * ===============================================================================
- * = DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING =
- * ===============================================================================
- */
-
-unimined.minecraft {
- minecraftForge {
- loader forge_version
- mixinConfig("${mod_id}.mixins.json", "${mod_id}.forge.mixins.json")
- }
-}
-
-remapJar {
- inputFile.set shadowJar.archiveFile
- dependsOn shadowJar
- archiveClassifier.set null
-}
-
-jar {
- archiveClassifier.set "dev"
-}
-
-processResources {
- from project(":Common").sourceSets.main.resources
- def buildProps = project.properties.clone()
-
- filesMatching("META-INF/mods.toml") {
- expand buildProps
- }
-}
-
-compileTestJava.enabled = false
-
-tasks.withType(JavaCompile).configureEach {
- source(project(":Common").sourceSets.main.allSource)
-}
-
-/**
- * Publishing Config
- */
-publishing {
- publications {
- mavenJava(MavenPublication) {
- artifactId project.archivesBaseName
- from components.java
-
- artifact(remapJar) {
- builtBy remapJar
- }
-
- pom.withXml {
- Node pomNode = asNode()
- pomNode.dependencies.'*'.findAll() {
- it.artifactId.text() == 'regutils-joined-fabric' ||
- it.artifactId.text() == 'core' ||
- it.artifactId.text() == 'toml'
- }.each() {
- it.parent().remove(it)
- }
- }
- }
- }
-
- repositories {
- maven rootProject.orion.getPublishingMaven()
- }
-}
-
-publisher {
- apiKeys {
- modrinth(System.getenv("MODRINTH_TOKEN"))
- curseforge(System.getenv("CURSE_TOKEN"))
- nightbloom(System.getenv("PLATFORM_KEY"))
- }
-
- setCurseID(curse_id)
- setModrinthID(modrinth_id)
- setNightbloomID("craterlib")
- setVersionType("release")
- setChangelog(rootProject.file("changelog.md"))
- setProjectVersion("${minecraft_version}-${project.version}")
- setDisplayName("[Forge 1.20.6] CraterLib - ${project.version}")
- setGameVersions("1.20.6")
- setLoaders("forge")
- setArtifact(remapJar)
- setCurseEnvironment("both")
- setIsManualRelease(true)
-
- curseDepends {
- optional("cloth-config")
- }
-
- modrinthDepends {
- optional("cloth-config")
- }
-}

View File

@@ -0,0 +1,39 @@
--- a/Forge/src/main/java/com/hypherionmc/craterlib/CraterLib.java
+++ /dev/null
@@ -1,36 +1,0 @@
-package com.hypherionmc.craterlib;
-
-import com.hypherionmc.craterlib.api.events.client.LateInitEvent;
-import com.hypherionmc.craterlib.common.ForgeServerEvents;
-import com.hypherionmc.craterlib.core.event.CraterEventBus;
-import com.hypherionmc.craterlib.core.networking.CraterPacketNetwork;
-import com.hypherionmc.craterlib.core.networking.data.PacketSide;
-import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
-import com.hypherionmc.craterlib.network.CraterForgeNetworkHandler;
-import com.hypherionmc.craterlib.nojang.client.BridgedMinecraft;
-import com.hypherionmc.craterlib.nojang.client.BridgedOptions;
-import net.minecraft.client.Minecraft;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.fml.DistExecutor;
-import net.minecraftforge.fml.common.Mod;
-import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
-import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
-import net.minecraftforge.fml.loading.FMLLoader;
-
-@Mod(CraterConstants.MOD_ID)
-public class CraterLib {
-
- public CraterLib() {
- MinecraftForge.EVENT_BUS.register(new ForgeServerEvents());
- FMLJavaModLoadingContext.get().getModEventBus().addListener(this::commonSetup);
- }
-
- public void commonSetup(FMLCommonSetupEvent evt) {
- new CraterPacketNetwork(new CraterForgeNetworkHandler(FMLLoader.getDist().isClient() ? PacketSide.CLIENT : PacketSide.SERVER));
- DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> {
- LateInitEvent event = new LateInitEvent(new BridgedMinecraft(), BridgedOptions.of(Minecraft.getInstance().options));
- CraterEventBus.INSTANCE.postEvent(event);
- });
- }
-}

View File

@@ -0,0 +1,28 @@
--- a/Forge/src/main/java/com/hypherionmc/craterlib/client/ForgeClientEvents.java
+++ /dev/null
@@ -1,25 +1,0 @@
-package com.hypherionmc.craterlib.client;
-
-import com.hypherionmc.craterlib.CraterConstants;
-import com.hypherionmc.craterlib.api.events.client.CraterClientTickEvent;
-import com.hypherionmc.craterlib.core.event.CraterEventBus;
-import com.hypherionmc.craterlib.nojang.client.multiplayer.BridgedClientLevel;
-import net.minecraft.client.Minecraft;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.event.TickEvent;
-import net.minecraftforge.eventbus.api.SubscribeEvent;
-import net.minecraftforge.fml.common.Mod;
-
-@Mod.EventBusSubscriber(modid = CraterConstants.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
-public class ForgeClientEvents {
-
- @SubscribeEvent
- public static void clientTick(TickEvent.LevelTickEvent event) {
- if (Minecraft.getInstance().level == null)
- return;
-
- CraterClientTickEvent craterClientTickEvent = new CraterClientTickEvent(BridgedClientLevel.of(Minecraft.getInstance().level));
- CraterEventBus.INSTANCE.postEvent(craterClientTickEvent);
- }
-
-}

View File

@@ -0,0 +1,44 @@
--- a/Forge/src/main/java/com/hypherionmc/craterlib/client/ForgeClientHelper.java
+++ /dev/null
@@ -1,41 +1,0 @@
-package com.hypherionmc.craterlib.client;
-
-import com.hypherionmc.craterlib.core.platform.ClientPlatform;
-import com.hypherionmc.craterlib.nojang.client.BridgedMinecraft;
-import com.hypherionmc.craterlib.nojang.client.multiplayer.BridgedClientLevel;
-import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
-import net.minecraft.client.Minecraft;
-import net.minecraft.network.Connection;
-
-import java.util.Objects;
-
-/**
- * @author HypherionSA
- * @date 16/06/2022
- */
-public class ForgeClientHelper implements ClientPlatform {
-
- public ForgeClientHelper() {
- }
-
- @Override
- public BridgedMinecraft getClientInstance() {
- return new BridgedMinecraft();
- }
-
- @Override
- public BridgedPlayer getClientPlayer() {
- return BridgedPlayer.of(Minecraft.getInstance().player);
- }
-
- @Override
- public BridgedClientLevel getClientLevel() {
- return BridgedClientLevel.of(Minecraft.getInstance().level);
- }
-
- @Override
- public Connection getClientConnection() {
- Objects.requireNonNull(Minecraft.getInstance().getConnection(), "Cannot send packets when not in game!");
- return Minecraft.getInstance().getConnection().getConnection();
- }
-}

View File

@@ -0,0 +1,29 @@
--- a/Forge/src/main/java/com/hypherionmc/craterlib/common/ForgeCommonHelper.java
+++ /dev/null
@@ -1,26 +1,0 @@
-package com.hypherionmc.craterlib.common;
-
-import com.hypherionmc.craterlib.core.platform.CommonPlatform;
-import com.hypherionmc.craterlib.nojang.server.BridgedMinecraftServer;
-import net.minecraft.resources.ResourceLocation;
-import net.minecraft.world.item.CreativeModeTab;
-import net.minecraftforge.server.ServerLifecycleHooks;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author HypherionSA
- */
-public class ForgeCommonHelper implements CommonPlatform {
-
- public static Map<ResourceLocation, CreativeModeTab> TABS = new HashMap<>();
-
- public ForgeCommonHelper() {
- }
-
- @Override
- public BridgedMinecraftServer getMCServer() {
- return BridgedMinecraftServer.of(ServerLifecycleHooks.getCurrentServer());
- }
-}

View File

@@ -0,0 +1,58 @@
--- a/Forge/src/main/java/com/hypherionmc/craterlib/common/ForgeCompatHelper.java
+++ /dev/null
@@ -1,55 +1,0 @@
-package com.hypherionmc.craterlib.common;
-
-import com.hypherionmc.craterlib.core.platform.CompatUtils;
-import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
-import team.creative.playerrevive.api.IBleeding;
-import team.creative.playerrevive.server.PlayerReviveServer;
-
-public class ForgeCompatHelper implements CompatUtils {
-
- @Override
- public boolean isPlayerActive(BridgedPlayer player) {
- return true;
- }
-
- @Override
- public String getSkinUUID(BridgedPlayer player) {
- return player.getStringUUID();
- }
-
- @Override
- public boolean isPlayerBleeding(BridgedPlayer player) {
- if (!ModloaderEnvironment.INSTANCE.isModLoaded("playerrevive"))
- return false;
-
- return PlayerReviveServer.isBleeding(player.toMojangServerPlayer());
- }
-
- @Override
- public boolean playerBledOut(BridgedPlayer player) {
- if (!ModloaderEnvironment.INSTANCE.isModLoaded("playerrevive"))
- return false;
-
- IBleeding bleeding = PlayerReviveServer.getBleeding(player.toMojangServerPlayer());
- return bleeding != null && bleeding.bledOut();
- }
-
- @Override
- public boolean playerRevived(BridgedPlayer player) {
- if (!ModloaderEnvironment.INSTANCE.isModLoaded("playerrevive"))
- return false;
-
- 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();
- }
-}

View File

@@ -0,0 +1,82 @@
--- a/Forge/src/main/java/com/hypherionmc/craterlib/common/ForgeLoaderHelper.java
+++ /dev/null
@@ -1,79 +1,0 @@
-package com.hypherionmc.craterlib.common;
-
-import com.hypherionmc.craterlib.core.platform.Environment;
-import com.hypherionmc.craterlib.core.platform.LoaderType;
-import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
-import net.minecraft.SharedConstants;
-import net.minecraft.client.Minecraft;
-import net.minecraftforge.fml.ModList;
-import net.minecraftforge.fml.loading.FMLLoader;
-import net.minecraftforge.fml.loading.FMLPaths;
-
-import java.io.File;
-
-/**
- * @author HypherionSA
- */
-public class ForgeLoaderHelper implements ModloaderEnvironment {
-
- public ForgeLoaderHelper() {
- }
-
- @Override
- public boolean isFabric() {
- return false;
- }
-
- @Override
- public LoaderType getLoaderType() {
- return LoaderType.FORGE;
- }
-
- @Override
- public String getGameVersion() {
- return SharedConstants.VERSION_STRING;
- }
-
- @Override
- public File getGameFolder() {
- return Minecraft.getInstance().gameDirectory;
- }
-
- @Override
- public File getConfigFolder() {
- return FMLPaths.CONFIGDIR.get().toFile();
- }
-
- @Override
- public File getModsFolder() {
- return FMLPaths.MODSDIR.get().toFile();
- }
-
- @Override
- public Environment getEnvironment() {
- switch (FMLLoader.getDist()) {
- case CLIENT -> {
- return Environment.CLIENT;
- }
- case DEDICATED_SERVER -> {
- return Environment.SERVER;
- }
- }
- return Environment.UNKNOWN;
- }
-
- @Override
- public boolean isModLoaded(String modid) {
- return ModList.get().isLoaded(modid);
- }
-
- @Override
- public boolean isDevEnv() {
- return !FMLLoader.isProduction();
- }
-
- @Override
- public int getModCount() {
- return ModList.get().size();
- }
-}

View File

@@ -0,0 +1,46 @@
--- a/Forge/src/main/java/com/hypherionmc/craterlib/common/ForgeServerEvents.java
+++ /dev/null
@@ -1,43 +1,0 @@
-package com.hypherionmc.craterlib.common;
-
-import com.hypherionmc.craterlib.api.events.server.CraterRegisterCommandEvent;
-import com.hypherionmc.craterlib.api.events.server.CraterServerLifecycleEvent;
-import com.hypherionmc.craterlib.core.event.CraterEventBus;
-import com.hypherionmc.craterlib.nojang.commands.CommandsRegistry;
-import com.hypherionmc.craterlib.nojang.server.BridgedMinecraftServer;
-import net.minecraftforge.event.RegisterCommandsEvent;
-import net.minecraftforge.event.server.ServerStartedEvent;
-import net.minecraftforge.event.server.ServerStartingEvent;
-import net.minecraftforge.event.server.ServerStoppedEvent;
-import net.minecraftforge.event.server.ServerStoppingEvent;
-import net.minecraftforge.eventbus.api.SubscribeEvent;
-
-public class ForgeServerEvents {
-
- @SubscribeEvent
- public void serverStarting(ServerStartingEvent event) {
- CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Starting(BridgedMinecraftServer.of(event.getServer())));
- }
-
- @SubscribeEvent
- public void serverStarted(ServerStartedEvent event) {
- CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Started(BridgedMinecraftServer.of(event.getServer())));
- }
-
- @SubscribeEvent
- public void serverStopping(ServerStoppingEvent event) {
- CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Stopping(BridgedMinecraftServer.of(event.getServer())));
- }
-
- @SubscribeEvent
- public void serverStopped(ServerStoppedEvent event) {
- CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Stopped(BridgedMinecraftServer.of(event.getServer())));
- }
-
- @SubscribeEvent
- public void onCommandRegister(RegisterCommandsEvent event) {
- CraterEventBus.INSTANCE.postEvent(new CraterRegisterCommandEvent());
- CommandsRegistry.INSTANCE.registerCommands(event.getDispatcher());
- }
-
-}

View File

@@ -0,0 +1,46 @@
--- a/Forge/src/main/java/com/hypherionmc/craterlib/mixin/ConfigScreenHandlerMixin.java
+++ /dev/null
@@ -1,43 +1,0 @@
-package com.hypherionmc.craterlib.mixin;
-
-import com.hypherionmc.craterlib.client.gui.config.CraterConfigScreen;
-import com.hypherionmc.craterlib.core.config.ConfigController;
-import com.hypherionmc.craterlib.core.config.ModuleConfig;
-import com.hypherionmc.craterlib.core.config.annotations.NoConfigScreen;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.screens.Screen;
-import net.minecraftforge.client.ConfigScreenHandler;
-import net.minecraftforge.forgespi.language.IModInfo;
-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.CallbackInfoReturnable;
-
-import java.util.Optional;
-import java.util.function.BiFunction;
-
-/**
- * @author HypherionSA
- */
-@Mixin(ConfigScreenHandler.class)
-public class ConfigScreenHandlerMixin {
-
- /**
- * Inject Auto Generated config Screens into forge
- *
- */
- @Inject(at = @At("RETURN"), method = "getScreenFactoryFor", cancellable = true, remap = false)
- private static void injectConfigScreen(IModInfo selectedMod, CallbackInfoReturnable<Optional<BiFunction<Minecraft, Screen, Screen>>> cir) {
- ConfigController.getMonitoredConfigs().forEach((conf, config) -> {
- if (config.getClass().isAnnotationPresent(NoConfigScreen.class))
- return;
-
- if (config.getClass().isAnnotationPresent(ClothScreen.class) && (ModloaderEnvironment.INSTANCE.isModLoaded("cloth_config") || ModloaderEnvironment.INSTANCE.isModLoaded("cloth-config") || ModloaderEnvironment.INSTANCE.isModLoaded("clothconfig"))) {
- ModList.get().getModContainerById(config.getModId()).ifPresent(c -> c.registerExtensionPoint(IConfigScreenFactory.class, ((minecraft, screen) -> ClothConfigScreenBuilder.buildConfigScreen(config, screen))));
- } else {
- //ModList.get().getModContainerById(config.getModId()).ifPresent(c -> c.registerExtensionPoint(IConfigScreenFactory.class, ((minecraft, screen) -> new CraterConfigScreen(config, screen))));
- }
- });
- }
-
-}

View File

@@ -0,0 +1,40 @@
--- a/Forge/src/main/java/com/hypherionmc/craterlib/mixin/ServerGamePacketListenerImplMixin.java
+++ /dev/null
@@ -1,37 +1,0 @@
-package com.hypherionmc.craterlib.mixin;
-
-import com.hypherionmc.craterlib.api.events.server.CraterServerChatEvent;
-import com.hypherionmc.craterlib.core.event.CraterEventBus;
-import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
-import com.hypherionmc.craterlib.utils.ChatUtils;
-import net.minecraft.network.chat.Component;
-import net.minecraft.network.chat.PlayerChatMessage;
-import net.minecraft.server.level.ServerPlayer;
-import net.minecraft.server.network.FilteredText;
-import net.minecraft.server.network.ServerGamePacketListenerImpl;
-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(value = ServerGamePacketListenerImpl.class, priority = Integer.MIN_VALUE)
-public class ServerGamePacketListenerImplMixin {
-
- @Shadow
- public ServerPlayer player;
-
- @Inject(
- method = "lambda$handleChat$5",
- at = @At("HEAD"),
- cancellable = true
- )
- private void injectChatEvent(Component component, PlayerChatMessage arg, FilteredText p_296589_, CallbackInfo ci) {
- Component finalcomp = component == null ? arg.decoratedContent() : component;
- CraterServerChatEvent event = new CraterServerChatEvent(BridgedPlayer.of(this.player), finalcomp.getString(), ChatUtils.mojangToAdventure(finalcomp));
- CraterEventBus.INSTANCE.postEvent(event);
- if (event.wasCancelled())
- ci.cancel();
- }
-
-}

View File

@@ -0,0 +1,56 @@
--- a/Forge/src/main/java/com/hypherionmc/craterlib/mixin/ServerStatusPacketListenerMixin.java
+++ /dev/null
@@ -1,53 +1,0 @@
-package com.hypherionmc.craterlib.mixin;
-
-import com.hypherionmc.craterlib.api.events.server.ServerStatusEvent;
-import com.hypherionmc.craterlib.core.event.CraterEventBus;
-import com.hypherionmc.craterlib.utils.ChatUtils;
-import net.minecraft.network.Connection;
-import net.minecraft.network.protocol.status.ClientboundStatusResponsePacket;
-import net.minecraft.network.protocol.status.ServerStatus;
-import net.minecraft.network.protocol.status.ServerboundStatusRequestPacket;
-import net.minecraft.server.network.ServerStatusPacketListenerImpl;
-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;
-
-@Mixin(ServerStatusPacketListenerImpl.class)
-public class ServerStatusPacketListenerMixin {
-
- @Shadow
- @Final
- private ServerStatus status;
-
- @Shadow @Final private Connection connection;
-
- @Inject(method = "handleStatusRequest",
- at = @At(
- value = "INVOKE",
- target = "Lnet/minecraft/network/Connection;send(Lnet/minecraft/network/protocol/Packet;)V",
- shift = At.Shift.BEFORE),
- cancellable = true
- )
- private void injectHandleStatusRequest(ServerboundStatusRequestPacket arg, CallbackInfo ci) {
- ServerStatusEvent.StatusRequestEvent event = new ServerStatusEvent.StatusRequestEvent(ChatUtils.mojangToAdventure(status.description()));
- CraterEventBus.INSTANCE.postEvent(event);
-
- if (event.getNewStatus() != null) {
- ci.cancel();
- this.connection.send(new ClientboundStatusResponsePacket(
- new ServerStatus(ChatUtils.adventureToMojang(
- event.getNewStatus()),
- status.players(),
- status.version(),
- status.favicon(),
- status.enforcesSecureChat(),
- status.isModded()
- )
- ));
- }
- }
-
-}

View File

@@ -0,0 +1,101 @@
--- a/Forge/src/main/java/com/hypherionmc/craterlib/network/CraterForgeNetworkHandler.java
+++ /dev/null
@@ -1,98 +1,0 @@
-package com.hypherionmc.craterlib.network;
-
-import com.hypherionmc.craterlib.CraterConstants;
-import com.hypherionmc.craterlib.core.networking.PacketRegistry;
-import com.hypherionmc.craterlib.core.networking.data.PacketContext;
-import com.hypherionmc.craterlib.core.networking.data.PacketHolder;
-import com.hypherionmc.craterlib.core.networking.data.PacketSide;
-import com.hypherionmc.craterlib.nojang.network.BridgedFriendlyByteBuf;
-import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
-import net.minecraft.client.Minecraft;
-import net.minecraft.network.Connection;
-import net.minecraft.network.FriendlyByteBuf;
-import net.minecraft.server.level.ServerPlayer;
-import net.minecraft.server.network.ServerGamePacketListenerImpl;
-import net.minecraftforge.event.network.CustomPayloadEvent;
-import net.minecraftforge.network.ChannelBuilder;
-import net.minecraftforge.network.PacketDistributor;
-import net.minecraftforge.network.SimpleChannel;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.function.BiConsumer;
-import java.util.function.Consumer;
-import java.util.function.Function;
-
-/**
- * Based on https://github.com/mysticdrew/common-networking/tree/1.20.4
- */
-public class CraterForgeNetworkHandler extends PacketRegistry {
- private final Map<Class<?>, SimpleChannel> CHANNELS = new HashMap<>();
-
- public CraterForgeNetworkHandler(PacketSide side) {
- super(side);
- }
-
- protected <T> void registerPacket(PacketHolder<T> holder) {
- if (CHANNELS.get(holder.messageType()) == null) {
- SimpleChannel channel = ChannelBuilder
- .named(holder.type().id())
- .clientAcceptedVersions((a, b) -> true)
- .serverAcceptedVersions((a, b) -> true)
- .networkProtocolVersion(1)
- .simpleChannel();
-
- channel.messageBuilder(holder.messageType())
- .decoder(mojangDecoder(holder.decoder()))
- .encoder(mojangEncoder(holder.encoder()))
- .consumerNetworkThread(buildHandler(holder.handler()))
- .add();
-
- CHANNELS.put(holder.messageType(), channel);
- } else {
- CraterConstants.LOG.error("Trying to register duplicate packet for type {}", holder.messageType());
- }
- }
-
- public <T> void sendToServer(T packet) {
- this.sendToServer(packet, false);
- }
-
- public <T> void sendToServer(T packet, boolean ignoreCheck) {
- SimpleChannel channel = CHANNELS.get(packet.getClass());
- Connection connection = Minecraft.getInstance().getConnection().getConnection();
- if (channel.isRemotePresent(connection) || ignoreCheck) {
- channel.send(packet, PacketDistributor.SERVER.noArg());
- }
- }
-
- public <T> void sendToClient(T packet, BridgedPlayer player) {
- SimpleChannel channel = CHANNELS.get(packet.getClass());
- ServerGamePacketListenerImpl connection = player.getConnection();
- if (connection == null)
- return;
-
- if (channel.isRemotePresent(connection.getConnection())) {
- channel.send(packet, PacketDistributor.PLAYER.with(player.toMojangServerPlayer()));
- }
- }
-
- private <T> Function<FriendlyByteBuf, T> mojangDecoder(Function<BridgedFriendlyByteBuf, T> handler) {
- return byteBuf -> handler.apply(BridgedFriendlyByteBuf.of(byteBuf));
- }
-
- private <T> BiConsumer<T, FriendlyByteBuf> mojangEncoder(BiConsumer<T, BridgedFriendlyByteBuf> handler) {
- return ((t, byteBuf) -> handler.accept(t, BridgedFriendlyByteBuf.of(byteBuf)));
- }
-
- private <T> BiConsumer<T, CustomPayloadEvent.Context> buildHandler(Consumer<PacketContext<T>> handler) {
- return (message, ctx) -> {
- ctx.enqueueWork(() -> {
- PacketSide side = ctx.getDirection().getReceptionSide().isServer() ? PacketSide.SERVER : PacketSide.CLIENT;
- ServerPlayer player = ctx.getSender();
- handler.accept(new PacketContext<>(BridgedPlayer.of(player), message, side));
- });
- ctx.setPacketHandled(true);
- };
- }
-}

View File

@@ -0,0 +1,34 @@
--- a/Forge/src/main/resources/META-INF/mods.toml
+++ /dev/null
@@ -1,31 +1,0 @@
-modLoader = "javafml"
-loaderVersion = "[50,)"
-license = "MIT"
-issueTrackerURL = "https://github.com/firstdarkdev/craterLib/issues"
-
-[[mods]]
- modId = "${mod_id}"
- version = "${version}"
- displayName = "${mod_name}"
- displayURL = "https://modrinth.com/mod/craterlib"
- logoFile = "craterlib_logo.png"
- #credits="Thanks for this example mod goes to Java"
- authors = "${mod_author}, Zenith"
- description = '''
- A library mod used by First Dark Development and HypherionSA Mods
- '''
- displayTest = "NONE"
-
-[[dependencies.${ mod_id }]]
- modId = "forge"
- mandatory = true
- versionRange = "[50,)"
- ordering = "NONE"
- side = "BOTH"
-
-[[dependencies.${ mod_id }]]
- modId = "minecraft"
- mandatory = true
- versionRange = "[1.20.6,1.21)"
- ordering = "NONE"
- side = "BOTH"

View File

@@ -0,0 +1,4 @@
--- a/Forge/src/main/resources/META-INF/services/com.hypherionmc.craterlib.core.platform.ClientPlatform
+++ /dev/null
@@ -1,1 +1,0 @@
-com.hypherionmc.craterlib.client.ForgeClientHelper

View File

@@ -0,0 +1,4 @@
--- a/Forge/src/main/resources/META-INF/services/com.hypherionmc.craterlib.core.platform.CommonPlatform
+++ /dev/null
@@ -1,1 +1,0 @@
-com.hypherionmc.craterlib.common.ForgeCommonHelper

View File

@@ -0,0 +1,4 @@
--- a/Forge/src/main/resources/META-INF/services/com.hypherionmc.craterlib.core.platform.CompatUtils
+++ /dev/null
@@ -1,1 +1,0 @@
-com.hypherionmc.craterlib.common.ForgeCompatHelper

View File

@@ -0,0 +1,4 @@
--- a/Forge/src/main/resources/META-INF/services/com.hypherionmc.craterlib.core.platform.ModloaderEnvironment
+++ /dev/null
@@ -1,1 +1,0 @@
-com.hypherionmc.craterlib.common.ForgeLoaderHelper

View File

@@ -0,0 +1,21 @@
--- a/Forge/src/main/resources/craterlib.forge.mixins.json
+++ /dev/null
@@ -1,18 +1,0 @@
-{
- "required": true,
- "minVersion": "0.8",
- "package": "com.hypherionmc.craterlib.mixin",
- "compatibilityLevel": "JAVA_17",
- "mixins": [
- ],
- "client": [
- "ConfigScreenHandlerMixin"
- ],
- "server": [
- "ServerGamePacketListenerImplMixin",
- "ServerStatusPacketListenerMixin"
- ],
- "injectors": {
- "defaultRequire": 1
- }
-}

View File

@@ -0,0 +1,10 @@
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/common/NeoForgeCompatHelper.java
+++ b/NeoForge/src/main/java/com/hypherionmc/craterlib/common/NeoForgeCompatHelper.java
@@ -3,6 +3,7 @@
import com.hypherionmc.craterlib.core.platform.CompatUtils;
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
+import net.kyori.adventure.text.Component;
import redstonedubstep.mods.vanishmod.VanishUtil;
import team.creative.playerrevive.api.IBleeding;
import team.creative.playerrevive.server.PlayerReviveServer;

View File

@@ -1,5 +1,12 @@
--- a/Paper/build.gradle
+++ b/Paper/build.gradle
@@ -1,5 +1,5 @@
plugins {
- id "io.papermc.paperweight.userdev" version "1.7.3"
+ id "io.papermc.paperweight.userdev" version "1.7.7"
id "xyz.jpenilla.run-paper" version "2.3.0"
}
@@ -68,8 +68,8 @@
setVersionType("alpha")
setChangelog(rootProject.file("changelog.md"))

View File

@@ -16,3 +16,12 @@
# Forge
forge_version=50.0.6
@@ -41,7 +41,7 @@
ftb_ranks=2101.1.1
player_revive=6119534
creative_core=6113754
-advanced_chat=SNA4dye5
+advanced_chat=CEJSc93h
# Publishing
curse_id=867099

View File

@@ -1,10 +1,10 @@
--- a/settings.gradle
+++ b/settings.gradle
@@ -14,6 +14,6 @@
@@ -14,6 +14,5 @@
}
rootProject.name = 'CraterLib'
-include("Common", "Fabric"/*, "NeoForge"*/)
+include("Common", "Fabric", "NeoForge")
//include 'Paper'
-

View File

@@ -1,6 +1,6 @@
--- a/Fabric/build.gradle
+++ b/Fabric/build.gradle
@@ -117,8 +117,8 @@
@@ -118,8 +118,8 @@
setVersionType("release")
setChangelog(rootProject.file("changelog.md"))
setProjectVersion("${minecraft_version}-${project.version}")

View File

@@ -1,6 +1,6 @@
--- a/Forge/src/main/java/com/hypherionmc/craterlib/common/ForgeCompatHelper.java
+++ /dev/null
@@ -1,45 +1,0 @@
@@ -1,55 +1,0 @@
-package com.hypherionmc.craterlib.common;
-
-import com.hypherionmc.craterlib.core.platform.CompatUtils;
@@ -45,4 +45,14 @@
- 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();
- }
-}

View File

@@ -0,0 +1,10 @@
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/common/NeoForgeCompatHelper.java
+++ b/NeoForge/src/main/java/com/hypherionmc/craterlib/common/NeoForgeCompatHelper.java
@@ -3,6 +3,7 @@
import com.hypherionmc.craterlib.core.platform.CompatUtils;
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
+import net.kyori.adventure.text.Component;
import redstonedubstep.mods.vanishmod.VanishUtil;
import team.creative.playerrevive.api.IBleeding;
import team.creative.playerrevive.server.PlayerReviveServer;

View File

@@ -0,0 +1,10 @@
--- a/Paper/src/main/java/com/hypherionmc/craterlib/common/PaperCompatHelper.java
+++ b/Paper/src/main/java/com/hypherionmc/craterlib/common/PaperCompatHelper.java
@@ -4,6 +4,7 @@
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
import com.hypherionmc.craterlib.utils.ChatUtils;
+import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.metadata.MetadataValue;

View File

@@ -32,12 +32,14 @@
# Mod Dependencies
fabrictailor=2.3.1
@@ -39,13 +39,13 @@
@@ -39,14 +39,14 @@
vanishmod_neo=puxrKAMr
ftb_essentials=2101.1.0
ftb_ranks=2101.1.1
-player_revive=6119534
-creative_core=6113754
-advanced_chat=SNA4dye5
+advanced_chat=5ddOPqgR
+player_revive=6130248
+creative_core=6109912