-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
109eaa1
commit 6e4cd72
Showing
20 changed files
with
287 additions
and
147 deletions.
There are no files selected for viewing
3 changes: 0 additions & 3 deletions
3
api/src/main/java/kr/toxicity/healthbar/api/healthbar/HealthBarUpdater.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
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
15 changes: 8 additions & 7 deletions
15
api/src/main/java/kr/toxicity/healthbar/api/renderer/HealthBarRenderer.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 |
---|---|---|
@@ -1,15 +1,16 @@ | ||
package kr.toxicity.healthbar.api.renderer; | ||
|
||
import kr.toxicity.healthbar.api.component.WidthComponent; | ||
import org.bukkit.Location; | ||
import kr.toxicity.healthbar.api.nms.VirtualTextDisplay; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Unmodifiable; | ||
|
||
import java.util.List; | ||
|
||
public interface HealthBarRenderer extends Renderer { | ||
@NotNull | ||
RenderResult render(); | ||
|
||
@Unmodifiable | ||
List<VirtualTextDisplay> displays(); | ||
void updateTick(); | ||
|
||
record RenderResult(@NotNull WidthComponent component, @NotNull Location location) { | ||
} | ||
boolean work(); | ||
void stop(); | ||
} |
7 changes: 1 addition & 6 deletions
7
api/src/main/java/kr/toxicity/healthbar/api/renderer/ImageRenderer.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 |
---|---|---|
@@ -1,10 +1,5 @@ | ||
package kr.toxicity.healthbar.api.renderer; | ||
|
||
import kr.toxicity.healthbar.api.component.PixelComponent; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public interface ImageRenderer extends Renderer { | ||
@NotNull | ||
PixelComponent render(int groupCount); | ||
public interface ImageRenderer extends PixelRenderer { | ||
boolean isBackground(); | ||
} |
10 changes: 10 additions & 0 deletions
10
api/src/main/java/kr/toxicity/healthbar/api/renderer/PixelRenderer.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,10 @@ | ||
package kr.toxicity.healthbar.api.renderer; | ||
|
||
import kr.toxicity.healthbar.api.component.PixelComponent; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public interface PixelRenderer extends Renderer { | ||
@NotNull | ||
PixelComponent render(int groupCount); | ||
int layer(); | ||
} |
7 changes: 1 addition & 6 deletions
7
api/src/main/java/kr/toxicity/healthbar/api/renderer/TextRenderer.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 |
---|---|---|
@@ -1,9 +1,4 @@ | ||
package kr.toxicity.healthbar.api.renderer; | ||
|
||
import kr.toxicity.healthbar.api.component.PixelComponent; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public interface TextRenderer extends Renderer { | ||
@NotNull | ||
PixelComponent render(int groupCount); | ||
public interface TextRenderer extends PixelRenderer { | ||
} |
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
30 changes: 2 additions & 28 deletions
30
dist/src/main/kotlin/kr/toxicity/healthbar/healthbar/HealthBarUpdaterImpl.kt
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 |
---|---|---|
@@ -1,50 +1,24 @@ | ||
package kr.toxicity.healthbar.healthbar | ||
|
||
import kr.toxicity.healthbar.api.healthbar.HealthBarData | ||
import kr.toxicity.healthbar.api.healthbar.HealthBarUpdater | ||
import kr.toxicity.healthbar.api.healthbar.HealthBarUpdaterGroup | ||
import kr.toxicity.healthbar.api.nms.VirtualTextDisplay | ||
import kr.toxicity.healthbar.api.renderer.HealthBarRenderer | ||
import kr.toxicity.healthbar.util.PLUGIN | ||
import org.bukkit.util.Vector | ||
|
||
class HealthBarUpdaterImpl( | ||
private val parent: HealthBarUpdaterGroupImpl, | ||
data: HealthBarData, | ||
private val renderer: HealthBarRenderer | ||
): HealthBarUpdater { | ||
private val display = renderer().render().run { | ||
val player = data.player.player() | ||
PLUGIN.nms().createTextDisplay(player, location, component.component.build()).apply { | ||
val scale = data.healthBar.scale() | ||
transformation( | ||
Vector(0.0, -(1 - scale.y) * 8192 / 40 ,0.0), | ||
scale | ||
) | ||
} | ||
} | ||
|
||
override fun parent(): HealthBarUpdaterGroup = parent | ||
override fun display(): VirtualTextDisplay = display | ||
override fun renderer(): HealthBarRenderer = renderer | ||
|
||
override fun updateTick() { | ||
renderer.updateTick() | ||
} | ||
|
||
override fun remove() { | ||
display.remove() | ||
renderer.stop() | ||
} | ||
|
||
override fun update(): Boolean { | ||
if (!renderer().hasNext()) { | ||
display.remove() | ||
return false | ||
} else { | ||
val render = renderer().render() | ||
display.teleport(render.location) | ||
display.text(render.component.component.build()) | ||
return true | ||
} | ||
} | ||
override fun update(): Boolean = renderer.work() | ||
} |
Oops, something went wrong.