Skip to content

Commit

Permalink
Adds Skript supports.
Browse files Browse the repository at this point in the history
  • Loading branch information
toxicity188 committed Oct 21, 2024
1 parent 7a78f5a commit a22fc36
Show file tree
Hide file tree
Showing 61 changed files with 400 additions and 217 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

![healthbar](https://github.com/toxicity188/BetterHealthBar3/assets/114675706/8af7d97c-3277-42f7-bccd-d5e124dfa5df)

**NOTICE: If you want to use BetterHealthBar with shaderspack, set use-core-shaders to false in config.yml**

Welcome to BetterHealthBar!

[![GitHub Release](https://img.shields.io/github/v/release/toxicity188/BetterHealthBar3?display_name=release&style=for-the-badge&logo=kotlin)](https://github.com/toxicity188/BetterHealthBar3/releases/latest)
Expand All @@ -22,9 +24,9 @@ This plugin implements beautiful health bar!
![ezgif-4-6688863fff](https://github.com/toxicity188/BetterHealthBar3/assets/114675706/8484a92e-d0c2-4fd5-a766-5c5cb9fe697c)
This plugin supports sight-trace system.

### Custom core shader
### Custom core shaders
![2024_05_03_10_05_19_637-min](https://github.com/toxicity188/BetterHealthBar3/assets/114675706/7a0efa03-a6e7-42fd-b38e-a92d69503ad3)
This plugin has it's own core shader, fixes z-fighting issue!
This plugin has it's own core shaders, fixes z-fighting issue!

### Stack system
![녹화_2024_05_05_10_11_17_395-min](https://github.com/toxicity188/BetterHealthBar3/assets/114675706/d0903a79-e55d-4634-babb-063af2ef0c7c)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import java.util.UUID;

@FunctionalInterface
public interface BedrockAdapter {
BedrockAdapter NONE = u -> false;
boolean isBedrockPlayer(@NotNull UUID uuid);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package kr.toxicity.healthbar.api.condition;

import kr.toxicity.healthbar.api.healthbar.HealthBarData;
import kr.toxicity.healthbar.api.event.HealthBarCreateEvent;
import org.jetbrains.annotations.NotNull;

import java.util.function.Function;

public interface HealthBarCondition extends Function<HealthBarData, Boolean> {
public interface HealthBarCondition extends Function<HealthBarCreateEvent, Boolean> {
HealthBarCondition TRUE = p -> true;

default @NotNull HealthBarCondition not() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.jetbrains.annotations.NotNull;

@FunctionalInterface
public interface HealthBarConfiguration {
@NotNull
String path();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package kr.toxicity.healthbar.api.event;

import kr.toxicity.healthbar.api.entity.HealthBarEntity;
import kr.toxicity.healthbar.api.healthbar.HealthBar;
import kr.toxicity.healthbar.api.player.HealthBarPlayer;
import kr.toxicity.healthbar.api.trigger.HealthBarTrigger;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;

@Getter
@Setter
public class HealthBarCreateEvent extends Event implements Cancellable {

private static final HandlerList HANDLER_LIST = new HandlerList();

private final @NotNull HealthBar healthBar;
private final @NotNull HealthBarTrigger trigger;
private final @NotNull HealthBarPlayer player;
private final @NotNull HealthBarEntity entity;

private boolean cancelled;

public HealthBarCreateEvent(@NotNull HealthBar healthBar, @NotNull HealthBarTrigger trigger, @NotNull HealthBarPlayer player, @NotNull HealthBarEntity entity) {
super(true);
this.healthBar = healthBar;
this.trigger = trigger;
this.player = player;
this.entity = entity;
}

@Override
public @NotNull HandlerList getHandlers() {
return HANDLER_LIST;
}

public static @NotNull HandlerList getHandlerList() {
return HANDLER_LIST;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import kr.toxicity.healthbar.api.condition.HealthBarCondition;
import kr.toxicity.healthbar.api.configuration.HealthBarConfiguration;
import kr.toxicity.healthbar.api.event.HealthBarCreateEvent;
import kr.toxicity.healthbar.api.layout.LayoutGroup;
import kr.toxicity.healthbar.api.renderer.HealthBarRenderer;
import kr.toxicity.healthbar.api.trigger.HealthBarTriggerType;
Expand Down Expand Up @@ -35,7 +36,7 @@ public interface HealthBar extends HealthBarConfiguration {
boolean isDefault();

@NotNull
HealthBarRenderer createRenderer(@NotNull HealthBarData pair);
HealthBarRenderer createRenderer(@NotNull HealthBarCreateEvent pair);
@NotNull
HealthBarCondition condition();
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package kr.toxicity.healthbar.api.healthbar;

import kr.toxicity.healthbar.api.entity.HealthBarEntity;
import kr.toxicity.healthbar.api.event.HealthBarCreateEvent;
import kr.toxicity.healthbar.api.player.HealthBarPlayer;
import org.jetbrains.annotations.NotNull;

Expand All @@ -25,5 +26,5 @@ default void remove() {
updaters.clear();
}

void addHealthBar(@NotNull HealthBarData data);
void addHealthBar(@NotNull HealthBarCreateEvent data);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package kr.toxicity.healthbar.api.layout;

import kr.toxicity.healthbar.api.healthbar.HealthBarData;
import kr.toxicity.healthbar.api.event.HealthBarCreateEvent;
import kr.toxicity.healthbar.api.image.HealthBarImage;
import kr.toxicity.healthbar.api.listener.HealthBarListener;
import kr.toxicity.healthbar.api.renderer.ImageRenderer;
Expand All @@ -14,5 +14,5 @@ public interface ImageLayout extends Layout {
int duration();

@NotNull
ImageRenderer createImageRenderer(@NotNull HealthBarData entity);
ImageRenderer createImageRenderer(@NotNull HealthBarCreateEvent entity);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package kr.toxicity.healthbar.api.layout;

import kr.toxicity.healthbar.api.healthbar.HealthBarData;
import kr.toxicity.healthbar.api.event.HealthBarCreateEvent;
import kr.toxicity.healthbar.api.renderer.TextRenderer;
import kr.toxicity.healthbar.api.text.TextAlign;
import net.kyori.adventure.text.Component;
Expand All @@ -19,8 +19,8 @@ public interface TextLayout extends Layout {
TextAlign align();

@NotNull
Function<HealthBarData, Component> pattern();
Function<HealthBarCreateEvent, Component> pattern();

@NotNull
TextRenderer createRenderer(@NotNull HealthBarData pair);
TextRenderer createRenderer(@NotNull HealthBarCreateEvent pair);
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package kr.toxicity.healthbar.api.listener;

import kr.toxicity.healthbar.api.healthbar.HealthBarData;
import kr.toxicity.healthbar.api.event.HealthBarCreateEvent;
import org.jetbrains.annotations.NotNull;

public interface HealthBarListener {
HealthBarListener ZERO = e -> 0;
HealthBarListener INVALID = e -> -1;

double value(@NotNull HealthBarData entity);
double value(@NotNull HealthBarCreateEvent entity);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

@FunctionalInterface
public interface ModelEngineAdapter {
ModelEngineAdapter NONE = e -> null;
@Nullable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package kr.toxicity.healthbar.api.placeholder;

import kr.toxicity.healthbar.api.healthbar.HealthBarData;
import kr.toxicity.healthbar.api.event.HealthBarCreateEvent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public interface HealthBarPlaceholder<T> {
@NotNull
Class<T> type();
@NotNull
T value(@NotNull HealthBarData player);
T value(@NotNull HealthBarCreateEvent player);

default @Nullable T cast(@NotNull Object object) {
return type().isAssignableFrom(object.getClass()) ? type().cast(object) : null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package kr.toxicity.healthbar.api.placeholder;

import kr.toxicity.healthbar.api.healthbar.HealthBarData;
import kr.toxicity.healthbar.api.event.HealthBarCreateEvent;
import org.jetbrains.annotations.NotNull;

import java.util.List;
import java.util.function.Function;

public interface PlaceholderBuilder<T> {
HealthBarPlaceholder<T> build(@NotNull List<String> strings);
@NotNull HealthBarPlaceholder<T> build(@NotNull List<String> strings);
int requiredArgsCount();

static <T> PlaceholderBuilder<T> of(int length, @NotNull Class<T> clazz, @NotNull Function<List<String>, Function<HealthBarData, T>> tFunction) {
static <T> PlaceholderBuilder<T> of(int length, @NotNull Class<T> clazz, @NotNull Function<List<String>, Function<HealthBarCreateEvent, T>> tFunction) {
return new PlaceholderBuilder<>() {
@Override
public HealthBarPlaceholder<T> build(@NotNull List<String> strings) {
public @NotNull HealthBarPlaceholder<T> build(@NotNull List<String> strings) {
var get = tFunction.apply(strings);
return new HealthBarPlaceholder<T>() {
return new HealthBarPlaceholder<>() {
@NotNull
@Override
public Class<T> type() {
Expand All @@ -24,7 +24,7 @@ public Class<T> type() {

@NotNull
@Override
public T value(@NotNull HealthBarData player) {
public T value(@NotNull HealthBarCreateEvent player) {
return get.apply(player);
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package kr.toxicity.healthbar.api.placeholder;

import kr.toxicity.healthbar.api.healthbar.HealthBarData;
import kr.toxicity.healthbar.api.event.HealthBarCreateEvent;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextReplacementConfig;
import net.kyori.adventure.text.minimessage.MiniMessage;
Expand Down Expand Up @@ -68,19 +68,19 @@ public PlaceholderContainer(@NotNull Class<T> clazz, String name, @NotNull Funct

private final Map<String, PlaceholderBuilder<T>> map = new HashMap<>();

public void addPlaceholder(@NotNull String name, @NotNull Function<HealthBarData, T> function) {
public void addPlaceholder(@NotNull String name, @NotNull Function<HealthBarCreateEvent, T> function) {
map.put(name, new PlaceholderBuilder<>() {
@Override
public int requiredArgsCount() {
return 0;
}

@Override
public HealthBarPlaceholder<T> build(@NotNull List<String> strings) {
public @NotNull HealthBarPlaceholder<T> build(@NotNull List<String> strings) {
return new HealthBarPlaceholder<>() {
@NotNull
@Override
public T value(@NotNull HealthBarData player) {
public T value(@NotNull HealthBarCreateEvent player) {
return function.apply(player);
}

Expand Down Expand Up @@ -129,7 +129,7 @@ public Class<String> type() {

@NotNull
@Override
public String value(@NotNull HealthBarData player) {
public String value(@NotNull HealthBarCreateEvent player) {
return stringMapper.apply(apply.value(player));
}
};
Expand All @@ -147,7 +147,7 @@ public Class<Object> type() {

@NotNull
@Override
public Object value(@NotNull HealthBarData player) {
public Object value(@NotNull HealthBarCreateEvent player) {
return v;
}
};
Expand Down Expand Up @@ -179,15 +179,15 @@ public Class<Object> type() {

@NotNull
@Override
public Object value(@NotNull HealthBarData player) {
public Object value(@NotNull HealthBarCreateEvent player) {
return cast.parser.apply(string.value(player));
}
};
} else return get.value(list);
}

public static @NotNull Function<HealthBarData, Component> toString(@NotNull String pattern) {
var array = new ArrayList<Function<HealthBarData, Component>>();
public static @NotNull Function<HealthBarCreateEvent, Component> toString(@NotNull String pattern) {
var array = new ArrayList<Function<HealthBarCreateEvent, Component>>();
var sb = new StringBuilder();
var skip = false;
for (char c : pattern.toCharArray()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

public interface WrappedScheduler {
@NotNull WrappedTask task(@NotNull Runnable runnable);
@NotNull WrappedTask asyncTask(@NotNull Runnable runnable);
@NotNull WrappedTask taskLater(long delay, @NotNull Runnable runnable);
@NotNull WrappedTask task(@NotNull World world, int x, int z, @NotNull Runnable runnable);
@NotNull WrappedTask asyncTaskTimer(long delay, long period, @NotNull Runnable runnable);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kr.toxicity.healthbar.api.scheduler;

@FunctionalInterface
public interface WrappedTask {
void cancel();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.jetbrains.annotations.NotNull;

@FunctionalInterface
public interface HealthBarTrigger {
@NotNull HealthBarTriggerType type();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import kr.toxicity.healthbar.api.bedrock.BedrockAdapter
import org.geysermc.floodgate.api.FloodgateApi
import java.util.*

class FloodgateAdapter: BedrockAdapter {
class FloodgateAdapter : BedrockAdapter {
override fun isBedrockPlayer(uuid: UUID): Boolean {
return FloodgateApi.getInstance().isFloodgatePlayer(uuid)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import kr.toxicity.healthbar.api.bedrock.BedrockAdapter
import org.geysermc.api.Geyser
import java.util.*

class GeyserAdapter: BedrockAdapter {
class GeyserAdapter : BedrockAdapter {
override fun isBedrockPlayer(uuid: UUID): Boolean {
return Geyser.api().isBedrockPlayer(uuid)
}
Expand Down
Loading

0 comments on commit a22fc36

Please sign in to comment.