Skip to content

Commit

Permalink
Refactored the code to be more clear (#81)
Browse files Browse the repository at this point in the history
## Description
Refactored the Markdown code to be more clear

## Changes
- **Change 1**: Refactored the Markdown outside of the Utils classes and
put all Syntaxes into their own package.

## Type of Change
- [ ] Bug fix
- [x] New feature
- [ ] Documentation update

## Checklist
- [x] My code follows the style guidelines of this project.
[Contributing](https://github.com/MeAlam1/BlueLib/blob/1.21/CONTRIBUTING.md)
- [x] I have performed a self-review of my own code.
- [x] I have commented my code following the guidelines.
[Contributing](https://github.com/MeAlam1/BlueLib/blob/1.21/CONTRIBUTING.md)
- [x] My changes generate no new warnings.

## Related Issues
#61
  • Loading branch information
MeAlam1 authored Nov 27, 2024
1 parent 6550eb6 commit 1045160
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) BlueLib. Licensed under the MIT License.

package software.bluelib.utils.markdown;
package software.bluelib.markdown;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Copyright (c) BlueLib. Licensed under the MIT License.

package software.bluelib.utils.markdown;
package software.bluelib.markdown;

import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import software.bluelib.markdown.syntax.*;
import software.bluelib.utils.logging.BaseLogLevel;
import software.bluelib.utils.logging.BaseLogger;

Expand Down Expand Up @@ -198,6 +199,19 @@ public EnableMarkdownFor underline() {
BaseLogger.log(BaseLogLevel.INFO, "Enabled underline markdown", true);
return this;
}

/**
* A {@code public} method that enables hyperlink Markdown formatting.
*
* @return The {@link EnableMarkdownFor} instance to allow method chaining.
* @author MeAlam
* @since 1.4.0
*/
public EnableMarkdownFor hyperlink() {
Hyperlink.isHyperlinkEnabled = true;
BaseLogger.log(BaseLogLevel.INFO, "Enabled hyperlink markdown", true);
return this;
}
}

/**
Expand Down Expand Up @@ -263,5 +277,18 @@ public DisableMarkdownFor underline() {
BaseLogger.log(BaseLogLevel.INFO, "Disabled underline markdown", true);
return this;
}

/**
* A {@code public} method that disables hyperlink Markdown formatting.
*
* @return The {@link DisableMarkdownFor} instance to allow method chaining.
* @author MeAlam
* @since 1.4.0
*/
public DisableMarkdownFor hyperlink() {
Hyperlink.isHyperlinkEnabled = false;
BaseLogger.log(BaseLogLevel.INFO, "Disabled hyperlink markdown", true);
return this;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright (c) BlueLib. Licensed under the MIT License.

package software.bluelib.utils.markdown;
package software.bluelib.markdown.syntax;

import software.bluelib.markdown.MarkdownFeature;
import software.bluelib.utils.logging.BaseLogLevel;
import software.bluelib.utils.logging.BaseLogger;

Expand Down Expand Up @@ -39,7 +40,7 @@ public class Bold extends MarkdownFeature {
*
* @since 1.1.0
*/
protected static Boolean isBoldEnabled = true;
public static Boolean isBoldEnabled = true;

/**
* A {@code public} constructor that initializes the prefix and suffix for the bold formatting feature.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Copyright (c) BlueLib. Licensed under the MIT License.

package software.bluelib.utils.markdown;
package software.bluelib.markdown.syntax;

import net.minecraft.network.chat.*;
import software.bluelib.markdown.MarkdownFeature;
import software.bluelib.utils.logging.BaseLogLevel;
import software.bluelib.utils.logging.BaseLogger;
import software.bluelib.utils.math.MiscUtils;
Expand Down Expand Up @@ -41,7 +42,7 @@ public class Hyperlink extends MarkdownFeature {
*
* @since 1.4.0
*/
protected static Boolean isHyperlinkEnabled = true;
public static Boolean isHyperlinkEnabled = true;

/**
* A {@code public} constructor that initializes the prefix and suffix for the Hyperlink formatting feature.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright (c) BlueLib. Licensed under the MIT License.

package software.bluelib.utils.markdown;
package software.bluelib.markdown.syntax;

import software.bluelib.markdown.MarkdownFeature;
import software.bluelib.utils.logging.BaseLogLevel;
import software.bluelib.utils.logging.BaseLogger;

Expand Down Expand Up @@ -40,7 +41,7 @@ public class Italic extends MarkdownFeature {
*
* @since 1.1.0
*/
protected static Boolean isItalicEnabled = true;
public static Boolean isItalicEnabled = true;

/**
* A {@code public} constructor that initializes the prefix and suffix for the italic formatting feature.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright (c) BlueLib. Licensed under the MIT License.

package software.bluelib.utils.markdown;
package software.bluelib.markdown.syntax;

import software.bluelib.markdown.MarkdownFeature;
import software.bluelib.utils.logging.BaseLogLevel;
import software.bluelib.utils.logging.BaseLogger;

Expand Down Expand Up @@ -40,7 +41,7 @@ public class Strikethrough extends MarkdownFeature {
*
* @since 1.1.0
*/
protected static Boolean isStrikethroughEnabled = true;
public static Boolean isStrikethroughEnabled = true;

/**
* A {@code public} constructor that initializes the prefix and suffix for the strikethrough formatting feature.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright (c) BlueLib. Licensed under the MIT License.

package software.bluelib.utils.markdown;
package software.bluelib.markdown.syntax;

import software.bluelib.markdown.MarkdownFeature;
import software.bluelib.utils.logging.BaseLogLevel;
import software.bluelib.utils.logging.BaseLogger;

Expand Down Expand Up @@ -40,7 +41,7 @@ public class Underline extends MarkdownFeature {
*
* @since 1.1.0
*/
protected static Boolean isUnderlineEnabled = true;
public static Boolean isUnderlineEnabled = true;

/**
* A {@code public} constructor that initializes the prefix and suffix for the underline formatting feature.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import net.minecraft.network.chat.OutgoingChatMessage;
import net.minecraft.network.chat.PlayerChatMessage;
import net.minecraft.server.level.ServerPlayer;
import software.bluelib.utils.markdown.MarkdownParser;
import software.bluelib.markdown.MarkdownParser;

/**
* A {@code public class} responsible for handling server chat events and formatting chat messages using Markdown.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.event.ServerChatEvent;
import software.bluelib.utils.markdown.MarkdownParser;
import software.bluelib.markdown.MarkdownParser;

/**
* A {@code public class} responsible for handling server chat events and formatting chat messages using Markdown.
Expand Down

0 comments on commit 1045160

Please sign in to comment.