[DEV] Backport fixes from DEV branch.
This commit is contained in:
@@ -22,12 +22,12 @@ public class CraterPlayerEvent extends CraterEvent {
|
||||
|
||||
public PlayerLoggedIn(BridgedPlayer player, boolean isFromVanish) {
|
||||
super(player);
|
||||
this.isFromVanish = false;
|
||||
this.isFromVanish = isFromVanish;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Getter @Setter
|
||||
@Getter
|
||||
public static class PlayerLoggedOut extends CraterPlayerEvent {
|
||||
private final boolean isFromVanish;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class CraterPlayerEvent extends CraterEvent {
|
||||
|
||||
public PlayerLoggedOut(BridgedPlayer player, boolean isFromVanish) {
|
||||
super(player);
|
||||
this.isFromVanish = false;
|
||||
this.isFromVanish = isFromVanish;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,8 @@
|
||||
package com.hypherionmc.craterlib.core.platform;
|
||||
|
||||
public enum LoaderType {
|
||||
FABRIC,
|
||||
FORGE,
|
||||
NEOFORGE,
|
||||
PAPER
|
||||
}
|
@@ -12,8 +12,11 @@ public interface ModloaderEnvironment {
|
||||
|
||||
public final ModloaderEnvironment INSTANCE = InternalServiceUtil.load(ModloaderEnvironment.class);
|
||||
|
||||
@Deprecated(forRemoval = true, since = "2.0.2")
|
||||
boolean isFabric();
|
||||
|
||||
LoaderType getLoaderType();
|
||||
|
||||
String getGameVersion();
|
||||
|
||||
File getGameFolder();
|
||||
|
@@ -54,7 +54,7 @@ public class ChatUtils {
|
||||
|
||||
public static String resolve(net.kyori.adventure.text.Component component, boolean formatted) {
|
||||
Component c = adventureToMojang(component);
|
||||
String returnVal = ChatFormatting.stripFormatting(c.getString());
|
||||
String returnVal = ChatFormatting.stripFormatting(DiscordMarkdownStripper.stripMarkdown(c.getString()));
|
||||
|
||||
if (formatted) {
|
||||
returnVal = DiscordSerializer.INSTANCE.serialize(safeCopy(c).copy());
|
||||
|
@@ -0,0 +1,35 @@
|
||||
package com.hypherionmc.craterlib.utils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class DiscordMarkdownStripper {
|
||||
|
||||
// Patterns for different markdown syntaxes
|
||||
private static final Pattern BOLD = Pattern.compile("\\*\\*(.*?)\\*\\*");
|
||||
private static final Pattern ITALIC_UNDERSCORE = Pattern.compile("_(.*?)_");
|
||||
private static final Pattern ITALIC_ASTERISK = Pattern.compile("\\*(.*?)\\*");
|
||||
private static final Pattern UNDERLINE = Pattern.compile("__(.*?)__");
|
||||
private static final Pattern STRIKETHROUGH = Pattern.compile("~~(.*?)~~");
|
||||
private static final Pattern CODE_BLOCK = Pattern.compile("```(.+?)```", Pattern.DOTALL);
|
||||
private static final Pattern INLINE_CODE = Pattern.compile("`([^`]*)`");
|
||||
private static final Pattern BLOCKQUOTE = Pattern.compile("^> (.*?$)", Pattern.MULTILINE);
|
||||
private static final Pattern MARKDOWN_LINK = Pattern.compile("\\[(.*?)\\]\\((.*?)\\)");
|
||||
private static final Pattern PLAIN_URL = Pattern.compile("\\b(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]");
|
||||
|
||||
public static String stripMarkdown(@NotNull String text) {
|
||||
text = BOLD.matcher(text).replaceAll("$1");
|
||||
text = ITALIC_UNDERSCORE.matcher(text).replaceAll("$1");
|
||||
text = ITALIC_ASTERISK.matcher(text).replaceAll("$1");
|
||||
text = UNDERLINE.matcher(text).replaceAll("$1");
|
||||
text = STRIKETHROUGH.matcher(text).replaceAll("$1");
|
||||
text = CODE_BLOCK.matcher(text).replaceAll("$1");
|
||||
text = INLINE_CODE.matcher(text).replaceAll("$1");
|
||||
text = BLOCKQUOTE.matcher(text).replaceAll("$1");
|
||||
text = MARKDOWN_LINK.matcher(text).replaceAll("$1");
|
||||
text = PLAIN_URL.matcher(text).replaceAll("<$0>");
|
||||
|
||||
return text;
|
||||
}
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
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.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.SharedConstants;
|
||||
@@ -19,6 +20,11 @@ public class FabricLoaderHelper implements ModloaderEnvironment {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoaderType getLoaderType() {
|
||||
return LoaderType.FABRIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGameVersion() {
|
||||
return SharedConstants.VERSION_STRING;
|
||||
|
@@ -1,6 +1,7 @@
|
||||
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;
|
||||
@@ -23,6 +24,11 @@ public class ForgeLoaderHelper implements ModloaderEnvironment {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoaderType getLoaderType() {
|
||||
return LoaderType.FORGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGameVersion() {
|
||||
return SharedConstants.VERSION_STRING;
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Project
|
||||
version_major=2
|
||||
version_minor=0
|
||||
version_patch=1
|
||||
version_build=1
|
||||
version_patch=2
|
||||
version_build=0
|
||||
|
||||
#Mod
|
||||
mod_author=HypherionSA
|
||||
|
@@ -22,12 +22,12 @@ public class CraterPlayerEvent extends CraterEvent {
|
||||
|
||||
public PlayerLoggedIn(BridgedPlayer player, boolean isFromVanish) {
|
||||
super(player);
|
||||
this.isFromVanish = false;
|
||||
this.isFromVanish = isFromVanish;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Getter @Setter
|
||||
@Getter
|
||||
public static class PlayerLoggedOut extends CraterPlayerEvent {
|
||||
private final boolean isFromVanish;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class CraterPlayerEvent extends CraterEvent {
|
||||
|
||||
public PlayerLoggedOut(BridgedPlayer player, boolean isFromVanish) {
|
||||
super(player);
|
||||
this.isFromVanish = false;
|
||||
this.isFromVanish = isFromVanish;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,8 @@
|
||||
package com.hypherionmc.craterlib.core.platform;
|
||||
|
||||
public enum LoaderType {
|
||||
FABRIC,
|
||||
FORGE,
|
||||
NEOFORGE,
|
||||
PAPER
|
||||
}
|
@@ -12,8 +12,11 @@ public interface ModloaderEnvironment {
|
||||
|
||||
public final ModloaderEnvironment INSTANCE = InternalServiceUtil.load(ModloaderEnvironment.class);
|
||||
|
||||
@Deprecated(forRemoval = true, since = "2.0.2")
|
||||
boolean isFabric();
|
||||
|
||||
LoaderType getLoaderType();
|
||||
|
||||
String getGameVersion();
|
||||
|
||||
File getGameFolder();
|
||||
|
@@ -11,7 +11,6 @@ import net.minecraft.SharedConstants;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
|
||||
public class ChatUtils {
|
||||
|
||||
private static final GsonComponentSerializer adventureSerializer = GsonComponentSerializer.builder().options(
|
||||
@@ -52,7 +51,7 @@ public class ChatUtils {
|
||||
|
||||
public static String resolve(net.kyori.adventure.text.Component component, boolean formatted) {
|
||||
Component c = adventureToMojang(component);
|
||||
String returnVal = ChatFormatting.stripFormatting(c.getString());
|
||||
String returnVal = ChatFormatting.stripFormatting(DiscordMarkdownStripper.stripMarkdown(c.getString()));
|
||||
|
||||
if (formatted) {
|
||||
returnVal = DiscordSerializer.INSTANCE.serialize(safeCopy(c).copy());
|
||||
|
@@ -0,0 +1,35 @@
|
||||
package com.hypherionmc.craterlib.utils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class DiscordMarkdownStripper {
|
||||
|
||||
// Patterns for different markdown syntaxes
|
||||
private static final Pattern BOLD = Pattern.compile("\\*\\*(.*?)\\*\\*");
|
||||
private static final Pattern ITALIC_UNDERSCORE = Pattern.compile("_(.*?)_");
|
||||
private static final Pattern ITALIC_ASTERISK = Pattern.compile("\\*(.*?)\\*");
|
||||
private static final Pattern UNDERLINE = Pattern.compile("__(.*?)__");
|
||||
private static final Pattern STRIKETHROUGH = Pattern.compile("~~(.*?)~~");
|
||||
private static final Pattern CODE_BLOCK = Pattern.compile("```(.+?)```", Pattern.DOTALL);
|
||||
private static final Pattern INLINE_CODE = Pattern.compile("`([^`]*)`");
|
||||
private static final Pattern BLOCKQUOTE = Pattern.compile("^> (.*?$)", Pattern.MULTILINE);
|
||||
private static final Pattern MARKDOWN_LINK = Pattern.compile("\\[(.*?)\\]\\((.*?)\\)");
|
||||
private static final Pattern PLAIN_URL = Pattern.compile("\\b(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]");
|
||||
|
||||
public static String stripMarkdown(@NotNull String text) {
|
||||
text = BOLD.matcher(text).replaceAll("$1");
|
||||
text = ITALIC_UNDERSCORE.matcher(text).replaceAll("$1");
|
||||
text = ITALIC_ASTERISK.matcher(text).replaceAll("$1");
|
||||
text = UNDERLINE.matcher(text).replaceAll("$1");
|
||||
text = STRIKETHROUGH.matcher(text).replaceAll("$1");
|
||||
text = CODE_BLOCK.matcher(text).replaceAll("$1");
|
||||
text = INLINE_CODE.matcher(text).replaceAll("$1");
|
||||
text = BLOCKQUOTE.matcher(text).replaceAll("$1");
|
||||
text = MARKDOWN_LINK.matcher(text).replaceAll("$1");
|
||||
text = PLAIN_URL.matcher(text).replaceAll("<$0>");
|
||||
|
||||
return text;
|
||||
}
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
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.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.SharedConstants;
|
||||
@@ -19,6 +20,11 @@ public class FabricLoaderHelper implements ModloaderEnvironment {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoaderType getLoaderType() {
|
||||
return LoaderType.FABRIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGameVersion() {
|
||||
return SharedConstants.VERSION_STRING;
|
||||
|
@@ -1,6 +1,7 @@
|
||||
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;
|
||||
@@ -23,6 +24,11 @@ public class ForgeLoaderHelper implements ModloaderEnvironment {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoaderType getLoaderType() {
|
||||
return LoaderType.FORGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGameVersion() {
|
||||
return SharedConstants.VERSION_STRING;
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Project
|
||||
version_major=2
|
||||
version_minor=0
|
||||
version_patch=1
|
||||
version_build=1
|
||||
version_patch=2
|
||||
version_build=0
|
||||
|
||||
#Mod
|
||||
mod_author=HypherionSA
|
||||
|
@@ -22,12 +22,12 @@ public class CraterPlayerEvent extends CraterEvent {
|
||||
|
||||
public PlayerLoggedIn(BridgedPlayer player, boolean isFromVanish) {
|
||||
super(player);
|
||||
this.isFromVanish = false;
|
||||
this.isFromVanish = isFromVanish;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Getter @Setter
|
||||
@Getter
|
||||
public static class PlayerLoggedOut extends CraterPlayerEvent {
|
||||
private final boolean isFromVanish;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class CraterPlayerEvent extends CraterEvent {
|
||||
|
||||
public PlayerLoggedOut(BridgedPlayer player, boolean isFromVanish) {
|
||||
super(player);
|
||||
this.isFromVanish = false;
|
||||
this.isFromVanish = isFromVanish;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,8 @@
|
||||
package com.hypherionmc.craterlib.core.platform;
|
||||
|
||||
public enum LoaderType {
|
||||
FABRIC,
|
||||
FORGE,
|
||||
NEOFORGE,
|
||||
PAPER
|
||||
}
|
@@ -12,8 +12,11 @@ public interface ModloaderEnvironment {
|
||||
|
||||
public final ModloaderEnvironment INSTANCE = InternalServiceUtil.load(ModloaderEnvironment.class);
|
||||
|
||||
@Deprecated(forRemoval = true, since = "2.0.2")
|
||||
boolean isFabric();
|
||||
|
||||
LoaderType getLoaderType();
|
||||
|
||||
String getGameVersion();
|
||||
|
||||
File getGameFolder();
|
||||
|
@@ -11,7 +11,6 @@ import net.minecraft.SharedConstants;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
|
||||
public class ChatUtils {
|
||||
|
||||
private static final GsonComponentSerializer adventureSerializer = GsonComponentSerializer.builder().options(
|
||||
@@ -52,7 +51,7 @@ public class ChatUtils {
|
||||
|
||||
public static String resolve(net.kyori.adventure.text.Component component, boolean formatted) {
|
||||
Component c = adventureToMojang(component);
|
||||
String returnVal = ChatFormatting.stripFormatting(c.getString());
|
||||
String returnVal = ChatFormatting.stripFormatting(DiscordMarkdownStripper.stripMarkdown(c.getString()));
|
||||
|
||||
if (formatted) {
|
||||
returnVal = DiscordSerializer.INSTANCE.serialize(safeCopy(c).copy());
|
||||
|
@@ -0,0 +1,35 @@
|
||||
package com.hypherionmc.craterlib.utils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class DiscordMarkdownStripper {
|
||||
|
||||
// Patterns for different markdown syntaxes
|
||||
private static final Pattern BOLD = Pattern.compile("\\*\\*(.*?)\\*\\*");
|
||||
private static final Pattern ITALIC_UNDERSCORE = Pattern.compile("_(.*?)_");
|
||||
private static final Pattern ITALIC_ASTERISK = Pattern.compile("\\*(.*?)\\*");
|
||||
private static final Pattern UNDERLINE = Pattern.compile("__(.*?)__");
|
||||
private static final Pattern STRIKETHROUGH = Pattern.compile("~~(.*?)~~");
|
||||
private static final Pattern CODE_BLOCK = Pattern.compile("```(.+?)```", Pattern.DOTALL);
|
||||
private static final Pattern INLINE_CODE = Pattern.compile("`([^`]*)`");
|
||||
private static final Pattern BLOCKQUOTE = Pattern.compile("^> (.*?$)", Pattern.MULTILINE);
|
||||
private static final Pattern MARKDOWN_LINK = Pattern.compile("\\[(.*?)\\]\\((.*?)\\)");
|
||||
private static final Pattern PLAIN_URL = Pattern.compile("\\b(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]");
|
||||
|
||||
public static String stripMarkdown(@NotNull String text) {
|
||||
text = BOLD.matcher(text).replaceAll("$1");
|
||||
text = ITALIC_UNDERSCORE.matcher(text).replaceAll("$1");
|
||||
text = ITALIC_ASTERISK.matcher(text).replaceAll("$1");
|
||||
text = UNDERLINE.matcher(text).replaceAll("$1");
|
||||
text = STRIKETHROUGH.matcher(text).replaceAll("$1");
|
||||
text = CODE_BLOCK.matcher(text).replaceAll("$1");
|
||||
text = INLINE_CODE.matcher(text).replaceAll("$1");
|
||||
text = BLOCKQUOTE.matcher(text).replaceAll("$1");
|
||||
text = MARKDOWN_LINK.matcher(text).replaceAll("$1");
|
||||
text = PLAIN_URL.matcher(text).replaceAll("<$0>");
|
||||
|
||||
return text;
|
||||
}
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
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.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.SharedConstants;
|
||||
@@ -19,6 +20,11 @@ public class FabricLoaderHelper implements ModloaderEnvironment {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoaderType getLoaderType() {
|
||||
return LoaderType.FABRIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGameVersion() {
|
||||
return SharedConstants.VERSION_STRING;
|
||||
|
@@ -1,6 +1,7 @@
|
||||
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;
|
||||
@@ -23,6 +24,11 @@ public class ForgeLoaderHelper implements ModloaderEnvironment {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoaderType getLoaderType() {
|
||||
return LoaderType.FORGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGameVersion() {
|
||||
return SharedConstants.VERSION_STRING;
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Project
|
||||
version_major=2
|
||||
version_minor=0
|
||||
version_patch=1
|
||||
version_build=1
|
||||
version_patch=2
|
||||
version_build=0
|
||||
|
||||
#Mod
|
||||
mod_author=HypherionSA
|
||||
|
@@ -22,12 +22,12 @@ public class CraterPlayerEvent extends CraterEvent {
|
||||
|
||||
public PlayerLoggedIn(BridgedPlayer player, boolean isFromVanish) {
|
||||
super(player);
|
||||
this.isFromVanish = false;
|
||||
this.isFromVanish = isFromVanish;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Getter @Setter
|
||||
@Getter
|
||||
public static class PlayerLoggedOut extends CraterPlayerEvent {
|
||||
private final boolean isFromVanish;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class CraterPlayerEvent extends CraterEvent {
|
||||
|
||||
public PlayerLoggedOut(BridgedPlayer player, boolean isFromVanish) {
|
||||
super(player);
|
||||
this.isFromVanish = false;
|
||||
this.isFromVanish = isFromVanish;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,8 @@
|
||||
package com.hypherionmc.craterlib.core.platform;
|
||||
|
||||
public enum LoaderType {
|
||||
FABRIC,
|
||||
FORGE,
|
||||
NEOFORGE,
|
||||
PAPER
|
||||
}
|
@@ -12,8 +12,11 @@ public interface ModloaderEnvironment {
|
||||
|
||||
public final ModloaderEnvironment INSTANCE = InternalServiceUtil.load(ModloaderEnvironment.class);
|
||||
|
||||
@Deprecated(forRemoval = true, since = "2.0.2")
|
||||
boolean isFabric();
|
||||
|
||||
LoaderType getLoaderType();
|
||||
|
||||
String getGameVersion();
|
||||
|
||||
File getGameFolder();
|
||||
|
@@ -11,7 +11,6 @@ import net.minecraft.SharedConstants;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
|
||||
public class ChatUtils {
|
||||
|
||||
private static final GsonComponentSerializer adventureSerializer = GsonComponentSerializer.builder().options(
|
||||
@@ -52,7 +51,7 @@ public class ChatUtils {
|
||||
|
||||
public static String resolve(net.kyori.adventure.text.Component component, boolean formatted) {
|
||||
Component c = adventureToMojang(component);
|
||||
String returnVal = ChatFormatting.stripFormatting(c.getString());
|
||||
String returnVal = ChatFormatting.stripFormatting(DiscordMarkdownStripper.stripMarkdown(c.getString()));
|
||||
|
||||
if (formatted) {
|
||||
returnVal = DiscordSerializer.INSTANCE.serialize(safeCopy(c).copy());
|
||||
|
@@ -0,0 +1,35 @@
|
||||
package com.hypherionmc.craterlib.utils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class DiscordMarkdownStripper {
|
||||
|
||||
// Patterns for different markdown syntaxes
|
||||
private static final Pattern BOLD = Pattern.compile("\\*\\*(.*?)\\*\\*");
|
||||
private static final Pattern ITALIC_UNDERSCORE = Pattern.compile("_(.*?)_");
|
||||
private static final Pattern ITALIC_ASTERISK = Pattern.compile("\\*(.*?)\\*");
|
||||
private static final Pattern UNDERLINE = Pattern.compile("__(.*?)__");
|
||||
private static final Pattern STRIKETHROUGH = Pattern.compile("~~(.*?)~~");
|
||||
private static final Pattern CODE_BLOCK = Pattern.compile("```(.+?)```", Pattern.DOTALL);
|
||||
private static final Pattern INLINE_CODE = Pattern.compile("`([^`]*)`");
|
||||
private static final Pattern BLOCKQUOTE = Pattern.compile("^> (.*?$)", Pattern.MULTILINE);
|
||||
private static final Pattern MARKDOWN_LINK = Pattern.compile("\\[(.*?)\\]\\((.*?)\\)");
|
||||
private static final Pattern PLAIN_URL = Pattern.compile("\\b(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]");
|
||||
|
||||
public static String stripMarkdown(@NotNull String text) {
|
||||
text = BOLD.matcher(text).replaceAll("$1");
|
||||
text = ITALIC_UNDERSCORE.matcher(text).replaceAll("$1");
|
||||
text = ITALIC_ASTERISK.matcher(text).replaceAll("$1");
|
||||
text = UNDERLINE.matcher(text).replaceAll("$1");
|
||||
text = STRIKETHROUGH.matcher(text).replaceAll("$1");
|
||||
text = CODE_BLOCK.matcher(text).replaceAll("$1");
|
||||
text = INLINE_CODE.matcher(text).replaceAll("$1");
|
||||
text = BLOCKQUOTE.matcher(text).replaceAll("$1");
|
||||
text = MARKDOWN_LINK.matcher(text).replaceAll("$1");
|
||||
text = PLAIN_URL.matcher(text).replaceAll("<$0>");
|
||||
|
||||
return text;
|
||||
}
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
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.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.SharedConstants;
|
||||
@@ -19,6 +20,11 @@ public class FabricLoaderHelper implements ModloaderEnvironment {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoaderType getLoaderType() {
|
||||
return LoaderType.FABRIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGameVersion() {
|
||||
return SharedConstants.VERSION_STRING;
|
||||
|
@@ -1,6 +1,7 @@
|
||||
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;
|
||||
@@ -23,6 +24,11 @@ public class ForgeLoaderHelper implements ModloaderEnvironment {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoaderType getLoaderType() {
|
||||
return LoaderType.FORGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGameVersion() {
|
||||
return SharedConstants.VERSION_STRING;
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Project
|
||||
version_major=2
|
||||
version_minor=0
|
||||
version_patch=1
|
||||
version_build=1
|
||||
version_patch=2
|
||||
version_build=0
|
||||
|
||||
#Mod
|
||||
mod_author=HypherionSA
|
||||
|
@@ -22,12 +22,12 @@ public class CraterPlayerEvent extends CraterEvent {
|
||||
|
||||
public PlayerLoggedIn(BridgedPlayer player, boolean isFromVanish) {
|
||||
super(player);
|
||||
this.isFromVanish = false;
|
||||
this.isFromVanish = isFromVanish;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Getter @Setter
|
||||
@Getter
|
||||
public static class PlayerLoggedOut extends CraterPlayerEvent {
|
||||
private final boolean isFromVanish;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class CraterPlayerEvent extends CraterEvent {
|
||||
|
||||
public PlayerLoggedOut(BridgedPlayer player, boolean isFromVanish) {
|
||||
super(player);
|
||||
this.isFromVanish = false;
|
||||
this.isFromVanish = isFromVanish;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,8 @@
|
||||
package com.hypherionmc.craterlib.core.platform;
|
||||
|
||||
public enum LoaderType {
|
||||
FABRIC,
|
||||
FORGE,
|
||||
NEOFORGE,
|
||||
PAPER
|
||||
}
|
@@ -12,8 +12,11 @@ public interface ModloaderEnvironment {
|
||||
|
||||
public final ModloaderEnvironment INSTANCE = InternalServiceUtil.load(ModloaderEnvironment.class);
|
||||
|
||||
@Deprecated(forRemoval = true, since = "2.0.2")
|
||||
boolean isFabric();
|
||||
|
||||
LoaderType getLoaderType();
|
||||
|
||||
String getGameVersion();
|
||||
|
||||
File getGameFolder();
|
||||
|
@@ -11,7 +11,6 @@ import net.minecraft.SharedConstants;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
|
||||
public class ChatUtils {
|
||||
|
||||
private static final GsonComponentSerializer adventureSerializer = GsonComponentSerializer.builder().options(
|
||||
@@ -52,7 +51,7 @@ public class ChatUtils {
|
||||
|
||||
public static String resolve(net.kyori.adventure.text.Component component, boolean formatted) {
|
||||
Component c = adventureToMojang(component);
|
||||
String returnVal = ChatFormatting.stripFormatting(c.getString());
|
||||
String returnVal = ChatFormatting.stripFormatting(DiscordMarkdownStripper.stripMarkdown(c.getString()));
|
||||
|
||||
if (formatted) {
|
||||
returnVal = DiscordSerializer.INSTANCE.serialize(safeCopy(c).copy());
|
||||
|
@@ -0,0 +1,35 @@
|
||||
package com.hypherionmc.craterlib.utils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class DiscordMarkdownStripper {
|
||||
|
||||
// Patterns for different markdown syntaxes
|
||||
private static final Pattern BOLD = Pattern.compile("\\*\\*(.*?)\\*\\*");
|
||||
private static final Pattern ITALIC_UNDERSCORE = Pattern.compile("_(.*?)_");
|
||||
private static final Pattern ITALIC_ASTERISK = Pattern.compile("\\*(.*?)\\*");
|
||||
private static final Pattern UNDERLINE = Pattern.compile("__(.*?)__");
|
||||
private static final Pattern STRIKETHROUGH = Pattern.compile("~~(.*?)~~");
|
||||
private static final Pattern CODE_BLOCK = Pattern.compile("```(.+?)```", Pattern.DOTALL);
|
||||
private static final Pattern INLINE_CODE = Pattern.compile("`([^`]*)`");
|
||||
private static final Pattern BLOCKQUOTE = Pattern.compile("^> (.*?$)", Pattern.MULTILINE);
|
||||
private static final Pattern MARKDOWN_LINK = Pattern.compile("\\[(.*?)\\]\\((.*?)\\)");
|
||||
private static final Pattern PLAIN_URL = Pattern.compile("\\b(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]");
|
||||
|
||||
public static String stripMarkdown(@NotNull String text) {
|
||||
text = BOLD.matcher(text).replaceAll("$1");
|
||||
text = ITALIC_UNDERSCORE.matcher(text).replaceAll("$1");
|
||||
text = ITALIC_ASTERISK.matcher(text).replaceAll("$1");
|
||||
text = UNDERLINE.matcher(text).replaceAll("$1");
|
||||
text = STRIKETHROUGH.matcher(text).replaceAll("$1");
|
||||
text = CODE_BLOCK.matcher(text).replaceAll("$1");
|
||||
text = INLINE_CODE.matcher(text).replaceAll("$1");
|
||||
text = BLOCKQUOTE.matcher(text).replaceAll("$1");
|
||||
text = MARKDOWN_LINK.matcher(text).replaceAll("$1");
|
||||
text = PLAIN_URL.matcher(text).replaceAll("<$0>");
|
||||
|
||||
return text;
|
||||
}
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
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.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.SharedConstants;
|
||||
@@ -19,6 +20,11 @@ public class FabricLoaderHelper implements ModloaderEnvironment {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoaderType getLoaderType() {
|
||||
return LoaderType.FABRIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGameVersion() {
|
||||
return SharedConstants.VERSION_STRING;
|
||||
|
@@ -1,6 +1,7 @@
|
||||
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;
|
||||
@@ -23,6 +24,11 @@ public class ForgeLoaderHelper implements ModloaderEnvironment {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoaderType getLoaderType() {
|
||||
return LoaderType.FORGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGameVersion() {
|
||||
return SharedConstants.VERSION_STRING;
|
||||
|
@@ -1,6 +1,7 @@
|
||||
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;
|
||||
@@ -23,6 +24,11 @@ public class NeoForgeLoaderHelper implements ModloaderEnvironment {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoaderType getLoaderType() {
|
||||
return LoaderType.NEOFORGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGameVersion() {
|
||||
return SharedConstants.VERSION_STRING;
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Project
|
||||
version_major=2
|
||||
version_minor=0
|
||||
version_patch=1
|
||||
version_build=1
|
||||
version_patch=2
|
||||
version_build=0
|
||||
|
||||
#Mod
|
||||
mod_author=HypherionSA
|
||||
|
@@ -22,12 +22,12 @@ public class CraterPlayerEvent extends CraterEvent {
|
||||
|
||||
public PlayerLoggedIn(BridgedPlayer player, boolean isFromVanish) {
|
||||
super(player);
|
||||
this.isFromVanish = false;
|
||||
this.isFromVanish = isFromVanish;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Getter @Setter
|
||||
@Getter
|
||||
public static class PlayerLoggedOut extends CraterPlayerEvent {
|
||||
private final boolean isFromVanish;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class CraterPlayerEvent extends CraterEvent {
|
||||
|
||||
public PlayerLoggedOut(BridgedPlayer player, boolean isFromVanish) {
|
||||
super(player);
|
||||
this.isFromVanish = false;
|
||||
this.isFromVanish = isFromVanish;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,8 @@
|
||||
package com.hypherionmc.craterlib.core.platform;
|
||||
|
||||
public enum LoaderType {
|
||||
FABRIC,
|
||||
FORGE,
|
||||
NEOFORGE,
|
||||
PAPER
|
||||
}
|
@@ -12,8 +12,11 @@ public interface ModloaderEnvironment {
|
||||
|
||||
public final ModloaderEnvironment INSTANCE = InternalServiceUtil.load(ModloaderEnvironment.class);
|
||||
|
||||
@Deprecated(forRemoval = true, since = "2.0.2")
|
||||
boolean isFabric();
|
||||
|
||||
LoaderType getLoaderType();
|
||||
|
||||
String getGameVersion();
|
||||
|
||||
File getGameFolder();
|
||||
|
@@ -11,7 +11,6 @@ import net.minecraft.SharedConstants;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
|
||||
public class ChatUtils {
|
||||
|
||||
private static final GsonComponentSerializer adventureSerializer = GsonComponentSerializer.builder().options(
|
||||
@@ -52,7 +51,7 @@ public class ChatUtils {
|
||||
|
||||
public static String resolve(net.kyori.adventure.text.Component component, boolean formatted) {
|
||||
Component c = adventureToMojang(component);
|
||||
String returnVal = ChatFormatting.stripFormatting(c.getString());
|
||||
String returnVal = ChatFormatting.stripFormatting(DiscordMarkdownStripper.stripMarkdown(c.getString()));
|
||||
|
||||
if (formatted) {
|
||||
returnVal = DiscordSerializer.INSTANCE.serialize(safeCopy(c).copy());
|
||||
|
@@ -0,0 +1,35 @@
|
||||
package com.hypherionmc.craterlib.utils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class DiscordMarkdownStripper {
|
||||
|
||||
// Patterns for different markdown syntaxes
|
||||
private static final Pattern BOLD = Pattern.compile("\\*\\*(.*?)\\*\\*");
|
||||
private static final Pattern ITALIC_UNDERSCORE = Pattern.compile("_(.*?)_");
|
||||
private static final Pattern ITALIC_ASTERISK = Pattern.compile("\\*(.*?)\\*");
|
||||
private static final Pattern UNDERLINE = Pattern.compile("__(.*?)__");
|
||||
private static final Pattern STRIKETHROUGH = Pattern.compile("~~(.*?)~~");
|
||||
private static final Pattern CODE_BLOCK = Pattern.compile("```(.+?)```", Pattern.DOTALL);
|
||||
private static final Pattern INLINE_CODE = Pattern.compile("`([^`]*)`");
|
||||
private static final Pattern BLOCKQUOTE = Pattern.compile("^> (.*?$)", Pattern.MULTILINE);
|
||||
private static final Pattern MARKDOWN_LINK = Pattern.compile("\\[(.*?)\\]\\((.*?)\\)");
|
||||
private static final Pattern PLAIN_URL = Pattern.compile("\\b(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]");
|
||||
|
||||
public static String stripMarkdown(@NotNull String text) {
|
||||
text = BOLD.matcher(text).replaceAll("$1");
|
||||
text = ITALIC_UNDERSCORE.matcher(text).replaceAll("$1");
|
||||
text = ITALIC_ASTERISK.matcher(text).replaceAll("$1");
|
||||
text = UNDERLINE.matcher(text).replaceAll("$1");
|
||||
text = STRIKETHROUGH.matcher(text).replaceAll("$1");
|
||||
text = CODE_BLOCK.matcher(text).replaceAll("$1");
|
||||
text = INLINE_CODE.matcher(text).replaceAll("$1");
|
||||
text = BLOCKQUOTE.matcher(text).replaceAll("$1");
|
||||
text = MARKDOWN_LINK.matcher(text).replaceAll("$1");
|
||||
text = PLAIN_URL.matcher(text).replaceAll("<$0>");
|
||||
|
||||
return text;
|
||||
}
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
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.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.SharedConstants;
|
||||
@@ -19,6 +20,11 @@ public class FabricLoaderHelper implements ModloaderEnvironment {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoaderType getLoaderType() {
|
||||
return LoaderType.FABRIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGameVersion() {
|
||||
return SharedConstants.VERSION_STRING;
|
||||
|
@@ -1,6 +1,7 @@
|
||||
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;
|
||||
@@ -23,6 +24,11 @@ public class ForgeLoaderHelper implements ModloaderEnvironment {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoaderType getLoaderType() {
|
||||
return LoaderType.FORGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGameVersion() {
|
||||
return SharedConstants.VERSION_STRING;
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Project
|
||||
version_major=2
|
||||
version_minor=0
|
||||
version_patch=1
|
||||
version_build=1
|
||||
version_patch=2
|
||||
version_build=0
|
||||
|
||||
#Mod
|
||||
mod_author=HypherionSA
|
||||
|
@@ -22,12 +22,12 @@ public class CraterPlayerEvent extends CraterEvent {
|
||||
|
||||
public PlayerLoggedIn(BridgedPlayer player, boolean isFromVanish) {
|
||||
super(player);
|
||||
this.isFromVanish = false;
|
||||
this.isFromVanish = isFromVanish;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Getter @Setter
|
||||
@Getter
|
||||
public static class PlayerLoggedOut extends CraterPlayerEvent {
|
||||
private final boolean isFromVanish;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class CraterPlayerEvent extends CraterEvent {
|
||||
|
||||
public PlayerLoggedOut(BridgedPlayer player, boolean isFromVanish) {
|
||||
super(player);
|
||||
this.isFromVanish = false;
|
||||
this.isFromVanish = isFromVanish;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,8 @@
|
||||
package com.hypherionmc.craterlib.core.platform;
|
||||
|
||||
public enum LoaderType {
|
||||
FABRIC,
|
||||
FORGE,
|
||||
NEOFORGE,
|
||||
PAPER
|
||||
}
|
@@ -12,8 +12,11 @@ public interface ModloaderEnvironment {
|
||||
|
||||
public final ModloaderEnvironment INSTANCE = InternalServiceUtil.load(ModloaderEnvironment.class);
|
||||
|
||||
@Deprecated(forRemoval = true, since = "2.0.2")
|
||||
boolean isFabric();
|
||||
|
||||
LoaderType getLoaderType();
|
||||
|
||||
String getGameVersion();
|
||||
|
||||
File getGameFolder();
|
||||
|
@@ -14,12 +14,9 @@ import net.minecraft.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.data.registries.VanillaRegistries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ChatUtils {
|
||||
|
||||
private static final GsonComponentSerializer adventureSerializer = GsonComponentSerializer.builder().options(
|
||||
@@ -70,7 +67,7 @@ public class ChatUtils {
|
||||
|
||||
public static String resolve(net.kyori.adventure.text.Component component, boolean formatted) {
|
||||
Component c = adventureToMojang(component);
|
||||
String returnVal = ChatFormatting.stripFormatting(c.getString());
|
||||
String returnVal = ChatFormatting.stripFormatting(DiscordMarkdownStripper.stripMarkdown(c.getString()));
|
||||
|
||||
if (formatted) {
|
||||
returnVal = DiscordSerializer.INSTANCE.serialize(safeCopy(c).copy());
|
||||
|
@@ -0,0 +1,35 @@
|
||||
package com.hypherionmc.craterlib.utils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class DiscordMarkdownStripper {
|
||||
|
||||
// Patterns for different markdown syntaxes
|
||||
private static final Pattern BOLD = Pattern.compile("\\*\\*(.*?)\\*\\*");
|
||||
private static final Pattern ITALIC_UNDERSCORE = Pattern.compile("_(.*?)_");
|
||||
private static final Pattern ITALIC_ASTERISK = Pattern.compile("\\*(.*?)\\*");
|
||||
private static final Pattern UNDERLINE = Pattern.compile("__(.*?)__");
|
||||
private static final Pattern STRIKETHROUGH = Pattern.compile("~~(.*?)~~");
|
||||
private static final Pattern CODE_BLOCK = Pattern.compile("```(.+?)```", Pattern.DOTALL);
|
||||
private static final Pattern INLINE_CODE = Pattern.compile("`([^`]*)`");
|
||||
private static final Pattern BLOCKQUOTE = Pattern.compile("^> (.*?$)", Pattern.MULTILINE);
|
||||
private static final Pattern MARKDOWN_LINK = Pattern.compile("\\[(.*?)\\]\\((.*?)\\)");
|
||||
private static final Pattern PLAIN_URL = Pattern.compile("\\b(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]");
|
||||
|
||||
public static String stripMarkdown(@NotNull String text) {
|
||||
text = BOLD.matcher(text).replaceAll("$1");
|
||||
text = ITALIC_UNDERSCORE.matcher(text).replaceAll("$1");
|
||||
text = ITALIC_ASTERISK.matcher(text).replaceAll("$1");
|
||||
text = UNDERLINE.matcher(text).replaceAll("$1");
|
||||
text = STRIKETHROUGH.matcher(text).replaceAll("$1");
|
||||
text = CODE_BLOCK.matcher(text).replaceAll("$1");
|
||||
text = INLINE_CODE.matcher(text).replaceAll("$1");
|
||||
text = BLOCKQUOTE.matcher(text).replaceAll("$1");
|
||||
text = MARKDOWN_LINK.matcher(text).replaceAll("$1");
|
||||
text = PLAIN_URL.matcher(text).replaceAll("<$0>");
|
||||
|
||||
return text;
|
||||
}
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
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.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.SharedConstants;
|
||||
@@ -19,6 +20,11 @@ public class FabricLoaderHelper implements ModloaderEnvironment {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoaderType getLoaderType() {
|
||||
return LoaderType.FABRIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGameVersion() {
|
||||
return SharedConstants.VERSION_STRING;
|
||||
|
@@ -1,6 +1,7 @@
|
||||
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;
|
||||
@@ -23,6 +24,11 @@ public class ForgeLoaderHelper implements ModloaderEnvironment {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoaderType getLoaderType() {
|
||||
return LoaderType.FORGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGameVersion() {
|
||||
return SharedConstants.VERSION_STRING;
|
||||
|
@@ -1,6 +1,7 @@
|
||||
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;
|
||||
@@ -23,6 +24,11 @@ public class NeoForgeLoaderHelper implements ModloaderEnvironment {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoaderType getLoaderType() {
|
||||
return LoaderType.NEOFORGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGameVersion() {
|
||||
return SharedConstants.VERSION_STRING;
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Project
|
||||
version_major=2
|
||||
version_minor=0
|
||||
version_patch=1
|
||||
version_build=1
|
||||
version_patch=2
|
||||
version_build=0
|
||||
|
||||
#Mod
|
||||
mod_author=HypherionSA
|
||||
|
@@ -1 +1 @@
|
||||
abdb68ca08db07525a68e2cf1b3e26e972e6f0d6
|
||||
df50b0e82d36d510560d802628434055694d9a04
|
@@ -8,24 +8,21 @@
|
||||
import com.hypherionmc.craterlib.nojang.resources.ResourceIdentifier;
|
||||
import me.hypherionmc.mcdiscordformatter.discord.DiscordSerializer;
|
||||
import me.hypherionmc.mcdiscordformatter.minecraft.MinecraftSerializer;
|
||||
@@ -11,14 +9,10 @@
|
||||
@@ -11,11 +9,10 @@
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.Util;
|
||||
-import net.minecraft.client.Minecraft;
|
||||
-import net.minecraft.core.HolderLookup;
|
||||
-import net.minecraft.core.RegistryAccess;
|
||||
-import net.minecraft.data.registries.VanillaRegistries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
-
|
||||
-import java.util.function.Consumer;
|
||||
+import net.minecraft.network.chat.TextComponent;
|
||||
+import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
public class ChatUtils {
|
||||
|
||||
@@ -28,30 +22,20 @@
|
||||
@@ -25,30 +22,20 @@
|
||||
|
||||
public static Component adventureToMojang(net.kyori.adventure.text.Component inComponent) {
|
||||
final String serialised = adventureSerializer.serialize(inComponent);
|
||||
@@ -59,7 +56,7 @@
|
||||
}
|
||||
|
||||
public static String strip(String inString, String... toStrip) {
|
||||
@@ -80,7 +64,7 @@
|
||||
@@ -77,7 +64,7 @@
|
||||
}
|
||||
|
||||
public static net.kyori.adventure.text.Component resolve(String component, boolean formatted) {
|
||||
@@ -68,7 +65,7 @@
|
||||
if (formatted) {
|
||||
returnVal = MinecraftSerializer.INSTANCE.serialize(component);
|
||||
}
|
||||
@@ -108,7 +92,7 @@
|
||||
@@ -105,7 +92,7 @@
|
||||
if (identifier == null)
|
||||
return net.kyori.adventure.text.Component.text("Unknown");
|
||||
|
||||
|
@@ -1,9 +1,10 @@
|
||||
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/common/NeoForgeLoaderHelper.java
|
||||
+++ /dev/null
|
||||
@@ -1,73 +1,0 @@
|
||||
@@ -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;
|
||||
@@ -27,6 +28,11 @@
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- public LoaderType getLoaderType() {
|
||||
- return LoaderType.NEOFORGE;
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- public String getGameVersion() {
|
||||
- return SharedConstants.VERSION_STRING;
|
||||
- }
|
||||
|
@@ -8,23 +8,20 @@
|
||||
import com.hypherionmc.craterlib.nojang.resources.ResourceIdentifier;
|
||||
import me.hypherionmc.mcdiscordformatter.discord.DiscordSerializer;
|
||||
import me.hypherionmc.mcdiscordformatter.minecraft.MinecraftSerializer;
|
||||
@@ -11,15 +9,9 @@
|
||||
@@ -11,12 +9,8 @@
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.Util;
|
||||
-import net.minecraft.client.Minecraft;
|
||||
-import net.minecraft.core.HolderLookup;
|
||||
-import net.minecraft.core.RegistryAccess;
|
||||
-import net.minecraft.data.registries.VanillaRegistries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
|
||||
-import java.util.function.Consumer;
|
||||
-
|
||||
public class ChatUtils {
|
||||
|
||||
private static final GsonComponentSerializer adventureSerializer = GsonComponentSerializer.builder().options(
|
||||
@@ -28,22 +20,12 @@
|
||||
@@ -25,22 +19,12 @@
|
||||
|
||||
public static Component adventureToMojang(net.kyori.adventure.text.Component inComponent) {
|
||||
final String serialised = adventureSerializer.serialize(inComponent);
|
||||
|
@@ -1,9 +1,10 @@
|
||||
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/common/NeoForgeLoaderHelper.java
|
||||
+++ /dev/null
|
||||
@@ -1,73 +1,0 @@
|
||||
@@ -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;
|
||||
@@ -27,6 +28,11 @@
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- public LoaderType getLoaderType() {
|
||||
- return LoaderType.NEOFORGE;
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- public String getGameVersion() {
|
||||
- return SharedConstants.VERSION_STRING;
|
||||
- }
|
||||
|
@@ -8,23 +8,20 @@
|
||||
import com.hypherionmc.craterlib.nojang.resources.ResourceIdentifier;
|
||||
import me.hypherionmc.mcdiscordformatter.discord.DiscordSerializer;
|
||||
import me.hypherionmc.mcdiscordformatter.minecraft.MinecraftSerializer;
|
||||
@@ -11,15 +9,9 @@
|
||||
@@ -11,12 +9,8 @@
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.Util;
|
||||
-import net.minecraft.client.Minecraft;
|
||||
-import net.minecraft.core.HolderLookup;
|
||||
-import net.minecraft.core.RegistryAccess;
|
||||
-import net.minecraft.data.registries.VanillaRegistries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
|
||||
-import java.util.function.Consumer;
|
||||
-
|
||||
public class ChatUtils {
|
||||
|
||||
private static final GsonComponentSerializer adventureSerializer = GsonComponentSerializer.builder().options(
|
||||
@@ -28,22 +20,12 @@
|
||||
@@ -25,22 +19,12 @@
|
||||
|
||||
public static Component adventureToMojang(net.kyori.adventure.text.Component inComponent) {
|
||||
final String serialised = adventureSerializer.serialize(inComponent);
|
||||
|
@@ -1,9 +1,10 @@
|
||||
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/common/NeoForgeLoaderHelper.java
|
||||
+++ /dev/null
|
||||
@@ -1,73 +1,0 @@
|
||||
@@ -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;
|
||||
@@ -27,6 +28,11 @@
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- public LoaderType getLoaderType() {
|
||||
- return LoaderType.NEOFORGE;
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- public String getGameVersion() {
|
||||
- return SharedConstants.VERSION_STRING;
|
||||
- }
|
||||
|
@@ -8,23 +8,20 @@
|
||||
import com.hypherionmc.craterlib.nojang.resources.ResourceIdentifier;
|
||||
import me.hypherionmc.mcdiscordformatter.discord.DiscordSerializer;
|
||||
import me.hypherionmc.mcdiscordformatter.minecraft.MinecraftSerializer;
|
||||
@@ -11,15 +9,9 @@
|
||||
@@ -11,12 +9,8 @@
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.Util;
|
||||
-import net.minecraft.client.Minecraft;
|
||||
-import net.minecraft.core.HolderLookup;
|
||||
-import net.minecraft.core.RegistryAccess;
|
||||
-import net.minecraft.data.registries.VanillaRegistries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
|
||||
-import java.util.function.Consumer;
|
||||
-
|
||||
public class ChatUtils {
|
||||
|
||||
private static final GsonComponentSerializer adventureSerializer = GsonComponentSerializer.builder().options(
|
||||
@@ -28,22 +20,12 @@
|
||||
@@ -25,22 +19,12 @@
|
||||
|
||||
public static Component adventureToMojang(net.kyori.adventure.text.Component inComponent) {
|
||||
final String serialised = adventureSerializer.serialize(inComponent);
|
||||
|
@@ -1,9 +1,10 @@
|
||||
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/common/NeoForgeLoaderHelper.java
|
||||
+++ /dev/null
|
||||
@@ -1,73 +1,0 @@
|
||||
@@ -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;
|
||||
@@ -27,6 +28,11 @@
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- public LoaderType getLoaderType() {
|
||||
- return LoaderType.NEOFORGE;
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- public String getGameVersion() {
|
||||
- return SharedConstants.VERSION_STRING;
|
||||
- }
|
||||
|
@@ -8,23 +8,20 @@
|
||||
import com.hypherionmc.craterlib.nojang.resources.ResourceIdentifier;
|
||||
import me.hypherionmc.mcdiscordformatter.discord.DiscordSerializer;
|
||||
import me.hypherionmc.mcdiscordformatter.minecraft.MinecraftSerializer;
|
||||
@@ -11,15 +9,9 @@
|
||||
@@ -11,12 +9,8 @@
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.Util;
|
||||
-import net.minecraft.client.Minecraft;
|
||||
-import net.minecraft.core.HolderLookup;
|
||||
-import net.minecraft.core.RegistryAccess;
|
||||
-import net.minecraft.data.registries.VanillaRegistries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
|
||||
-import java.util.function.Consumer;
|
||||
-
|
||||
public class ChatUtils {
|
||||
|
||||
private static final GsonComponentSerializer adventureSerializer = GsonComponentSerializer.builder().options(
|
||||
@@ -28,22 +20,12 @@
|
||||
@@ -25,22 +19,12 @@
|
||||
|
||||
public static Component adventureToMojang(net.kyori.adventure.text.Component inComponent) {
|
||||
final String serialised = adventureSerializer.serialize(inComponent);
|
||||
|
@@ -8,23 +8,20 @@
|
||||
import com.hypherionmc.craterlib.nojang.resources.ResourceIdentifier;
|
||||
import me.hypherionmc.mcdiscordformatter.discord.DiscordSerializer;
|
||||
import me.hypherionmc.mcdiscordformatter.minecraft.MinecraftSerializer;
|
||||
@@ -11,15 +9,9 @@
|
||||
@@ -11,12 +9,8 @@
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.Util;
|
||||
-import net.minecraft.client.Minecraft;
|
||||
-import net.minecraft.core.HolderLookup;
|
||||
-import net.minecraft.core.RegistryAccess;
|
||||
-import net.minecraft.data.registries.VanillaRegistries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
|
||||
-import java.util.function.Consumer;
|
||||
-
|
||||
public class ChatUtils {
|
||||
|
||||
private static final GsonComponentSerializer adventureSerializer = GsonComponentSerializer.builder().options(
|
||||
@@ -28,22 +20,12 @@
|
||||
@@ -25,22 +19,12 @@
|
||||
|
||||
public static Component adventureToMojang(net.kyori.adventure.text.Component inComponent) {
|
||||
final String serialised = adventureSerializer.serialize(inComponent);
|
||||
|
@@ -1,9 +1,10 @@
|
||||
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/common/NeoForgeLoaderHelper.java
|
||||
+++ /dev/null
|
||||
@@ -1,73 +1,0 @@
|
||||
@@ -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;
|
||||
@@ -27,6 +28,11 @@
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- public LoaderType getLoaderType() {
|
||||
- return LoaderType.NEOFORGE;
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- public String getGameVersion() {
|
||||
- return SharedConstants.VERSION_STRING;
|
||||
- }
|
||||
|
Reference in New Issue
Block a user