-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new API features and creations of your own Detection
- Loading branch information
1 parent
49be95d
commit b4237c6
Showing
31 changed files
with
469 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
HypeGradients-API/src/main/java/me/doublenico/hypegradients/api/MessageDetection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package me.doublenico.hypegradients.api; | ||
|
||
import com.comphenix.protocol.wrappers.WrappedChatComponent; | ||
import dev.perryplaysmc.dynamicconfigurations.utils.DynamicConfigurationDirectory; | ||
import me.doublenico.hypegradients.api.detection.ChatDetectionConfiguration; | ||
import org.bukkit.entity.Player; | ||
|
||
public interface MessageDetection { | ||
|
||
String getName(); | ||
|
||
String getJSON(Player player, String jsonMessage); | ||
|
||
String getPlainMessage(Player player, String plainMessage); | ||
|
||
WrappedChatComponent getChatComponent(Player player, WrappedChatComponent component); | ||
|
||
boolean isEnabled(Player player, String plainMessage, String jsonMessage, WrappedChatComponent component); | ||
|
||
ChatDetectionConfiguration chatDetectionConfiguration(Player player, DynamicConfigurationDirectory directory); | ||
|
||
|
||
} |
39 changes: 39 additions & 0 deletions
39
HypeGradients-API/src/main/java/me/doublenico/hypegradients/api/MessageDetectionManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package me.doublenico.hypegradients.api; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class MessageDetectionManager { | ||
private final List<MessageDetection> messageDetectionList = new ArrayList<>(); | ||
|
||
private MessageDetectionManager() { | ||
} | ||
|
||
public static MessageDetectionManager getInstance() { | ||
return MessageDetectionManager.InstanceHolder.instance; | ||
} | ||
|
||
public List<MessageDetection> getMessageDetectionList() { | ||
return messageDetectionList; | ||
} | ||
|
||
public void addMessageDetection(MessageDetection messageDetection) { | ||
messageDetectionList.add(messageDetection); | ||
} | ||
|
||
public void removeMessageDetection(MessageDetection messageDetection) { | ||
messageDetectionList.remove(messageDetection); | ||
} | ||
|
||
public MessageDetection getMessageDetection(String name) { | ||
for (MessageDetection messageDetection : messageDetectionList) { | ||
if (messageDetection.getName().equals(name)) | ||
return messageDetection; | ||
} | ||
return null; | ||
} | ||
|
||
private static final class InstanceHolder { | ||
private static final MessageDetectionManager instance = new MessageDetectionManager(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...adients-API/src/main/java/me/doublenico/hypegradients/api/animations/AnimationHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package me.doublenico.hypegradients.api.animations; | ||
|
||
public record AnimationHolder(AnimationCache animationCache) { | ||
|
||
private static int currentFrame = 0; | ||
|
||
|
||
public String getNextFrame(String name) { | ||
Animation animation = animationCache.animationHandler().getAnimation(name); | ||
if (animation != null) { | ||
if (currentFrame == animation.frames().size() - 1) currentFrame = 0; | ||
else currentFrame++; | ||
return animation.frames().get(currentFrame); | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.