Skip to content

Commit

Permalink
fix: ME glowing color
Browse files Browse the repository at this point in the history
  • Loading branch information
entrypointkr committed Apr 29, 2024
1 parent 8d51cca commit 9da8d3f
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 38 deletions.
124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ In gradle:

groovy
```
compileOnly 'io.typst:bukkit-glow:2.1.0'
compileOnly 'io.typst:bukkit-glow:2.1.1'
```

kts
```
compileOnly("io.typst:bukkit-glow:2.1.0")
compileOnly("io.typst:bukkit-glow:2.1.1")
```

In plugin.yml:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = 'io.typst'
version = '2.1.0'
version = '2.1.1'

repositories {
mavenCentral()
Expand Down
1 change: 0 additions & 1 deletion src/main/java/io/typst/bukkit/glow/GlowAPI.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.typst.bukkit.glow;


import io.typst.bukkit.glow.modelengine.ModelEngineAccessor;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Entity;
Expand Down
57 changes: 57 additions & 0 deletions src/main/java/io/typst/bukkit/glow/ModelEngineAccessor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package io.typst.bukkit.glow;

import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import org.bukkit.ChatColor;

import java.util.UUID;

/**
* for lazy access due the soft depend
*/
class ModelEngineAccessor {
public static void setGlowing(UUID ownerId, ChatColor color) {
ModeledEntity modeledEntity = ModelEngineAPI.getModeledEntity(ownerId);
if (modeledEntity == null) {
return;
}
int rgb = getRGBFromChatColor(color);
for (ActiveModel model : modeledEntity.getModels().values()) {
model.setGlowColor(rgb); // NOTE: ME seems to use ItemDisplay for glowing not scoreboard
model.setGlowing(true);
}
}

public static void removeGlowing(UUID ownerId) {
ModeledEntity modeledEntity = ModelEngineAPI.getModeledEntity(ownerId);
if (modeledEntity == null) {
return;
}
for (ActiveModel model : modeledEntity.getModels().values()) {
model.setGlowing(false);
}
}

// Reference: https://wiki.vg/Text_formatting#Colors
private static int getRGBFromChatColor(ChatColor color) {
return switch (color) {
case BLACK -> 0x000000;
case DARK_BLUE -> 0x0000aa;
case DARK_GREEN -> 0x00aa00;
case DARK_AQUA -> 0x00aaaa;
case DARK_RED -> 0xaa0000;
case DARK_PURPLE -> 0xaa00aa;
case GOLD -> 0xffaa00;
case GRAY -> 0xaaaaaa;
case DARK_GRAY -> 0x555555;
case BLUE -> 0x5555ff;
case GREEN -> 0x55ff55;
case AQUA -> 0x55ffff;
case RED -> 0xff5555;
case LIGHT_PURPLE -> 0xff55ff;
case YELLOW -> 0xffff55;
default -> 0xffffff;
};
}
}

This file was deleted.

0 comments on commit 9da8d3f

Please sign in to comment.